Day of Defeat Plugins Community
This site is an archive — everything is readable and downloadable, nothing can be posted. Admin
Archive › Old Forum Threads › Help › Scripting Help › [SOLVED] dod_get_user_stamina?
4 posts, 2 people · 823 views Thread Rating: ★★★★★
closed[SOLVED] dod_get_user_stamina?
Started by Tank on 02-26-2010, 06:14 PM
Tank
started this thread
Posts: 581
Threads: 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?

Dr.G
posted here
Posts: 776
Threads: 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...

Tank
started this thread
Posts: 581
Threads: 59
Joined: Jan 2007
02-26-2010, 07:02 PM #3

Thanks for helping out, that did the job exactly.

Dr.G
posted here
Posts: 776
Threads: 75
Joined: Nov 2007
02-26-2010, 09:16 PM #4

no problemo ;)

Archive › Old Forum Threads › Help › Scripting Help › [SOLVED] dod_get_user_stamina?
DoD Plugins Archive · Repository · Old Forum Threads · Maps · Admin · built 14 Sep 2026 00:34 UTC