Giving $ and score to cop after ticketing a criminal -
Dragonsaurus - 03.05.2013
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:
- 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.
The problem is that I can't find out how to give a certain amount of score and money to the cop, if the criminal pays the ticket.
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");
}
And here the ticket dialog at OnDialogResponse:
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;
}
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!
Re: Giving $ and score to cop after ticketing a criminal -
RevolutionaryGaming - 03.05.2013
I am going to assume you are using an enum to save player information. If that is so, I would recommend adding another field to it called TicketingCop and make it the size of MAX_PLAYERS. When the cop uses the ticket command on that player, set that player's TicketingCop value to the ID of that cop.
Under your dialog response, you'll want to use the following to give money to the cop:
pawn Код:
GivePlayerMoney(PlayerInfo[playerid][TicketingCop], 1000);
Same goes for score. In essence, you are using the ID saved as the TicketingCop value for the player to give the money to the cop.
Re: Giving $ and score to cop after ticketing a criminal -
Dragonsaurus - 03.05.2013
Thanks pal, that worked, but I only tested it on myself (I ticketed myself and not other players)
Soon I will try it with my friend...
Thanks again!
EDIT: Tested and succeed! Rep+! Big thanks!