AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   make vaules global? (https://forums.alliedmods.net/showthread.php?t=12654)

Bone 04-20-2005 16:22

make vaules global?
 
I am trying make lottery thing in my rp plug in here is current code.

Code:
 ////////////////////////////////////////////////////////////////////  // Start Lottery  //////////////////////////////////////////////////////////////////  public cmd_startlotto(id,level,cid) {     if(!cmd_access(id,level,cid,2)) {         return PLUGIN_HANDLED;     }     // start lotto         new winningticket = random_num (0, 3)     new arg1[256];         new hudstring[256];             read_argv(1,arg1,255);                 new jackpot = str_to_num(arg1)         format(hudstring,255,"%s",lotterymsg);                 return PLUGIN_HANDLED;  }  ////////////////////////////////////////////////////////////////////  // Buy Lotto Ticket  //////////////////////////////////////////////////////////////////  public buyticket(id) {     /*if(!cmd_access(id,level,cid,1)) {     return PLUGIN_HANDLED;     }*/     new ticket = random_num(0,3)         if(haveticket = 1) { // if exceeds our array         client_print(id,print_chat,"* [Lotto] You already have lotto ticket, gotta make it fair^n");         return PLUGIN_HANDLED;     }         client_print(id,print_chat,"* [Lotto] You bought a lotto ticket^n");         return PLUGIN_HANDLED;  }  ////////////////////////////////////////////////////////////////////  // check Lotto Ticket  ////////////////////////////////////////////////////////////////// public checkticket(id) {     /*if(!cmd_access(id,level,cid,1)) {     return PLUGIN_HANDLED;     }*/             if(ticket != winningticket) { // if exceeds our array         client_print(id,print_chat,"* [Lotto] you did not win, try again next time!^n");         return PLUGIN_HANDLED;         }                 client_print(id,print_chat,"* [Lotto] YOU WON THE LOTTERY!!! CONGRATS!!!^n");         userwallet[id] += jackpot         return PLUGIN_HANDLED;  }

the thing is that like checkticket doesnt know bout jackpot which is in when u start loteery etc.. so is there was make variable global so that all commands and shit can use it.

teame06 04-20-2005 16:30

Code:
new Global_variable new Global_variable2 // This is where you would put global variables etc, at the top of the file after the #include //////////////////////////////////////////////////////////////////// // Start Lottery ////////////////////////////////////////////////////////////////// public cmd_startlotto(id,level,cid) {     if(!cmd_access(id,level,cid,2)) {         return PLUGIN_HANDLED;     }     // start lotto         new winningticket = random_num (0, 3)     new arg1[256];         new hudstring[256];             read_argv(1,arg1,255);                 new jackpot = str_to_num(arg1)         format(hudstring,255,"%s",lotterymsg);                 return PLUGIN_HANDLED; } //////////////////////////////////////////////////////////////////// // Buy Lotto Ticket ////////////////////////////////////////////////////////////////// public buyticket(id) {     /*if(!cmd_access(id,level,cid,1)) {     return PLUGIN_HANDLED;     }*/     new ticket = random_num(0,3)         if(haveticket = 1) { // if exceeds our array         client_print(id,print_chat,"* [Lotto] You already have lotto ticket, gotta make it fair^n");         return PLUGIN_HANDLED;     }         client_print(id,print_chat,"* [Lotto] You bought a lotto ticket^n");         return PLUGIN_HANDLED; } //////////////////////////////////////////////////////////////////// // check Lotto Ticket ////////////////////////////////////////////////////////////////// public checkticket(id) {     /*if(!cmd_access(id,level,cid,1)) {     return PLUGIN_HANDLED;     }*/             if(ticket != winningticket) { // if exceeds our array         client_print(id,print_chat,"* [Lotto] you did not win, try again next time!^n");         return PLUGIN_HANDLED;         }                 client_print(id,print_chat,"* [Lotto] YOU WON THE LOTTERY!!! CONGRATS!!!^n");         userwallet[id] += jackpot         return PLUGIN_HANDLED; }

v3x 04-20-2005 16:32

Can it also be g_* ? ;)

teame06 04-20-2005 16:32

Quote:

Originally Posted by v3x
Can it also be g_* ? ;)

It can be v3x_* if you want it lol.

XxAvalanchexX 04-20-2005 16:33

Quote:

Originally Posted by v3x
Can it also be g_* ? ;)

Yes, it can have any name, stop making useless posts!! :-)


All times are GMT -4. The time now is 09:54.

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