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:
<...>
public ShowVipMenu(id, lvl, cid){
if(!cmd_access(id, lvl, cid, 0))
return PLUGIN_HANDLED
new menu = menu_create("vipmenu", "uservipmenu")
menu_additem(menu, "option 1", "", 0) // case 0
menu_additem(menu, "option 2", "", 0) // case 1
menu_additem(menu, "option 3", "", 0) // case 2
menu_additem(menu, "option 4", "", 0) // case 3
menu_additem(menu, "option 5", "", 0) // case 4
menu_additem(menu, "option 6", "", 0)// case 5
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
menu_setprop(menu, MPROP_PERPAGE, 6)
menu_setprop(menu, MPROP_EXITNAME, "exit")
menu_display(id, menu, 0)
return PLUGIN_HANDLED
}
public savingChoice(id, menu, item){
if(item == MENU_EXIT){
menu_cancel(id)
return PLUGIN_HANDLED
}
new command[6], name[64], access, callback
menu_item_getinfo(menu, item, access, command, sizeof command - 1, name, sizeof name - 1, callback)
switch(item){
case 0:{
client_print(id, print_chat, "The chosen item will be activated next round")
userMenuChoice = 1
}
case 1: {
client_print(id, print_chat, "The chosen item will be activated next round")
userMenuChoice = 2
}
case 2: {
client_print(id, print_chat, "The chosen item will be activated next round")
userMenuChoice = 3
}
case 3: {
client_print(id, print_chat, "The chosen item will be activated next round")
userMenuChoice = 4
}
case 4: {
client_print(id, print_chat, "The chosen item will be activated next round")
userMenuChoice = 5
}
case 5:{
client_print(id, print_chat, "The chosen item will be activated next round")
userMenuChoice = 6
}
}
menu_destroy(menu)
return PLUGIN_HANDLED
}
public LogEvent_RoundStart(id, userMenuChoice){
if(userMenuChoice == 1){
give_item(id, "item to give")
}
else if(userMenuChoice == 2){
give_item(id, "item to give")
}
if(userMenuChoice == 3){
give_item(id, "item to give")
}
if(userMenuChoice == 4){
give_item(id, "item to give")
}
if(userMenuChoice == 5){
give_item(id, "item to give")
}
if(userMenuChoice == 6){
give_item(id, "item to give")
}
return PLUGIN_HANDLED
}
<...>
I searched in forums but could find similar question answered, sorry if it exists and I missed it, link to that question would be appreciated.
any help is appreciated. Thank you