Spawn-weapons
#2

We could problably create a function that handles giving out gunsets, like this.
PHP код:
GiveGuns(playerid)
{
    switch(
chosenGuns[playerid])
    {
        case 
0// just in case something broke along the way
        
{
            
ShowPlayerDialog(playeridDIALOG_SHOWMENUDIALOG_STYLE_TABLIST"Spawn weapons",
            
"Weapon set 1:\t Deagle\t$0\n\
            Weapon set 2:\t Deagle, shotgun\t$500\n\
            Weapon set 3:\t Deagle, shotgun, M4\t$500"
//
            
"Select""Close");
            return 
1;
        }
        case 
1:
        {
            
// give gunset 1..
        
}
        case 
2:
        {
            
// give gunset 2..
        
}
        case 
3:
        {
            
// give gunset 3..
        
}
    }

For that we'd create a global variable
PHP код:
new chosenGuns[MAX_PLAYERS]; 
and on the dialog response we'd set the gunset they chose and make the guns be given aswell,
PHP код:
switch(listitem)
{
    case 
0:
    {
        
chosenGuns[playerid] = 1;
        
GiveGuns(playerid);
    }
    case 
1:
    {
        
chosenGuns[playerid] = 2;
        
GiveGuns(playerid);
    }
    case 
2:
    {
        
chosenGuns[playerid] = 3;
        
GiveGuns(playerid);
    }

then OnPlayerConnect we'd add
PHP код:
chosenGuns[playerid] = 
to make sure the gunset gets reset for the playerid.

then OnPlayerSpawn we'd add
PHP код:
GiveGuns(playerid); 

Also, there won't actually be a need to show the gun menu, since if he has chosenGuns set to 0, the GiveGuns function will handle it.
I'm talking about the following code
PHP код:
OnPlayerSpawn
{
       if(
ShowMenu[playerid] == 1)
    {
        
ShowPlayerDialog(playeridDIALOG_SHOWMENUDIALOG_STYLE_TABLIST"Spawn weapons",
        
"Weapon set 1:\t Deagle\t$0\n\
        Weapon set 2:\t Deagle, shotgun\t$500\n\
        Weapon set 3:\t Deagle, shotgun, M4\t$500"
//
        
"Select""Close");
                } 
Reply


Messages In This Thread
Spawn-weapons[answered] - by Counterafk - 02.12.2015, 02:44
Re: Spawn-weapons - by CmZxC - 02.12.2015, 02:54
Re: Spawn-weapons - by Counterafk - 02.12.2015, 05:05
Re: Spawn-weapons - by PinkFloydLover - 02.12.2015, 05:21
Re: Spawn-weapons - by Counterafk - 02.12.2015, 05:37

Forum Jump:


Users browsing this thread: 1 Guest(s)