AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Plugin doesn't work properly. (https://forums.alliedmods.net/showthread.php?t=197207)

Unkolix 09-30-2012 02:13

Plugin doesn't work properly.
 
I made that /vipmenu would work only once per round but I can use it as many times as I can and VIP model doesn't change... Why?

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <hamsandwich>
#include <cstrike>
#include <fakemeta>
#include <xs>
#include <engine>
#include <fun>

#define FLAG ADMIN_IMMUNITY

new const MENU_POPUP[] = "misc/DeathRunVip/vip_menu_popup.wav"
new const MENU_OK[] = "misc/DeathRunVip/vip_menu_ok.wav"
new const VIP_CONNECT[] = "misc/DeathRunVip/vip_connect.wav"

#define MAXPLAYERS 32 + 1

static const COLOR[] = "^x04" //green
new gmsgSayText
new maxplayers
new cvar_gravity
new cvar_speed
new SayTxT
new bool:gbUsed[MAXPLAYERS]
new const 
vipmenu[][] =
{
    
"say /vipmenu""say vipmenu""say_team /vipmenu""say_team vipmenu"
}

new 
gCylinderSprite;

public 
plugin_precache()
{
    
precache_model("models/player/DeathRunVip/DeathRunVip.mdl")
        
precache_sound(VIP_CONNECT)

    
precache_sound(MENU_POPUP)
    
precache_sound(MENU_OK)

    
gCylinderSprite precache_model"sprites/shockwave.spr" );
}

public 
plugin_init()
{
    
register_dictionary("drvip.txt");
    
    
register_plugin("Deathrun V.I.P""3.0""Unkolix")

    
cvar_gravity register_cvar("dr_vip_gravity""400")
    
cvar_speed register_cvar("dr_vip_speed""400")

    
RegisterHam(Ham_Spawn"player""bacon_spawn"1)
    
register_forward(FM_SetClientKeyValue"fw_SetClientKeyValue")
    
register_forward(FM_ClientUserInfoChanged"fw_ClientUserInfoChanged")
    
register_clcmd("say /wantvip","ShowMotd")
    
register_event("ResetHUD""resetModel""b")
    
register_logevent"eventRoundEnd"2"1=Round_End" )
    
maxplayers get_maxplayers()
    
gmsgSayText get_user_msgid("SayText")
    
register_clcmd("say""handle_say")
    for(new 
0sizeof vipmenui++)
    
register_clcmd(vipmenu[i], "cmdvipmenu"ADMIN_LEVEL_H)

    
SayTxT get_user_msgid("SayText");
}

public 
resetModel(idlevelcid
{
    if (
get_user_flags(id) & ADMIN_LEVEL_H
    {
        
cs_set_user_model(id"DeathRunVip")    
    }
    return 
PLUGIN_CONTINUE
}

public 
eventRoundEnd()
{
    
arraysetgbUsedfalseMAXPLAYERS )
}

public 
client_disconnect(id)
{
    
gbUsed[id] = false;
}

public 
cmdvipmenu(id
{      
    if( !
gbUsed[id] )
    {
        if(
is_user_alive(id) && get_user_flags(id) & ADMIN_LEVEL_H)
        {
            
VIP_menu(id)
        }
    }
    return 
PLUGIN_HANDLED
}

public 
client_connect(client)
{
    if(
get_user_flags(client) & FLAG)
    {
        
client_cmd(client"spk %s"VIP_CONNECT)

            new 
name[32];
            
get_user_name(clientname31);
            
set_hudmessage02550, -1.00.2906.012.0 );
            
show_hudmessage0"%L"name"VIP_CONNECT");
    }
}

public 
bacon_spawn(id)
{
    if(!
is_user_alive(id))
        return
    
    if(
get_user_flags(id) & FLAG)
    {   
        new 
iOrigin];
        
get_user_originidiOrigin );

        
Create_BeamCylinderiOrigin120gCylinderSprite006160random), random255 ), random), 255);
        
Create_BeamCylinderiOrigin120gCylinderSprite006160random), random255 ), random), 255);
        
Create_BeamCylinderiOrigin120gCylinderSprite006160random), random255 ), random), 255);
    }
}

public 
VIP_menu(id)
{
    static 
CsTeamsteam team cs_get_user_team(id)
    
    if(!
is_user_alive(id))
       return 
PLUGIN_HANDLED

    client_cmd
(id"spk %s"MENU_POPUP)
        
        new 
gmenu menu_create("\y~::*V.I.P Menu*::~" "Vip_Handler");
        
menu_additem(gmenu ,"\r255 \wHealth""1" 0);
        
menu_additem(gmenu ,"\r255 \wArmor""2" 0);
        
menu_additem(gmenu ,"\wGravity""3" 0);
        
menu_additem(gmenu ,"\wSpeed""4" 0);
        
menu_additem(gmenu ,"\wGrenades""5"0);
        
menu_additem(gmenu ,"\wNightVision (\rFor dark maps\w)""6" 0);
    if(
team == CS_TEAM_T)
    {
        
menu_additem(gmenu ,"\wDeagle with \r2 ammo""7" 0);
    }
 
        
menu_setprop(gmenu MPROP_EXIT MEXIT_ALL);
 
        
menu_display(id gmenu 0);

    return 
PLUGIN_CONTINUE
}

public 
Vip_Handler(idgmenuitemplayer)
{
   if(
item == MENU_EXIT)
   {
      
menu_destroy(gmenu)
      return 
PLUGIN_HANDLED
   
}

   new 
data[6], iName[64]
   new 
accesscallback
   menu_item_getinfo
(gmenuitemaccessdata5iName63callback)
   
   new 
key str_to_num(data)
   
   switch(
key)
   {
      case 
1:
      {
    
client_cmd(id"spk %s"MENU_OK)

    
set_user_health(id255)
    
client_printcolor(player"%L""HEALTH")
    
    
gbUsed[id] = true;
      }

      case 
2:
      {
    
client_cmd(id"spk %s"MENU_OK)

    
set_user_armor(id255)
    
client_printcolor(player"%L""ARMOR")
    
    
gbUsed[id] = true;
      }

      case 
3:
      {
    
client_cmd(id"spk %s"MENU_OK)

    new 
Floatgravity
    gravity    
get_pcvar_float(cvar_gravity) / 800

    set_user_gravity
(idgravity)
    
client_printcolor(player"%L""GRAVITY")
    
    
gbUsed[id] = true;
      }
      
      case 
4:
      {
    new 
Floatspeed
    speed    
get_pcvar_float(cvar_speed)

    
client_cmd(id"spk %s"MENU_OK)

    
set_user_maxspeed(idspeed)
    
client_printcolor(player"%L""SPEED")
    
    
gbUsed[id] = true;
      }
      
      case 
5:
      {
    
give_item(id"weapon_hegrenade")
    
give_item(id"weapon_smokegrenade")
    
give_item(id"weapon_flashbang")
    
give_item(id"weapon_flashbang")

    
client_cmd(id"spk %s"MENU_OK)

    
client_printcolor(player"%L""GRENADES")
    
    
gbUsed[id] = true;
      }

      case 
6:
      {
    
cs_set_user_nvg(id)

    
client_cmd(id"spk %s"MENU_OK)

    
client_printcolor(player"%L""NIGHT_VISION")
    
    
gbUsed[id] = true;
      }
      
      case 
7:
      {
    
give_item(id"weapon_deagle")

    new 
weapon_id find_ent_by_owner(-1"weapon_deagle"id);
    if(
weapon_id)
    {
        
cs_set_weapon_ammo(weapon_id2);
    }

    
client_cmd(id"spk %s"MENU_OK)

    
client_printcolor(player"%L""DEAGLE")
    
    
gbUsed[id] = true;
      }
   }
   
menu_destroy(gmenu)
   return 
PLUGIN_HANDLED;
}

public 
client_PreThink(id)
{
    if(
is_user_alive(id))
    {
        if(
get_user_flags(id) & FLAG)
        {
            
            new 
oldbuttons get_user_oldbutton(id);
        
            
            
oldbuttons &= ~IN_JUMP;
            
entity_set_int(idEV_INT_oldbuttonsoldbuttons);
        }
    }
}  

public 
ShowMotd(id)
{
    
show_motd(id"vip.txt")
}

public 
client_putinserver(id)
{
    if (!
task_exists(id)) set_task(60.0"PrintText" ,id)
}

public 
PrintText(id)
{
    
client_print(idprint_chat"%L""WANT_VIP")
}

stock Create_BeamCylinderorigin], addradspritestartfrateframeratelifewidthamplituderedgreenbluebrightnessspeed )
{
    
message_beginMSG_PVSSVC_TEMPENTITYorigin ); 
    
write_byteTE_BEAMCYLINDER );
    
write_coordorigin] );
    
write_coordorigin] );
    
write_coordorigin] );
    
write_coordorigin] );
    
write_coordorigin] );
    
write_coordorigin] + addrad );
    
write_shortsprite );
    
write_bytestartfrate );
    
write_byteframerate );
    
write_byte(life );
    
write_bytewidth );
    
write_byteamplitude );
    
write_bytered );
    
write_bytegreen );
    
write_byteblue );
    
write_bytebrightness );
    
write_bytespeed );
    
message_end();
}

stock te_sprite(idFloat:origin[3], spritescalebrightness)
{
    
message_begin(MSG_ONESVC_TEMPENTITY_id)
    
write_byte(TE_SPRITE)
    
write_coord(floatround(origin[0]))
    
write_coord(floatround(origin[1]))
    
write_coord(floatround(origin[2]))
    
write_short(sprite)
    
write_byte(scale
    
write_byte(brightness)
    
message_end()
}

stock normalize(Float:fIn[3], Float:fOut[3], Float:fMul)
{
    new 
Float:fLen xs_vec_len(fIn)
    
xs_vec_copy(fInfOut)
    
    
fOut[0] /= fLenfOut[1] /= fLenfOut[2] /= fLen
    fOut
[0] *= fMulfOut[1] *= fMulfOut[2] *= fMul
}

stock client_printcolor(const id, const input[], any:...)
{
    new 
count 1players[32];
    static 
msg[191];
    
vformat(msg,190,input,3);
    
replace_all(msg,190,"/g","^4");// green txt
    
replace_all(msg,190,"/y","^1");// orange txt
    
replace_all(msg,190,"/ctr","^3");// team txt
    
replace_all(msg,190,"/w","^0");// team txt
    
if (idplayers[0] = id; else get_players(players,count,"ch");
    for (new 
0counti++)
        if(
is_user_connected(players[i]))
        {
            
message_begin(MSG_ONE_UNRELIABLESayTxT_players[i]);
            
write_byte(players[i]);
            
write_string(msg);
            
message_end();
        }
}    

public 
handle_say(id) {
    new 
said[192]
    
read_args(said,192)
    if(
get_user_flags(id) & ADMIN_LEVEL_H)
    {
    if( ( 
containi(said"who") != -&& containi(said"admin") != -) || contain(said"/vips") != -)
        
set_task(0.1,"print_adminlist",id)
    }
    return 
PLUGIN_CONTINUE
}

public 
print_adminlist(userid
{
    if(
get_user_flags(id) & ADMIN_LEVEL_H)
    {
        new 
adminnames[33][32]
        new 
message[256]
        new 
idcountxlen
        
        
for(id id <= maxplayers id++)
        if(
is_user_connected(id))
        if(
get_user_flags(id) & ADMIN_LEVEL_H)
        
get_user_name(idadminnames[count++], 31)
        
        
len format(message255"%s VIP's online: "COLOR)
        if(
count 0) {
        for(
count x++) {
            
len += format(message[len], 255-len"%s%s "adminnames[x], < (count-1) ? ", ":"")
            if(
len 96 ) {
            
print_message(usermessage)
            
len format(message255"%s ",COLOR)
            }
        }
        
print_message(usermessage)
        }
        else {
        
len += format(message[len], 255-len"There are no VIP's online.")
        
print_message(usermessage)
        }
    }
}

print_message(idmsg[]) {
    
message_begin(MSG_ONEgmsgSayText, {0,0,0}, id)
    
write_byte(id)
    
write_string(msg)
    
message_end()



fysiks 09-30-2012 02:40

Re: Plugin doesn't work properly.
 
The way that you have it coded should only allow you to use it once per map.

Remove the ".mdl" when setting the model.

Unkolix 09-30-2012 07:08

Re: Plugin doesn't work properly.
 
Remade some things but still model doesn't change an I can use /vipmenu as many times as I want... [MAIN POST]

fysiks 09-30-2012 14:31

Re: Plugin doesn't work properly.
 
It seems you need to learn to look for errors any time you have issues with a plugin regardless of what the problem is. If you fix the errors, it will start working. (Tested).

Unkolix 09-30-2012 14:50

Re: Plugin doesn't work properly.
 
But I don't know, there are no errors.. compiles fine. I am new for C++ and I only use codes from other plugins, or remake them...

fysiks 09-30-2012 14:54

Re: Plugin doesn't work properly.
 
Quote:

Originally Posted by Unkolix (Post 1809885)
But I don't know, there are no errors.. compiles fine.

There are errors. Runtime errors. Look in your logs.

Unkolix 09-30-2012 15:00

Re: Plugin doesn't work properly.
 
1 Attachment(s)
When I copyed the code I wrote it did make some errors... But this one doesn't:

fysiks 09-30-2012 15:47

Re: Plugin doesn't work properly.
 
Quote:

Originally Posted by Unkolix (Post 1809892)
When I copyed the code I wrote it did make some errors... But this one doesn't:

It does. You are not looking hard enough. Here is a hint.

Unkolix 10-01-2012 00:35

Re: Plugin doesn't work properly.
 
Ok, umm. I remade those lines to this kind:
PHP Code:

client_print(idprint_chat"%L"id"HEALTH"

But how to make them to show colors like they did before?

And how to make this work with this lines?
PHP Code:

show_hudmessage0"%L"name);
len format(message255"%L"COLOR)
len += format(message[len], 255-len"%L"


fysiks 10-01-2012 00:38

Re: Plugin doesn't work properly.
 
format and formatex work the same with regard to multilingual. The colored ones should be the same also if scripted correctly. I suggest using Connor's color chat stock.


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

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