AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   cvar not working (https://forums.alliedmods.net/showthread.php?t=2295)

Shibz 05-31-2004 23:06

cvar not working
 
This is my first plugin. I just did this to learn, do plz don't tell me that this has already been done because I know. Anyway, with much help from Bailopan, I got this plugin working on everything except the part where it spaces out the slaps using the cvar amx_bslaptime. Instead, it just does them very rapidly, probably at 10 per second or more.

Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> public plugin_init(){     register_plugin("Big Slap","0.0.1","Shibz")     register_concmd("amx_bslap","cmdSlap",ADMIN_SLAY,"<name or #userid> [power] [times]")     register_cvar("amx_bslaptime",".2") } public cmdSlap(id,level,cid){     if (!cmd_access(id,level,cid,2))         return PLUGIN_HANDLED     new arg[32]     read_argv(1,arg,31)     new player = cmd_target(id,arg,5)     if (!player) return PLUGIN_HANDLED     new spower[32],authid[32],name2[32],authid2[32],name[32],stimes[32]     read_argv(2,spower,31)     read_argv(3,stimes,3)     new damage = str_to_num(spower)     new times = str_to_num(stimes)     new Float:delay = get_cvar_num("amx_bslaptime")     new TaskParams[2]     TaskParams[0] = player     TaskParams[1] = damage     set_task(delay, "slap_player", 0, TaskParams, 2, "a", times)     get_user_authid(id,authid,31)     get_user_name(id,name,31)     get_user_authid(player,authid2,31)     get_user_name(player,name2,31)     log_amx("Cmd: ^"%s<%d><%s><>^" slap with %d damage %d times ^"%s<%d><%s><>^"",         name,get_user_userid(id),authid, damage, times,name2,get_user_userid(player),authid2 )         switch(get_cvar_num("amx_show_activity")) {     case 2: client_print(0,print_chat,"ADMIN %s: slap %s with %d damage %d times",name,name2,damage,times)     case 1: client_print(0,print_chat,"ADMIN: slap %s with %d damage %d times",name2,damage,times)     }                 console_print(id,"[AMXX] Client ^"%s^" slaped with %d damage %d times",name2,damage,times)       return PLUGIN_HANDLED }

Peli 05-31-2004 23:42

I think it isn't working because you didn't show the cvar in your code , try this :
Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> public plugin_init(){     register_plugin("Big Slap","0.0.1","Shibz")     register_concmd("amx_bslap","cmdSlap",ADMIN_SLAY,"<name or #userid> [power] [times]")     register_cvar("amx_bslaptime",".2") } public amx_bslaptime { //code here         return PLUGIN_HANDLED public cmdSlap(id,level,cid){     if (!cmd_access(id,level,cid,2))         return PLUGIN_HANDLED     new arg[32]     read_argv(1,arg,31)     new player = cmd_target(id,arg,5)     if (!player) return PLUGIN_HANDLED     new spower[32],authid[32],name2[32],authid2[32],name[32],stimes[32]     read_argv(2,spower,31)     read_argv(3,stimes,3)     new damage = str_to_num(spower)     new times = str_to_num(stimes)     new Float:delay = get_cvar_num("amx_bslaptime")     new TaskParams[2]     TaskParams[0] = player     TaskParams[1] = damage     set_task(delay, "slap_player", 0, TaskParams, 2, "a", times)     get_user_authid(id,authid,31)     get_user_name(id,name,31)     get_user_authid(player,authid2,31)     get_user_name(player,name2,31)     log_amx("Cmd: ^"%s<%d><%s><>^" slap with %d damage %d times ^"%s<%d><%s><>^"",         name,get_user_userid(id),authid, damage, times,name2,get_user_userid(player),authid2 )           switch(get_cvar_num("amx_show_activity")) {     case 2: client_print(0,print_chat,"ADMIN %s: slap %s with %d damage %d times",name,name2,damage,times)     case 1: client_print(0,print_chat,"ADMIN: slap %s with %d damage %d times",name2,damage,times)     }                     console_print(id,"[AMXX] Client ^"%s^" slaped with %d damage %d times",name2,damage,times)       return PLUGIN_HANDLED }

Shibz 06-01-2004 16:02

Uhh, sry bout my annoying nubness, but do I have to put anything where you put that //code here comment? Thanks.

tla-nick 06-01-2004 17:18

You're calling a function slap_player to do the actual slapping which dosn't exist.

You need to add something like this to your plugin:
Code:
public slap_player(id[],power[])     user_slap(id[0],power[0])

you may also need to use get_cvar_float to read the cvar rather than get_cvar_num
Code:
    new Float:delay = get_cvar_float("amx_bslaptime")

Shibz 06-01-2004 19:17

ok, thanks, I got it working.

Shibz 06-04-2004 19:59

Ok, now I want to have it take a user defined value for the delay and if one is not givin, it will use the cvar, but what I am putting in does not work.

Code:
public cmdSlap(id,level,cid){     if (!cmd_access(id,level,cid,2))         return PLUGIN_HANDLED     new arg[32]     read_argv(1,arg,31)     new player = cmd_target(id,arg,5)     if (!player) return PLUGIN_HANDLED     new spower[32],authid[32],name2[32],authid2[32],name[32],stimes[32],sdelay[32]     read_argv(2,spower,31)     read_argv(3,stimes,3)     read_argv(4,sdelay,4)     new damage = str_to_num(spower)     new times = str_to_num(stimes)     new Float:delay = str_to_num(sdelay)     if (!sdelay[0]){         Float:delay = get_cvar_float("amx_sslaptime")     }     new TaskParams[2]     TaskParams[0] = player     TaskParams[1] = damage     set_task(delay, "slap_player", 0, TaskParams, 2, "a", times)     get_user_authid(id,authid,31)     get_user_name(id,name,31)     get_user_authid(player,authid2,31)     get_user_name(player,name2,31)     log_amx("Cmd: ^"%s<%d><%s><>^" slap with %d damage %d times ^"%s<%d><%s><>^"",         name,get_user_userid(id),authid, damage, times,name2,get_user_userid(player),authid2 )     switch(get_cvar_num("amx_show_activity")) {     case 2: client_print(0,print_chat,"ADMIN %s: slap %s with %d damage %d times",name,name2,damage,times)     case 1: client_print(0,print_chat,"ADMIN: slap %s with %d damage %d times",name2,damage,times)     }     console_print(id,"[AMXX] Client ^"%s^" slaped with %d damage %d times",name2,damage,times)       return PLUGIN_HANDLED } public slap_player(data[]) {     new player = data[0]     new damage = data[1]     user_slap(player, damage)     user_slap(player, 0)     user_slap(player, 0) }


All times are GMT -4. The time now is 14:36.

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