AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Variable Help (https://forums.alliedmods.net/showthread.php?t=41193)

M1dn1ghtT0ker 07-10-2006 19:01

Variable Help
 
I have looked through the forums and I can't find anything that helps me, what i want to do is make a variable type thing like with amx_super's amx_godmode. I want to be able to type "amx_pred <name> X" and have X as 0 = off, 1 = on, and 2 = ON each round. could some tell me how to do this?

XxAvalanchexX 07-10-2006 19:32

Re: Variable Help
 
This should tell you how to make a basic command:
http://wiki.amxmodx.org/index.php/In...od_X_Scripting

To save a variable for each user on your server, the most common things to do is to create an array with 33 indexes and save to/read from it by passing the player id as the index.

Example:
Code:
new myVariable[33]; // this is how to create the array public set_something(id) {    myVariable[id] = 1; // this is how to set the value } public check_something(id) {    client_print(id,print_chat,"Your variable is: %i",myVariable[id]); // this is how to read the value }

GHW_Chronic 07-10-2006 19:42

Re: Variable Help
 
Incase you don't know how to script and thus avalanche's response confused you, here is the full script:
Code:
#include <amxmodx> #include <amxmisc> #include <fun> new bool:godmode[33] public plugin_init() {     register_plugin("Godmode Thingy","1.0","GHW_Chronic")     register_concmd("amx_pred","cmdforward",ADMIN_LEVEL_C,"<name> < 0=no more godmode 1=godmode this round 2=godmode forever >")     register_event("SendAudio","newround","a","2=%!MRAD_terwin","2=%!MRAD_ctwin","2=%!MRAD_rounddraw") } public client_disconnect(id) {     godmode[id]=false } public cmdforward(id,level,cid) {     if(cmd_access(id,level,cid,3))     {         return PLUGIN_HANDLED     }     new arg1[32]     new arg2[8]     read_argv(1,arg1,31)     read_argv(2,arg2,7)     new target=cmd_target(id,arg1,3)     if(!target)     {         return PLUGIN_HANDLED     }     new name[32]     get_user_name(target,name,31)     if(str_to_num(arg2)==0)     {         console_print(id,"[AMXX] Took %s's godmode",name)         client_print(target,print_chat,"[AMXX] An admin has taken your godmode.")         godmode[id]=false         set_user_godmode(target,0)     }     else if(str_to_num(arg2)==1)     {         client_print(target,print_chat,"[AMXX] An admin has given you godmode for this round.")         console_print(id,"[AMXX] Gave %s godmode for this round",name)         godmode[id]=false         set_user_godmode(target,1)     }     else if(str_to_num(arg2)==2)     {         client_print(target,print_chat,"[AMXX] An admin has given you godmode that lasts forever.")         console_print(id,"[AMXX] Gave %s godmode forever",name)         godmode[id]=true         set_user_godmode(target,1)     }     else     {         console_print(id,"amx_pred <name> <0=no more godmode 1=godmode this round 2=godmode forever>")     }     return PLUGIN_HANDLED } public newround() {     for(new i=1;i<=get_maxplayers();i++)     {         if(godmode[i])         {             set_user_godmode(i,1)         }     } }

v3x 07-10-2006 20:04

Re: Variable Help
 
Using ResetHUD in conjunction with a small task would be better.

GHW_Chronic 07-10-2006 20:10

Re: Variable Help
 
Quote:

Originally Posted by v3x
Using ResetHUD in conjunction with a small task would be better.

u can change line:
Code:
register_event("SendAudio","newround","a","2=%!MRAD_terwin","2=%!MRAD_ctwin","2=%!MRAD_rounddraw")
to:
Code:
register_event("ResetHUD","newround","b")
to use resethud which would only be nessesary on a deathmatch server.

v3x 07-10-2006 20:18

Re: Variable Help
 
and then:
Code:
public newround(id)   if(godmode[id])     set_task(0.1 , "set_godmode" , id); public set_godmode(id)   if(is_user_alive(id))     set_user_godmode(id , 1);
:o

GHW_Chronic 07-10-2006 20:19

Re: Variable Help
 
o, i forgot to add the 6.2 second time delay till next round eh? GG for me.

GHW_Chronic 07-10-2006 20:20

Re: Variable Help
 
Code:
#include <amxmodx> #include <amxmisc> #include <fun> new bool:godmode[33] public plugin_init() {     register_plugin("Godmode Thingy","1.0","GHW_Chronic")     register_concmd("amx_pred","cmdforward",ADMIN_LEVEL_C,"<name> < 0=no more godmode 1=godmode this round 2=godmode forever >")     register_event("ResetHUD","newround","b") } public client_disconnect(id) {     godmode[id]=false } public cmdforward(id,level,cid) {     if(cmd_access(id,level,cid,3))     {         return PLUGIN_HANDLED     }     new arg1[32]     new arg2[8]     read_argv(1,arg1,31)     read_argv(2,arg2,7)     new target=cmd_target(id,arg1,3)     if(!target)     {         return PLUGIN_HANDLED     }     new name[32]     get_user_name(target,name,31)     if(str_to_num(arg2)==0)     {         console_print(id,"[AMXX] Took %s's godmode",name)         client_print(target,print_chat,"[AMXX] An admin has taken your godmode.")         godmode[id]=false         set_user_godmode(target,0)     }     else if(str_to_num(arg2)==1)     {         client_print(target,print_chat,"[AMXX] An admin has given you godmode for this round.")         console_print(id,"[AMXX] Gave %s godmode for this round",name)         godmode[id]=false         set_user_godmode(target,1)     }     else if(str_to_num(arg2)==2)     {         client_print(target,print_chat,"[AMXX] An admin has given you godmode that lasts forever.")         console_print(id,"[AMXX] Gave %s godmode forever",name)         godmode[id]=true         set_user_godmode(target,1)     }     else     {         console_print(id,"amx_pred <name> <0=no more godmode 1=godmode this round 2=godmode forever>")     }     return PLUGIN_HANDLED } public newround(id) {     if(godmode[id])     {         set_task(0.2,"newround2",id)     } } public newround2(id) {     set_user_godmode(id,1) }

M1dn1ghtT0ker 07-11-2006 00:59

Re: Variable Help
 
ok im still confused haha but thanks Chronic :)


All times are GMT -4. The time now is 07:58.

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