03.05.2013, 14:00
Well, I am having some problems giving money and score to the cop when he gives a ticket at a criminal. Here is how it works:
Here is the pawno code of /ticket command:
And here the ticket dialog at OnDialogResponse:
Extra info: I am NOT getting pawno errors while compiling. Everything else works fine when testing it in-game. I need help only for the issue above.
If I have posted in the wrong section, I am sorry. (I am pretty new here, new at scripting too...)
Note: I am about to release the FilterScript called "Police System"... It is 98% done.
People who will help me will be thanked and I won't forget to add the credits at the FilterScript release. (If anyone wants REP+, post here your helpful code or opinion).
Thank you!
- The cop gives a ticket to the criminal.
- A dialog appears to the criminal with a certain information about paying or not the ticket.
- If the criminal presses "Pay", his wanted level decreases to 0.
Here is the pawno code of /ticket command:
PHP код:
dcmd_ticket(playerid,params[])
{
if(gTeam[playerid] <= 7)
{
if(CopDuty[playerid] == 1)
{
if(!strlen(params)) return SendClientMessage(playerid, RED, "Usage: /ticket [Player Id]");
new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
player1 = strval(params);
if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID)
{
if(GetPlayerWantedLevel(player1) == 1)
{
if(GetPlayerMoney(player1) >= 1000)
{
if(!IsPlayerInAnyVehicle(player1))
{
if (GetDistanceBetweenPlayers(playerid, player1) < 10)
{
GetPlayerName(player1, playername, sizeof(playername));
GetPlayerName(playerid, adminname, sizeof(adminname));
format(string,sizeof(string),"Officer %s has given you a ticket.",adminname);
ShowPlayerDialog(player1, DIALOG_TICKET, DIALOG_STYLE_MSGBOX, string, "You can choose to pay or NOT to pay the ticket: \n•If you choose to pay (Costs 1000$), your wanted level \nwill decrease to zero. \n•If you choose NOT to pay, your wanted level \nwill increase to 2 stars.", "Pay", "Don't pay");
format(string, sizeof(string), "Officer %s has given %s a ticket", adminname, playername);
Copstats[playerid][Tickets]++;
return SendClientMessageToAll(COP_COLOR, string);
}
else return SendClientMessage(playerid, RED, "ERROR: You need to be close to the player to give him a ticket.");
}
else return SendClientMessage(playerid, RED, "ERROR: Player is in a vehicle!");
}
else return SendClientMessage(playerid, RED, "ERROR: This player does not have $1000!");
}
else return SendClientMessage(playerid, RED, "ERROR: This player does not have 1 star wanted level!");
}
else return SendClientMessage(playerid, RED, "ERROR: Player not found");
}
else return SendClientMessage(playerid, RED, "ERROR: You have to be on cop duty (/copduty)");
}
else return SendClientMessage(playerid, RED, "ERROR: You have to be a Cop to use this command");
}
PHP код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_TICKET)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
new string[256];
if(response)
{
GivePlayerMoney(playerid, -1000);
SetPlayerWantedLevel(playerid, 0);
format(string, sizeof(string), "%s has paid the ticket.", name);
SendClientMessageToAll(COP_COLOR, string);
}
else
{
SetPlayerWantedLevel(playerid, 2);
format(string, sizeof(string), "%s did NOT pay the ticket.", name);
SendClientMessageToAll(COP_COLOR, string);
}
return 1;
}
return 0;
}
If I have posted in the wrong section, I am sorry. (I am pretty new here, new at scripting too...)
Note: I am about to release the FilterScript called "Police System"... It is 98% done.
People who will help me will be thanked and I won't forget to add the credits at the FilterScript release. (If anyone wants REP+, post here your helpful code or opinion).
Thank you!