Raised This Month: $ Target: $400
 0% 

[?]saving a value on user id


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
sentoki
New Member
Join Date: Aug 2015
Old 08-30-2015 , 10:36   [?]saving a value on user id
Reply With Quote #1

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(idlvlcid){
    
    if(!
cmd_access(idlvlcid0))
        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(menuMPROP_EXITMEXIT_ALL)
    
menu_setprop(menuMPROP_PERPAGE6)
    
menu_setprop(menuMPROP_EXITNAME"exit")

    
menu_display(idmenu0)

    return 
PLUGIN_HANDLED
}

public 
savingChoice(idmenuitem){
    
    if(
item == MENU_EXIT){
        
menu_cancel(id)
        return 
PLUGIN_HANDLED
    
}

    new 
command[6], name[64], accesscallback

    menu_item_getinfo
(menuitemaccesscommandsizeof command 1namesizeof name 1callback)

    switch(
item){
        
        case 
0:{
            
            
client_print(idprint_chat"The chosen item will be activated next round")
            
userMenuChoice 1
        
}
        case 
1: {
            
            
client_print(idprint_chat"The chosen item will be activated next round")
            
userMenuChoice 2
        
}
        case 
2: {
            
            
client_print(idprint_chat"The chosen item will be activated next round")
            
userMenuChoice 3
        
}
        case 
3: {
            
            
client_print(idprint_chat"The chosen item will be activated next round")
            
userMenuChoice 4
        
}
        case 
4: {
            
            
client_print(idprint_chat"The chosen item will be activated next round")
            
userMenuChoice 5
        
}
        case 
5:{
            
            
client_print(idprint_chat"The chosen item will be activated next round")
            
userMenuChoice 6
        
}
    }

    
menu_destroy(menu)

    return 
PLUGIN_HANDLED
}

public 
LogEvent_RoundStart(iduserMenuChoice){
    
    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
sentoki is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:18.


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