Raised This Month: $ Target: $400
 0% 

Variable Help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
M1dn1ghtT0ker
Junior Member
Join Date: Mar 2006
Location: Calgary, Alberta, Canada
Old 07-10-2006 , 19:01   Variable Help
Reply With Quote #1

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?
__________________
M1dn1ghtT0ker is offline
Send a message via MSN to M1dn1ghtT0ker
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 07-10-2006 , 19:32   Re: Variable Help
Reply With Quote #2

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 }
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
GHW_Chronic
SourceMod Donor
Join Date: Sep 2004
Location: Texas
Old 07-10-2006 , 19:42   Re: Variable Help
Reply With Quote #3

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)         }     } }

Last edited by GHW_Chronic; 07-10-2006 at 19:45.
GHW_Chronic is offline
Send a message via AIM to GHW_Chronic
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 07-10-2006 , 20:04   Re: Variable Help
Reply With Quote #4

Using ResetHUD in conjunction with a small task would be better.
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
GHW_Chronic
SourceMod Donor
Join Date: Sep 2004
Location: Texas
Old 07-10-2006 , 20:10   Re: Variable Help
Reply With Quote #5

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.
GHW_Chronic is offline
Send a message via AIM to GHW_Chronic
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 07-10-2006 , 20:18   Re: Variable Help
Reply With Quote #6

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);
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
GHW_Chronic
SourceMod Donor
Join Date: Sep 2004
Location: Texas
Old 07-10-2006 , 20:19   Re: Variable Help
Reply With Quote #7

o, i forgot to add the 6.2 second time delay till next round eh? GG for me.
GHW_Chronic is offline
Send a message via AIM to GHW_Chronic
GHW_Chronic
SourceMod Donor
Join Date: Sep 2004
Location: Texas
Old 07-10-2006 , 20:20   Re: Variable Help
Reply With Quote #8

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) }
GHW_Chronic is offline
Send a message via AIM to GHW_Chronic
M1dn1ghtT0ker
Junior Member
Join Date: Mar 2006
Location: Calgary, Alberta, Canada
Old 07-11-2006 , 00:59   Re: Variable Help
Reply With Quote #9

ok im still confused haha but thanks Chronic
__________________
M1dn1ghtT0ker is offline
Send a message via MSN to M1dn1ghtT0ker
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 07:58.


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