25.10.2009, 10:46
I would consider completely re-writing the dialog portion and removing anything the NPC has to do on his own. All he should have to do is follow a recording and pause whenever someone is close enough. I don't see a reason for the NPC to tell the server if someone is able to buy or not, they should just have to be within range of the NPC.
A personal favorite method of Dialog use that I currently use.
To activate that you just do
You don't have to use that, but it should diminish your problem of single patron use.
A personal favorite method of Dialog use that I currently use.
pawn Код:
#define DIALOG_NONE 0
#define DIALOG_BUY 1
#define DIALOG_AFFIRM 2
pDialogID[MAX_PLAYERS];
pParameters[MAX_PLAYERS];
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(pDialogID[playerid])
{
case DIALOG_NONE: return 1;
case DIALOG_BUY:
{
if(!response)
{
pDialogID[playerid]=DIALOG_NONE;
return SendClientMessage(playerid,0xFF0000FF,"See you around then.");
}
new string[128];
format(string,sizeof(string),"Purchase %d grenades for $%d?",strval(inputtext),25*strval(inputtext));
pParameters[playerid]=strval(inputtext);
pDialogID[playerid]=DIALOG_AFFIRM;
ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,"Purchase Grenades",string,"Accept","Nevermind");
}
case DIALOG_AFFIRM:
{
if(!response)
{
pDialogID[playerid]=DIALOG_BUY;
ShowPlayerDialog(playerid,0,DIALOG_STYLE_INPUT,"Purchase Grenades","How many?","Purchase","Nevermind");
return 1;
}
new string[128];
GetPlayerName(playerid,string,sizeof(string));
format(string,sizeof(string),"Thanks %s. Purchased %d grenades for $%d",string,pParameters[playerid],25*pParameters[playerid]);
SendClientMessage(playerid,0xFF0000FF,string);
GivePlayerMoney(playerid,0-25*pParameters[playerid]);
GivePlayerWeapon(playerid,16,pParameters[playerid]);
pDialogID[playerid]=DIALOG_NONE;
}
}
return 0;
}
pawn Код:
pDialogID[playerid]=DIALOG_BUY;
ShowPlayerDialog(playerid,0,DIALOG_STYLE_INPUT,"Purchase Grenades","How many?","Purchase","Nevermind");