4 posts,
2 people · 823 views
Thread Rating: ★★★★★
| closed[SOLVED] dod_get_user_stamina? |
| Started by Tank on 02-26-2010, 06:14 PM |
started this thread
Posts: 581Threads: 59
Joined: Jan 2007
02-26-2010, 06:14 PM
#1
I am currently working on a new plugin for my server. In this plugin people can select several options, but I wanted to prevent them from selecting an option they already have.rnrnSo I added some standard if functions, for example:rnrn
case 3: // Option 4rn {rn // Check: equal or more to price, then continuern if(money[id] >= get_pcvar_num(p_dprice))rn {rn if(get_user_gravity(id) == 1)rn {rn // current amount of money equals current money minus cvar-set pricern money[id] -= get_pcvar_num(p_dprice)rn rn set_user_gravity(id,0.5)rn rn client_print(id,print_chat,"[BAMSHOP] You bought Lower Gravity")rn }rn elsern {rn client_print(id,print_chat,"[BAMSHOP] You already have Lower Gravity")rn }rn }rn // Not enough money to purchasern elsern {rn client_print(id,print_chat,"[BAMSHOP] You do not have the money to purchase this item") rn }rn }rnrnI noticed there is only a function available to set stamina, not to get the status of their stamina. As in do they already have unlimited stamina, then they can't buy it again (this is to prevent them being idiots and spending their resources on something they already have).rnrnAny advice?posted here
Posts: 776Threads: 75
Joined: Nov 2007
02-26-2010, 06:39 PM
#2
Since stamina is variable i would give the clients id a value, and reset it when he spawn again or when ever..rnrn->rnrn
new GotUnlimitedStamina[33]rnrnpublic FunctionWhereStaminaIsSet(id)rn{rn if(GotUnlimitedStamina[id])rn returnrn rn // Native set stamina... cant remember what its called :)rn rn GotUnlimitedStamina[id] = 1rn rn returnrn}rnpublic ClientSpawnFunction(id)rn{rn //reset stamina...rn GotUnlimitedStamina[id] = 0rn returnrn}rnpublic client_putinserver(id)rn{rn GotUnlimitedStamina[id] = 0rn returnrn}rnpublic client_disconnect(id)rn{rn GotUnlimitedStamina[id] = 0rn returnrn}rnrnHope i didnt misunderstand...started this thread
Posts: 581Threads: 59
Joined: Jan 2007
02-26-2010, 07:02 PM
#3
Thanks for helping out, that did the job exactly.

