Giving $ and score to cop after ticketing a criminal
#1

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(playeridRED"Usage: /ticket [Player Id]");
            new 
player1playername[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(playeridplayer1) < 10)
                            {
                                
GetPlayerName(player1playernamesizeof(playername));
                                
GetPlayerName(playeridadminnamesizeof(adminname));
                                
format(string,sizeof(string),"Officer %s has given you a ticket.",adminname);
                                
ShowPlayerDialog(player1DIALOG_TICKETDIALOG_STYLE_MSGBOXstring"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(stringsizeof(string), "Officer %s has given %s a ticket"adminnameplayername);
                                
Copstats[playerid][Tickets]++;
                                return 
SendClientMessageToAll(COP_COLORstring);
                            }
                            else return 
SendClientMessage(playeridRED"ERROR: You need to be close to the player to give him a ticket.");
                        }
                        else return 
SendClientMessage(playeridRED"ERROR: Player is in a vehicle!");
                    }
                    else return 
SendClientMessage(playeridRED"ERROR: This player does not have $1000!");
                }
                else return 
SendClientMessage(playeridRED"ERROR: This player does not have 1 star wanted level!");
            }
            else return 
SendClientMessage(playeridRED"ERROR: Player not found");
        }
        else return 
SendClientMessage(playeridRED"ERROR: You have to be on cop duty (/copduty)");
    }
    else return 
SendClientMessage(playeridRED"ERROR: You have to be a Cop to use this command");

And here the ticket dialog at OnDialogResponse:

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    if(
dialogid == DIALOG_TICKET)
    {
        new 
name[MAX_PLAYER_NAME];
        
GetPlayerName(playeridnamesizeof(name));
        new 
string[256];
        if(
response)
        {
            
GivePlayerMoney(playerid, -1000);
            
SetPlayerWantedLevel(playerid0);
            
format(stringsizeof(string), "%s has paid the ticket."name);
            
SendClientMessageToAll(COP_COLORstring);
        }
        else
        {
            
SetPlayerWantedLevel(playerid2);
            
format(stringsizeof(string), "%s did NOT pay the ticket."name);
            
SendClientMessageToAll(COP_COLORstring);
        }
        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!
Reply
#2

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.
Reply
#3

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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)