impHullaBaloo
First time out of the vault

So, I'm trying to make a drink that can be used multiple times until depleted. For that, I thought about creating a misc item and using the ammo as the drink content so it loses its "ammo" when consumed. But I already started badly, I can't even make the script count how much of it has left ^^"
I assign the following script to the misc item itself:
As I put in the messages, the script crashed as soon as I try to use the function "get_weapon_ammo_count()". I spend all day trying to figure out what is wrong, maybe I can't use this function in a script assigned to a misc item? Anyway, I'm out of ideas, so any help is welcome ^^".
I assign the following script to the misc item itself:
#define SCRIPT_REALNAME "impdrink"
#include "define.h"
#include "command.h"
procedure use_p_proc;
variable ammoLeft := 0;
variable thisItemPid := 0;
procedure use_p_proc begin
#include "define.h"
#include "command.h"
procedure use_p_proc;
variable ammoLeft := 0;
variable thisItemPid := 0;
procedure use_p_proc begin
thisItemPid=obj_carrying_pid_obj(dude_obj, 653);
if not thisItemPid then return;
float_msg(dude_obj,"work until here",8);
ammoLeft = get_weapon_ammo_count(thisItemPid);
float_msg(dude_obj,"crashed
",8);
set_weapon_ammo_count(thisItemPid, ammoLeft - 1);
intface_redraw;
endif not thisItemPid then return;
float_msg(dude_obj,"work until here",8);
ammoLeft = get_weapon_ammo_count(thisItemPid);
float_msg(dude_obj,"crashed

set_weapon_ammo_count(thisItemPid, ammoLeft - 1);
intface_redraw;
As I put in the messages, the script crashed as soon as I try to use the function "get_weapon_ammo_count()". I spend all day trying to figure out what is wrong, maybe I can't use this function in a script assigned to a misc item? Anyway, I'm out of ideas, so any help is welcome ^^".