26.05.2014, 16:33
I didn't really understand.
A dialog is unique by definition : when a player shows a dialog, you act on a "playerid" var, and playerid is the id of each player who shows the dialog.
So a code like that
Will work as a charm.
A dialog is unique by definition : when a player shows a dialog, you act on a "playerid" var, and playerid is the id of each player who shows the dialog.
So a code like that
PHP код:
new cp[MAX_PLAYERS];
CMD:sellguns(playerid, params[])
{
cp[playerid] = CreateDynamicCP(params);
return 1;
}
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
foreach(new p : Player)
{
if(cp[p] == checkpointid)
{
SetPVarInt(playerid, "WeaponSeller", p);
return ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_LIST, "Buying weapons", "M4\nAk-47\n", "Buy", "Close");
}
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_WEAPONS)
{
if(!response) return 1;
if(listitem == 0)
{
GivePlayerWeapon(playerid, 31, 999);
GivePlayerMoney(playerid, -price_of_the_m4);
GivePlayerMoney(GetPVarInt(playerid, "WeaponSeller"), price_of_the_m4);
return 1;
}
else if(listitem == 1)
{
GivePlayerWeapon(playerid, 30, 999);
GivePlayerMoney(playerid, -price_ak_47);
GivePlayerMoney(GetPVarInt(playerid, "WeaponSeller"), price_ak_k7);
return 1;
}
}
return 0;
}
public OnPlayerExitDynamicCP(playerid, checkpointid)
{
foreach(new p : Players)
{
if(checkpointid == cp[p]) DeletePVar(playerid, "WeaponSeller");
}
}