Ticket and Payticket command
#1

Heey guys
I made a ticket and payticket command:
Код:
dcmd_payticket(playerid,params[])
{
	#pragma unused params
	new string[128];
    if(IsSpawned[playerid] != 1)
	{
	    SendClientMessage(playerid,COLOR_RED,"You must be alive and spawned in order to be able to use this command.");
	    return 1;
	}
	if(IsKidnapped[playerid] == 1)
	{
	    SendClientMessage(playerid,COLOR_RED,"You are kidnapped. You cannot use this command.");
	    return 1;
	}
	if(HasTicket[playerid] != 1)
	{
	    SendClientMessage(playerid,COLOR_RED,"You do not have a ticket to pay.");
		return 1;
	}
	SendClientMessage(playerid,COLOR_DEADCONNECT,"[[_Ticket Paid_]]");
	SendClientMessage(playerid,COLOR_LIGHTBLUE,"You have paid your ticket of $2000 and your wanted level has been removed.");
	SetPlayerWantedLevel(playerid,0);
	GivePlayerMoney(playerid,-2000);

	HasTicket[playerid] =0;
	TimeToPayTicket[playerid] =0;

	format(string,sizeof(string),"[POLICE RADIO] Suspect %s(%d) has paid their ticket of $2000 and their wanted level has been removed.",PlayerName(playerid),playerid);
	SendClientMessageToAllCops(string);
	return 1;
}
Код:
dcmd_ticket(playerid,params[])
{
	new string[128];
	new ID;
	if(sscanf(params, "u", ID))
	{
		SendClientMessage(playerid,COLOR_RED,"USAGE: /ticket (Player Name/ID)");
	    return 1;
	}
	if(IsKidnapped[playerid] == 1)
	{
	    SendClientMessage(playerid,COLOR_RED,"You are kidnapped. You cannot use this command.");
	    return 1;
	}
    if(IsSpawned[playerid] != 1)
	{
 		SendClientMessage(playerid,COLOR_RED,"You must be alive and spawned in order to be able to use this command.");
	    return 1;
	}
	if(gTeam[playerid] != TEAM_COP)
	{
	    SendClientMessage(playerid,COLOR_RED,"Only law enforcement can issue tickets to suspects.");
	    return 1;
	}
	if(InAdminMode[ID] == 1)
	{
	    SendClientMessage(playerid,COLOR_RED,"You cannot use this command on this player because they are in Administrator mode.");
	    return 1;
	}
	if(!IsPlayerConnected(ID))
	{
	    format(string,sizeof(string),"The player ID (%d) is not connected to the server. You cannot issue them a ticket.",ID);
	    SendClientMessage(playerid,COLOR_RED,string);
	    return 1;
	}
	if(GetPlayerWantedLevel(ID) >= 2)
	{
	    SendClientMessage(playerid,COLOR_RED,"You cannot give this player a ticket! You need to arrest him!");
	    return 1;
	}
	if(GetDistanceBetweenPlayers(playerid,ID) > 8)
	{
	    format(string,sizeof(string),"%s(%d) is too far away. You cannot issue them a ticket. Get closer.",PlayerName(ID),ID);
	    SendClientMessage(playerid,COLOR_RED,string);
	    return 1;
	}
	if(HasTicket[ID] ==1)
	{
		SendClientMessage(ID,COLOR_RED,"Pay Your ticket!");
		return 1;
	}
	SendClientMessage(ID,COLOR_DEADCONNECT,"[[_Fined_]]");
	format(string,sizeof(string),"Law Enforcement Officer %s(%d) has issued you a ticket of $2000 for your criminal actions.",PlayerName(playerid),playerid);
	SendClientMessage(ID,COLOR_DODGERBLUE,string);
	SendClientMessage(ID,COLOR_DODGERBLUE,"You have 2 minutes to pay this ticket with /payticket or your wanted level will increase.");
	HasTicket[ID] =1;
	TimeToPayTicket[ID] =120;
	TextDrawSetString(MessageTD[ID],"TICKET RECIEVED");
	TextDrawShowForPlayer(ID,MessageTD[ID]);
	MessageTDTime[ID] =5;
	IncreasePlayerScore(playerid,1);

	format(string,sizeof(string),"[POLICE RADIO] Law Enforcement Officer %s(%d) has issued a ticket of $2000 to %s(%d).",PlayerName(playerid),playerid,PlayerName(ID),ID);
	SendClientMessageToAllCops(string);
	return 1;
}
But how can i let it make if the suspect pays his ticket that the cop who gave the ticket gets money.
Thanks admigo
Reply
#2

This should work:

pawn Код:
dcmd_payticket(playerid,params[])
{
    #pragma unused params
    new string[128];
    if(IsSpawned[playerid] != 1)
    {
        SendClientMessage(playerid,COLOR_RED,"You must be alive and spawned in order to be able to use this command.");
        return 1;
    }
    if(IsKidnapped[playerid] == 1)
    {
        SendClientMessage(playerid,COLOR_RED,"You are kidnapped. You cannot use this command.");
        return 1;
    }
    if(HasTicket[playerid] != 1)
    {
        SendClientMessage(playerid,COLOR_RED,"You do not have a ticket to pay.");
        return 1;
    }
    SendClientMessage(playerid,COLOR_DEADCONNECT,"[[_Ticket Paid_]]");
    SendClientMessage(playerid,COLOR_LIGHTBLUE,"You have paid your ticket of $2000 and your wanted level has been removed.");
    SetPlayerWantedLevel(playerid,0);
    GivePlayerMoney(playerid,-2000);
    if(IsPlayerConnected(GetPVarInt(playerid, "copTicket")) && GetPVarType(playerid, "copTicket") != 0) {
        GivePlayerMoney(GetPVarInt(playerid, "copTicket"), 2000);
        DeletePVar(playerid, "copTicket");
    }

    HasTicket[playerid] =0;
    TimeToPayTicket[playerid] =0;

    format(string,sizeof(string),"[POLICE RADIO] Suspect %s(%d) has paid their ticket of $2000 and their wanted level has been removed.",PlayerName(playerid),playerid);
    SendClientMessageToAllCops(string);
    return 1;
}

dcmd_ticket(playerid,params[])
{
    new string[128];
    new ID;
    if(sscanf(params, "u", ID))
    {
        SendClientMessage(playerid,COLOR_RED,"USAGE: /ticket (Player Name/ID)");
        return 1;
    }
    if(IsKidnapped[playerid] == 1)
    {
        SendClientMessage(playerid,COLOR_RED,"You are kidnapped. You cannot use this command.");
        return 1;
    }
    if(IsSpawned[playerid] != 1)
    {
        SendClientMessage(playerid,COLOR_RED,"You must be alive and spawned in order to be able to use this command.");
        return 1;
    }
    if(gTeam[playerid] != TEAM_COP)
    {
        SendClientMessage(playerid,COLOR_RED,"Only law enforcement can issue tickets to suspects.");
        return 1;
    }
    if(InAdminMode[ID] == 1)
    {
        SendClientMessage(playerid,COLOR_RED,"You cannot use this command on this player because they are in Administrator mode.");
        return 1;
    }
    if(!IsPlayerConnected(ID))
    {
        format(string,sizeof(string),"The player ID (%d) is not connected to the server. You cannot issue them a ticket.",ID);
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
    if(GetPlayerWantedLevel(ID) >= 2)
    {
        SendClientMessage(playerid,COLOR_RED,"You cannot give this player a ticket! You need to arrest him!");
        return 1;
    }
    if(GetDistanceBetweenPlayers(playerid,ID) > 8)
    {
        format(string,sizeof(string),"%s(%d) is too far away. You cannot issue them a ticket. Get closer.",PlayerName(ID),ID);
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
    if(HasTicket[ID] ==1)
    {
        SendClientMessage(ID,COLOR_RED,"Pay Your ticket!");
        return 1;
    }
    SendClientMessage(ID,COLOR_DEADCONNECT,"[[_Fined_]]");
    format(string,sizeof(string),"Law Enforcement Officer %s(%d) has issued you a ticket of $2000 for your criminal actions.",PlayerName(playerid),playerid);
    SendClientMessage(ID,COLOR_DODGERBLUE,string);
    SendClientMessage(ID,COLOR_DODGERBLUE,"You have 2 minutes to pay this ticket with /payticket or your wanted level will increase.");
    HasTicket[ID] =1;
    TimeToPayTicket[ID] =120;
    TextDrawSetString(MessageTD[ID],"TICKET RECIEVED");
    TextDrawShowForPlayer(ID,MessageTD[ID]);
    MessageTDTime[ID] =5;
    SetPVarInt(ID, "copTicket", playerid);
    IncreasePlayerScore(playerid,1);

    format(string,sizeof(string),"[POLICE RADIO] Law Enforcement Officer %s(%d) has issued a ticket of $2000 to %s(%d).",PlayerName(playerid),playerid,PlayerName(ID),ID);
    SendClientMessageToAllCops(string);
    return 1;
}
Reply
#3

Quote:
Originally Posted by __
Посмотреть сообщение
This should work:

pawn Код:
dcmd_payticket(playerid,params[])
{
    #pragma unused params
    new string[128];
    if(IsSpawned[playerid] != 1)
    {
        SendClientMessage(playerid,COLOR_RED,"You must be alive and spawned in order to be able to use this command.");
        return 1;
    }
    if(IsKidnapped[playerid] == 1)
    {
        SendClientMessage(playerid,COLOR_RED,"You are kidnapped. You cannot use this command.");
        return 1;
    }
    if(HasTicket[playerid] != 1)
    {
        SendClientMessage(playerid,COLOR_RED,"You do not have a ticket to pay.");
        return 1;
    }
    SendClientMessage(playerid,COLOR_DEADCONNECT,"[[_Ticket Paid_]]");
    SendClientMessage(playerid,COLOR_LIGHTBLUE,"You have paid your ticket of $2000 and your wanted level has been removed.");
    SetPlayerWantedLevel(playerid,0);
    GivePlayerMoney(playerid,-2000);
    if(IsPlayerConnected(GetPVarInt(playerid, "copTicket")) && GetPVarType(playerid, "copTicket") != 0) {
        GivePlayerMoney(GetPVarInt(playerid, "copTicket"), 2000);
        DeletePVar(playerid, "copTicket");
    }

    HasTicket[playerid] =0;
    TimeToPayTicket[playerid] =0;

    format(string,sizeof(string),"[POLICE RADIO] Suspect %s(%d) has paid their ticket of $2000 and their wanted level has been removed.",PlayerName(playerid),playerid);
    SendClientMessageToAllCops(string);
    return 1;
}

dcmd_ticket(playerid,params[])
{
    new string[128];
    new ID;
    if(sscanf(params, "u", ID))
    {
        SendClientMessage(playerid,COLOR_RED,"USAGE: /ticket (Player Name/ID)");
        return 1;
    }
    if(IsKidnapped[playerid] == 1)
    {
        SendClientMessage(playerid,COLOR_RED,"You are kidnapped. You cannot use this command.");
        return 1;
    }
    if(IsSpawned[playerid] != 1)
    {
        SendClientMessage(playerid,COLOR_RED,"You must be alive and spawned in order to be able to use this command.");
        return 1;
    }
    if(gTeam[playerid] != TEAM_COP)
    {
        SendClientMessage(playerid,COLOR_RED,"Only law enforcement can issue tickets to suspects.");
        return 1;
    }
    if(InAdminMode[ID] == 1)
    {
        SendClientMessage(playerid,COLOR_RED,"You cannot use this command on this player because they are in Administrator mode.");
        return 1;
    }
    if(!IsPlayerConnected(ID))
    {
        format(string,sizeof(string),"The player ID (%d) is not connected to the server. You cannot issue them a ticket.",ID);
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
    if(GetPlayerWantedLevel(ID) >= 2)
    {
        SendClientMessage(playerid,COLOR_RED,"You cannot give this player a ticket! You need to arrest him!");
        return 1;
    }
    if(GetDistanceBetweenPlayers(playerid,ID) > 8)
    {
        format(string,sizeof(string),"%s(%d) is too far away. You cannot issue them a ticket. Get closer.",PlayerName(ID),ID);
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
    if(HasTicket[ID] ==1)
    {
        SendClientMessage(ID,COLOR_RED,"Pay Your ticket!");
        return 1;
    }
    SendClientMessage(ID,COLOR_DEADCONNECT,"[[_Fined_]]");
    format(string,sizeof(string),"Law Enforcement Officer %s(%d) has issued you a ticket of $2000 for your criminal actions.",PlayerName(playerid),playerid);
    SendClientMessage(ID,COLOR_DODGERBLUE,string);
    SendClientMessage(ID,COLOR_DODGERBLUE,"You have 2 minutes to pay this ticket with /payticket or your wanted level will increase.");
    HasTicket[ID] =1;
    TimeToPayTicket[ID] =120;
    TextDrawSetString(MessageTD[ID],"TICKET RECIEVED");
    TextDrawShowForPlayer(ID,MessageTD[ID]);
    MessageTDTime[ID] =5;
    SetPVarInt(ID, "copTicket", playerid);
    IncreasePlayerScore(playerid,1);

    format(string,sizeof(string),"[POLICE RADIO] Law Enforcement Officer %s(%d) has issued a ticket of $2000 to %s(%d).",PlayerName(playerid),playerid,PlayerName(ID),ID);
    SendClientMessageToAllCops(string);
    return 1;
}
OMG Ty FIXED!Can you explain me what SetPVarInt does?
Reply
#4

Lol, with all your help threads we're making your GameMode.

Those PVar things are Player Variables.
Which means it will set that variable for the whole server, not just your gamemode.
E.g.
In your GM:
pawn Код:
SetPVarInt(playerid, "Test", 2);
Then this variable will also work for your filterscript.
In your FS:
pawn Код:
if(GetPVarInt(playerid, "Test") == 2)
You've got different player variable types:
GetPVar:
Int
Float
String

SetPVar:
Int
Float
String

DeletePVar
Reply
#5

Off-Topic: Admigo, it's funny how you ask for help regarding everything in your script, makes your script really unique. Once you're done people can look through all your thread's and start putting AC&R together.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)