23.07.2014, 12:59
hey it seems like everytime i try give the closes player to me a ticket it give it my self with i am id 0 heres my code
PHP код:
cmd(tk, playerid, params[])
{
foreach(new ID : Player)
{
if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, -1, "Not conected");
if(ID != playerid) //this checks if the ID from the loop isnt you, if it was you it will avoid it.
{
return 0;
}
if(!IsCop(playerid))
return SendClientMessage(playerid, COLOR_RED, "Only Cops/Army can use this command.");
new string[120];
if(GetDistanceBetweenPlayers(playerid, ID) > 4)
{
return SendClientMessage(playerid, COLOR_RED, "That player is too far away to Ticket.");
}
new pwl = GetPlayerWantedLevel(ID);
if(pwl == 1)
{
format(string, 120, "[COP ACTION] You have been fined by officer %s. You have been charged $1,000", PlayerInfo(playerid));
SendClientMessage(ID, COLOR_DODGERBLUE, string);
format(string, 120, "[COP ACTION] You have fined %s. You have recieved a collection prize.", PlayerInfo(ID));
SendClientMessage(playerid, COLOR_DODGERBLUE, string);
format(string, 120, "[DISPATCH] Officer %s has fined %s. He is no longer wanted.", PlayerInfo(playerid), PlayerInfo(ID));
SendCopMessage(string);
SetPlayerWantedLevel(ID, 0);
IncreaseScore(playerid, 1);
GivePlayerMoney(playerid, 2500);
GivePlayerMoney(ID, -1000);
}
if(pwl == 2)
{
format(string, 120, "[COP ACTION] You have been fined by officer %s. You have been charged $2,000", PlayerInfo(playerid));
SendClientMessage(ID, COLOR_DODGERBLUE, string);
format(string, 120, "[COP ACTION] You have fined %s. You have recieved a collection prize.", PlayerInfo(ID));
SendClientMessage(playerid, COLOR_DODGERBLUE, string);
format(string, 120, "[DISPATCH] Officer %s has fined %s. He is no longer wanted.", PlayerInfo(playerid), PlayerInfo(ID));
SendCopMessage(string);
SetPlayerWantedLevel(ID, 0);
IncreaseScore(playerid, 1);
GivePlayerMoney(playerid, 2500);
GivePlayerMoney(ID, -2000);
}
if(pwl == 3)
{
format(string, 120, "[COP ACTION] You have been fined by officer %s. You have been charged $3,000", PlayerInfo(playerid));
SendClientMessage(ID, COLOR_DODGERBLUE, string);
format(string, 120, "[COP ACTION] You have fined %s. You have recieved a collection prize.", PlayerInfo(ID));
SendClientMessage(playerid, COLOR_DODGERBLUE, string);
format(string, 120, "[DISPATCH] Officer %s has fined %s. He is no longer wanted.", PlayerInfo(playerid), PlayerInfo(ID));
SendCopMessage(string);
SetPlayerWantedLevel(ID, 0);
IncreaseScore(playerid, 1);
GivePlayerMoney(playerid, 2500);
GivePlayerMoney(ID, -3000);
}
else
{
if(pwl == 0)
{
return SendClientMessage(playerid, COLOR_YELLOW, "["COL_GREY"Error"COL_YELLOW"]"COL_GREY":"COL_LRED"player is innocent!");
}
if(pwl == 4)
{
return SendClientMessage(playerid, COLOR_YELLOW, "["COL_GREY"Error"COL_YELLOW"]"COL_GREY":"COL_LRED"You only can give ticket to wanted players of 1 to 3!");
}
if(pwl == 5)
{
return SendClientMessage(playerid, COLOR_YELLOW, "["COL_GREY"Error"COL_YELLOW"]"COL_GREY":"COL_LRED"You only can give ticket to wanted players of 1 to 3!");
}
if(pwl == 6)
{
return SendClientMessage(playerid, COLOR_YELLOW, "["COL_GREY"Error"COL_YELLOW"]"COL_GREY":"COL_LRED"You only can give ticket to wanted players of 1 to 3!");
}
}
}
return 1;
}