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;
}
if(ID != playerid) //this checks if the ID from the loop isnt you, if it was you it will avoid it.
{
return 0;
}
cmd(tk, playerid, params[])
{
foreach(new ID : Player)
{
if(ID != playerid) //this checks if the ID from the loop isnt you, if it was you it will avoid it.
{
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;
}
cmd(tk, playerid, params[])
{
new lookupid;
sscanf(params, "?<CELLMIN_ON_MATCHES=1>U(-1)", lookupid);
if(lookupid == -1)
{
// No player was entered.
}
else if(lookupid == cellmin)
{
// Multiple matches found.
}
else if(lookupid == INVALID_PLAYER_ID)
{
// Entered player is not connected.
}
else
{
// Found just one player.
}
return 1;
}
cmd(tk, playerid, params[])
{
new lookupid;
sscanf(params, "?<CELLMIN_ON_MATCHES=1>U(-1)", lookupid);
if(lookupid == -1) return SendClientMessage(playerid, -1, "Usage: /tk (id/name).");
else if(lookupid == cellmin) return SendClientMessage(playerid, -1, "Multiple matches found for the specific phrase.");
else if(lookupid == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "That player isn't connected to the server right now.");
else
{
new string[144], pwl = GetPlayerWantedLevel(lookupid);
if(!IsCop(playerid)) return SendClientMessage(playerid, COLOR_RED, "Only Cops/Army can use this command.");
if(GetDistanceBetweenPlayers(playerid, lookupid) > 4) return SendClientMessage(playerid, COLOR_RED, "That player is too far away to Ticket.");
else if(pwl == 1)
{
format(string, sizeof(string), "[COP ACTION] You have been fined by officer %s. You have been charged $1,000", PlayerInfo(playerid));
SendClientMessage(lookupid, COLOR_DODGERBLUE, string);
format(string, sizeof(string), "[COP ACTION] You have fined %s. You have recieved a collection prize.", PlayerInfo(lookupid));
SendClientMessage(playerid, COLOR_DODGERBLUE, string);
format(string, sizeof(string), "[DISPATCH] Officer %s has fined %s. He is no longer wanted.", PlayerInfo(playerid), PlayerInfo(lookupid));
SendCopMessage(string);
SetPlayerWantedLevel(lookupid, 0);
IncreaseScore(playerid, 1);
GivePlayerMoney(playerid, 2500);
GivePlayerMoney(lookupid, -1000);
}
else if(pwl == 2)
{
format(string, sizeof(string), "[COP ACTION] You have been fined by officer %s. You have been charged $2,000", PlayerInfo(playerid));
SendClientMessage(lookupid, COLOR_DODGERBLUE, string);
format(string, sizeof(string), "[COP ACTION] You have fined %s. You have recieved a collection prize.", PlayerInfo(lookupid));
SendClientMessage(playerid, COLOR_DODGERBLUE, string);
format(string, sizeof(string), "[DISPATCH] Officer %s has fined %s. He is no longer wanted.", PlayerInfo(playerid), PlayerInfo(lookupid));
SendCopMessage(string);
SetPlayerWantedLevel(lookupid, 0);
IncreaseScore(playerid, 1);
GivePlayerMoney(playerid, 2500);
GivePlayerMoney(lookupid, -2000);
}
else if(pwl == 3)
{
format(string, sizeof(string), "[COP ACTION] You have been fined by officer %s. You have been charged $3,000", PlayerInfo(playerid));
SendClientMessage(lookupid, COLOR_DODGERBLUE, string);
format(string, sizeof(string), "[COP ACTION] You have fined %s. You have recieved a collection prize.", PlayerInfo(lookupid));
SendClientMessage(playerid, COLOR_DODGERBLUE, string);
format(string, sizeof(string), "[DISPATCH] Officer %s has fined %s. He is no longer wanted.", PlayerInfo(playerid), PlayerInfo(lookupid));
SendCopMessage(string);
SetPlayerWantedLevel(lookupid, 0);
IncreaseScore(playerid, 1);
GivePlayerMoney(playerid, 2500);
GivePlayerMoney(lookupid, -3000);
}
else
{
if(pwl == 0) return SendClientMessage(playerid, COLOR_YELLOW, "["COL_GREY"Error"COL_YELLOW"]"COL_GREY":"COL_LRED"player is innocent!");
else 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!");
else 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!");
else 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;
}
Why are you using foreach to code commands?
Use this format below to do so (You'll need sscanf): pawn Код:
pawn Код:
|
You used v in a wrong way.
pawn Код:
pawn Код:
|