04.03.2014, 16:55
Everything works with this system apart from one thing, the main thing. When the player clicks pay, I want it to give the police officer who ticketed him, the amount of the ticket. For example, I ticket someone 10k, he pays the 10k, i get the 10k for ticketing him.
here is my code.
Just so no-one thinks i'm stupid, the if(id==playerid) is commented so I can ticket myself
i dont really know any other way of doing this apart from assigning the player id and amount to a variable, but it doesn't work. Here is the dialog code...
here is my code.
Just so no-one thinks i'm stupid, the if(id==playerid) is commented so I can ticket myself
pawn Код:
new ticketprice[MAX_PLAYERS];
new giventicket[MAX_PLAYERS];
CMD:ticket(playerid, params[])
{
new id, amount, string[128], pName[MAX_PLAYER_NAME], pName2[MAX_PLAYER_NAME];
new Float:x, Float:y, Float:z;
GetPlayerPos(id, x, y, z);
GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerName(id, pName2, sizeof(pName2));
if(sscanf(params, "ui", id, amount)) return SendClientMessage(playerid, 0x0, "{F81414}Console: {FFFFFF}USAGE: /ticket [playerid] [amount]");
if(Team[playerid] != POLICE) return SendClientMessage(playerid, 0x0, "{F81414}Console: {FFFFFF}You aren't a Police Officer!");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0x0, "{F81414}Console: {FFFFFF}Player isn't connected!");
//if(id == playerid) return SendClientMessage(playerid, 0x0, "{F81414}Console: {FFFFFF}You can't ticket yourself!");
if(!IsPlayerInRangeOfPoint(id, 7.0, x, y, z)) return SendClientMessage(playerid, 0x0, "{F81414}Console: {FFFFFF}You aren't in range of this player!");
if(GetPlayerWantedLevel(id > 2)) return SendClientMessage(playerid, 0x0, "{F81414}Console: {FFFFFF}This player needs to be arrested!");
if(amount > 10000) return SendClientMessage(playerid, 0x0, "{F81414}Console: {FFFFFF}You can only ticket someone for a max of 10k!");
if(ticket[id] > 50000)
{
SendClientMessage(playerid, 0x0, "{F81414}Console: {FFFFFF}This player has a ticket price of 50k already, arrest him!");
SetPlayerWantedLevel(id, 4);
}
else ticket[id] += amount;
format(string, sizeof(string), "%s ticketed you $%i!", pName, amount);
ShowPlayerDialog(id, DIALOG_TICKETED, DIALOG_STYLE_MSGBOX, "Ticket", string, "Pay", "Cancel");
ticketprice[id] += amount;
giventicket[id] = playerid;
return 1;
}
pawn Код:
case DIALOG_TICKETED:
{
if(!response)
{
SetPlayerWantedLevel(playerid, 5);
}
if(response)
{
if(GetPlayerMoney(playerid < ticket[playerid])) return SetPlayerWantedLevel(playerid, 5);
GivePlayerMoney(playerid, - ticket[playerid]);
GivePlayerMoney(giventicket[playerid], ticket[playerid]);
}
}
}
return 1;
}