AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problem with a drunk effect. (https://forums.alliedmods.net/showthread.php?t=120723)

benamo6 03-07-2010 13:04

Problem with a drunk effect.
 
Wath is wrong with this code? The /drunk command dont work at all. I cant even see the print_chat.
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fun>
#include <cstrike>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"
new HasPrize[33][2];
new 
dcounter[33];
new 
sprSmoke;
new 
moved[33];
new 
moves[4][] = {"+moveleft","+moveright","+back","+forward"};
new 
mdlWbottle
new mdlWcan;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /drunk","drunk")
}
public 
plugin_precache()
{
    if(
file_exists("models/winebottle.mdl")==1)
    {
        
mdlWbottle precache_model("models/winebottle.mdl");
    }
    else
    {
        
mdlWbottle precache_model("models/can.mdl");
    }
    
sprSmoke precache_model("sprites/steam1.spr");
}
public 
client_putinserver(id)
{
    
HasPrize[id][0] = 0;
    
HasPrize[id][1] = 0;
}
public 
client_disconnect(id)
{
    
HasPrize[id][0] = 0;
    
HasPrize[id][1] = 0;
}
public 
drunk(id)
{
    
client_print(idprint_chat"You got drunk")
    new 
tid[1];
    
tid[0] = id;
    
dcounter[id] = 0;
    
set_task(0.5,"smokin_1",0,tid,1,"a",HasPrize[id][1]*2);
}
public 
sqrt(num)
{
    if(
get_cvar_num("amx_dice_debug") == 2)
        
log_amx("DEBUG (Advanced Roll the Dice): Function sqrt");
        
    new 
div num;
    new 
result 1;
    
    while (
div result)            // end when div == result, or just below 
    
{
        
div = (div result) / 2;    // take mean value as new divisor 
        
result num div;
    }
    
    return 
div;
}
public 
smokin_1(id[])
{
    if( (
is_user_alive(id[0])))
    {
        new 
vec[3], cmd[16];
        new 
a,by1,dfov,x1;
        
        
x1 random_num(-40,40);
        
y1 random_num(-40,40);
        
dcounter[id[0]] += 1;
        
get_user_origin(id[0],vec);
        
        
//Smoke    
        
message_beginMSG_BROADCAST,SVC_TEMPENTITY);
        
write_byte);
        
write_coord(vec[0]+x1);
        
write_coord(vec[1]+y1);
        
write_coord(vec[2]+30);
        
write_shortsprSmoke );
        
write_byte30 );
        
write_byte10 );
        
message_end();
        
        
dfov random_num(10,120);
        
format(cmd,15,"default_fov %d",dfov);        
        
client_cmd(id[0],cmd);
        
        if(
moved[id[0]] == 1)
        {
            
client_cmd(id[0],"-moveleft;-moveright;-forward;-back");
            
moved[id[0]] = 0;
        }
        
        
random_num(0,9);
        
        if(
== 1)
        {
            
emit_sound(id[0],CHAN_ITEM"misc/burp.wav"1.0ATTN_NORM0PITCH_NORM);
            
random_num(0,3);            
            
client_cmd(id[0],moves[a]);
            
moved[id[0]] = 1;
            new 
aimvec[3];
            new 
velocityvec[3];
            new 
length
            new 
speed 500;
            
get_user_origin(id[0],aimvec,2);
            
velocityvec[0]=aimvec[0]-vec[0];
            
velocityvec[1]=aimvec[1]-vec[1];
            
velocityvec[2]=aimvec[2]-vec[2];
            
length=sqrt(velocityvec[0]*velocityvec[0]+velocityvec[1]*velocityvec[1]+velocityvec[2]*velocityvec[2]);
            
velocityvec[0]=velocityvec[0]*speed/length;
            
velocityvec[1]=velocityvec[1]*speed/length;
            
velocityvec[2]=velocityvec[2]*speed/length;
            
            
// TE_MODEL from HL-SDK common/const.h 
            
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
            
write_byte(106);
            
write_coord(vec[0]);
            
write_coord(vec[1]);
            
write_coord(vec[2]+20);
            
write_coord(velocityvec[0]);
            
write_coord(velocityvec[1]);
            
write_coord(velocityvec[2]+100);
            
write_angle (0);
            if(
random(8) == 4)
                
write_short (mdlWbottle);
            else 
                
write_short (mdlWcan);
            
write_byte (2);
            
write_byte (255);
            
message_end();
        }
    }
    
    
    if(
moved[id[0]] == 1)
    {
        
client_cmd(id[0],"-moveleft;-moveright;-forward;-back");
        
        
client_cmd(id[0],"default_fov 90");
    }
    
    return 
PLUGIN_CONTINUE;



ConnorMcLeod 03-07-2010 13:58

Re: Wath is wrong with this code?
 
What is wrong with your title ?

benamo6 03-07-2010 14:00

Re: Problem with a drunk effect.
 
Fixed?


All times are GMT -4. The time now is 08:47.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.