02.12.2015, 02:54
We could problably create a function that handles giving out gunsets, like this.
For that we'd create a global variable
and on the dialog response we'd set the gunset they chose and make the guns be given aswell,
then OnPlayerConnect we'd add
to make sure the gunset gets reset for the playerid.
then OnPlayerSpawn we'd add
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 код:
GiveGuns(playerid)
{
switch(chosenGuns[playerid])
{
case 0: // just in case something broke along the way
{
ShowPlayerDialog(playerid, DIALOG_SHOWMENU, DIALOG_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..
}
}
}
PHP код:
new chosenGuns[MAX_PLAYERS];
PHP код:
switch(listitem)
{
case 0:
{
chosenGuns[playerid] = 1;
GiveGuns(playerid);
}
case 1:
{
chosenGuns[playerid] = 2;
GiveGuns(playerid);
}
case 2:
{
chosenGuns[playerid] = 3;
GiveGuns(playerid);
}
}
PHP код:
chosenGuns[playerid] = 0
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(playerid, DIALOG_SHOWMENU, DIALOG_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");
}