27.09.2016, 16:27
pawn Код:
CMD:pticket(playerid, params[])
{
if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
new plate[12],amount, reason[64], id;
if(Faction[playerid] != 1) return SendClientMessage(playerid, COLOUR_GREY, "You are not a member of the police.");
if(sscanf(params, "s[12]ds[64]",plate, amount,reason)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /pticket [license plate] [amount] [reason]");
for(new x = 1; x < GetVehiclePoolSize()+1; x++)
{
if(!isnull(VehPlate[x]) && !strcmp(plate, VehPlate[x], true))
{
id = x;
printf("%d vehid", id);
printf("%d model",VehModel[id]);
break;
}
}
if(amount < 1 || amount > 1000)return SendClientMessage(playerid, COLOUR_GREY, "Amount must be between $1 and $1,000.");
if(VehicleSQLID[id] < 1)return SendClientMessage(playerid, COLOUR_GREY, "You cannot place a ticket on this vehicle. (Admin Spawned/Static).");
if(VehicleFaction[id] == 1)return SendClientMessage(playerid, COLOUR_GREY, "This is a government vehicle, you cannot give it a parking ticket.");
new query[256];
printf("%d vehid", id);
printf("%d model",VehModel[id]);
format(query, sizeof(query), "INSERT INTO `ptickets` (VehID, Amount, PlacedBy, Date, Reason) VALUES (%d, %d, %d, %d, '%s')", VehicleSQLID[id], amount, PlayerSQLID[playerid], gettime(), reason);
mysql_tquery(dbHandle, query, "PTicket", "iiis", playerid, id, amount, reason);
return 1;
}
MAX_TICKETS = 500.
pawn Код:
forward PTicket(playerid, id, amount, reason[]);
public PTicket(playerid, id, amount, reason[])
{
printf("%d model",VehModel[id]);
new string[128];
new tid = cache_insert_id();
printf("%d - ticket id", cache_insert_id());
if(tid > MAX_TICKETS)return SendClientMessage(playerid, COLOUR_GREY, "Ticket not created; maximum ticket reached, contact admin.");
PTID[tid] = tid;
PTVehSQLID[tid] = VehicleSQLID[id];
PTByID[tid] = PlayerSQLID[playerid];
PTDate[tid] = gettime();
strcpy(PTReason[tid], reason, 24);
PTAmount[tid] = amount;
printf("%d ID", id);
printf("COLOR %d", VehColour1[id]);
new name = VehModel[id] - 400;
SendClientMessage(playerid, COLOUR_BLUE, "__________Parking Ticket Information__________");
format(string, sizeof(string), "Vehicle: "COL_GREY"%s "COL_WHITE"| License Plate: "COL_GREY"%s", VehicleNames[VehModel[id]-400], VehPlate[id]);
SendClientMessage(playerid, COLOUR_WHITE, string);
format(string, sizeof(string), "Amount: "COL_RED"$%s "COL_WHITE"| Reason: "COL_GREY"%s", AddCommas(amount), reason);
SendClientMessage(playerid, COLOUR_WHITE, string);
format(string, sizeof(string), "You have placed a parking ticket on the %s for the amount of $%s. The owner will be notified.", VehicleNames[name], AddCommas(amount));
SendClientMessage(playerid, COLOUR_ORANGE, string);
format(string, sizeof(string), "* %s places a parking ticket on the %s *", GetNameEx(playerid), VehicleNames[name]);
ProxDetector(30.0, playerid, string, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE, COLOUR_PURPLE);
return 1;
}