Raised This Month: $ Target: $400
 0% 

cvar not working


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Shibz
Junior Member
Join Date: Apr 2004
Old 05-31-2004 , 23:06   cvar not working
Reply With Quote #1

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 }
Shibz is offline
Peli
Veteran Member
Join Date: Mar 2004
Location: San Diego, CA
Old 05-31-2004 , 23:42  
Reply With Quote #2

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 }
Peli is offline
Send a message via MSN to Peli
Shibz
Junior Member
Join Date: Apr 2004
Old 06-01-2004 , 16:02  
Reply With Quote #3

Uhh, sry bout my annoying nubness, but do I have to put anything where you put that //code here comment? Thanks.
Shibz is offline
tla-nick
Junior Member
Join Date: Mar 2004
Location: Bradford UK
Old 06-01-2004 , 17:18  
Reply With Quote #4

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")
__________________
Where did you want to be, the day before yesterday?

- Another Disgruntled Microsoft User
tla-nick is offline
Shibz
Junior Member
Join Date: Apr 2004
Old 06-01-2004 , 19:17  
Reply With Quote #5

ok, thanks, I got it working.
Shibz is offline
Shibz
Junior Member
Join Date: Apr 2004
Old 06-04-2004 , 19:59  
Reply With Quote #6

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) }
Shibz is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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