[?]saving a value on user id
Hello guys, I recently got into scripting and trying to learn while making an example plugin for myself.
I try to add many things to the vip plugin to get to know as much as I can. I thought about ability for a player to open a vipmenu at any time ,doesn't matter he's dead or alive(and user can open menu and change his choice multiple times), then save his choice and give him selected item at the beginning of the next round. For example player opens the menu, chooses let's say free armor, his choice is saved, when the next round starts he's given free armor and this happens at every round until he chooses something else. My idea was to let the player open a menu at any time he wants, give every item a case number, then when he chooses, save that number as a variable value, and at the beginning of every round, check the value of a given variable and give items according to that value. My question is, how do I save the value of that variable depending on a player? I mean, I think I somehow need to assign the value to the id's of players and how do I do that? or is it simpler than that? The part pattern of the code would look something like this: PHP Code:
any help is appreciated. Thank you |
Re: [?]saving a value on user id
You simply create a global array with a size of 33. Then you index that array using "id" and assign the value you want to store to that cell of the array.
PHP Code:
|
Re: [?]saving a value on user id
I think better to use MAX_PLAYERS than 33:
PHP Code:
PHP Code:
|
Re: [?]saving a value on user id
Quote:
Quote:
|
Re: [?]saving a value on user id
Thank you, this helped, but I bumped into another thing related to this array.
i print values to check whether they were assigned correctly, and on the part "mainvipmenu" the value remains what it was assigned, however i tried printing out the value of vipPlayerValues on the round start and it always gives me a 0, and so if it's a zero it is neither of the cases. i commented on the code what I tried, but still same result:? might you spot why this is happening? I would appreciate it. PHP Code:
|
Re: [?]saving a value on user id
Round start doesn't passes the player index, use get_players and loop through them.
|
Re: [?]saving a value on user id
All worked well ^^. thank you all for the help
|
| All times are GMT -4. The time now is 22:18. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.