change to zcmd - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: change to zcmd (
/showthread.php?tid=515644)
change to zcmd -
Shazwan - 27.05.2014
How to change all this to zcmd = CMD:
Код:
if(!strcmp(cmdtext, "/kickall", true, 8))
{
for(new i = 0; i < MAX_PLAYERS; i++))
{
if(!IsPlayerAdmin(i))
{
if(IsPlayerConnected(i))
{
SendClientMessageToAll(-1,"All Players Have Been Kicked From The Server By An Admin.");
Kick(i);
return 1;
} else return SendClientMessage(playerid,-1,"There Are No Players Connected.");
}
}
}
Re: change to zcmd -
JeaSon - 27.05.2014
here
pawn Код:
CMD:kickall(playerid, params[])
{
for(new i = 0; i < MAX_PLAYERS; i++))
{
if(!IsPlayerAdmin(i))
{
if(IsPlayerConnected(i))
{
SendClientMessageToAll(-1,"All Players Have Been Kicked From The Server By An Admin.");
Kick(i);
return 1;
} else return SendClientMessage(playerid,-1,"There Are No Players Connected.");
}
}
return 1;
}
Re: change to zcmd -
Adityz - 27.05.2014
You just need to change the first line to this - CMD:kickall(playerid, params[]) like this :
pawn Код:
CMD:kickall(playerid, params[])
{
for(new i = 0; i < MAX_PLAYERS; i++))
{
if(!IsPlayerAdmin(i))
{
if(IsPlayerConnected(i))
{
SendClientMessageToAll(-1,"All Players Have Been Kicked From The Server By An Admin.");
Kick(i);
}
else return SendClientMessage(playerid,-1,"There Are No Players Connected.");
}
}
return 1;
}
Edit - wow Namer's fast..
Re: change to zcmd -
Shazwan - 27.05.2014
they are two return? which is one?
Re: change to zcmd -
Threshold - 27.05.2014
Quote:
Originally Posted by Adityz
You just need to change te first line to this - CMD:kickall(playerid, params[])
pawn Код:
CMD:kickall(playerid, params[]) { for(new i = 0; i < MAX_PLAYERS; i++)) { if(!IsPlayerAdmin(i)) { if(IsPlayerConnected(i)) { SendClientMessageToAll(-1,"All Players Have Been Kicked From The Server By An Admin."); Kick(i); return 1; } else return SendClientMessage(playerid,-1,"There Are No Players Connected."); } } return 1; }
Edit - wow Namer's fast..
|
Actually, returning inside a loop would break it, so it would only kick ID 0, or the first player connected. And a SendClientMessageToAll inside a loop? They're being kicked, so they might not see it anyway, but that is just setting you up for spam.
pawn Код:
CMD:kickall(playerid, params[])
{
//if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Only RCON admins can use this command.");
SendClientMessageToAll(-1,"All Players Have Been Kicked From The Server By An Admin.");
for(new i = 0; i < MAX_PLAYERS; i++))
{
if(!IsPlayerConnected(i)) continue;
if(IsPlayerAdmin(i)) continue;
Kick(i);
}
return 1;
}
And no, copying someone else's code and pretending you were 'too late' does not count as 'helping'.
Re: change to zcmd -
Adityz - 27.05.2014
Quote:
Originally Posted by BenzoAMG
Actually, returning inside a loop would break it, so it would only kick ID 0, or the first player connected. And a SendClientMessageToAll inside a loop? They're being kicked, so they might not see it anyway, but that is just setting you up for spam.
pawn Код:
CMD:kickall(playerid, params[]) { //if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Only RCON admins can use this command."); SendClientMessageToAll(-1,"All Players Have Been Kicked From The Server By An Admin."); for(new i = 0; i < MAX_PLAYERS; i++)) { if(!IsPlayerConnected(i)) continue; if(IsPlayerAdmin(i)) continue; Kick(i); } return 1; }
And no, copying someone else's code and pretending you were 'too late' does not count as 'helping'.
|
Yeah, but his question was "how to change all this to zcmd?". I just gave him an example of where to add the following line - 'CMD:kickall(playerid, params[])'.
Honestly, I didn't even read his code assuming that it would be working properly as he was just asking 'how to convert it to zcmd'. Anyways, I know it's my mistake, i'll check out other people's code properly before posting a reply, the next time.