"/getall" problem! - 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: "/getall" problem! (
/showthread.php?tid=330261)
"/getall" problem! -
Twisted_Insane - 31.03.2012
Hi!
I've scripted the following command:
pawn Код:
CMD:getall(playerid,params[])
{
if(PlayerInfo[playerid][pAdmin] >= 7)
{
new Float:x,Float:y,Float:z, interior = GetPlayerInterior(playerid);
GetPlayerPos(playerid,x,y,z);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && (i != playerid))
{
if(i == 0) return SendClientMessage(playerid, COLOR_RED, "No players online!");
PlayerPlaySound(i,1057,0.0,0.0,0.0);
SetPlayerPos(i,x+(playerid/4)+1,y+(playerid/4),z);
SetPlayerInterior(i,interior);
}
}
new string[128];
format(string,sizeof(string),"|| Administrator %s has teleported all players! ||", Name(playerid));
SendClientMessageToAll(COLOR_LIGHTBLUE, string);
}
else return SendClientMessage(playerid,COLOR_RED,"You need to be level 7 to use that command!");
return 1;
}
When no players except me are online, it should return a message with "No players online!". But it doesn't, instead of it, it shows the message that I've teleported all players!
Re: "/getall" problem! -
Seven_of_Nine - 31.03.2012
You should create a var,
and in the loop
Код:
if(IsPlayerConnected(i))
pCount++;
and after the loop
Код:
if(pCount == 0) SendClientMessage(playerid,color,"No players online!");
Re: "/getall" problem! -
Twisted_Insane - 31.03.2012
What's the difference if I'm creating the variable "i" and count it with '++' or if I'm creating the variable "pCount" and count it with '++'? I just did the same in my first post, just with another name!
Re: "/getall" problem! -
Seven_of_Nine - 31.03.2012
Код:
CMD:getall(playerid,params[])
{
if(PlayerInfo[playerid][pAdmin] >= 7)
{
new Float:x,Float:y,Float:z, interior = GetPlayerInterior(playerid);
GetPlayerPos(playerid,x,y,z);
new pCount;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i) || i == playerid) continue;
pCount++;
PlayerPlaySound(i,1057,0.0,0.0,0.0);
SetPlayerPos(i,x+(playerid/4)+1,y+(playerid/4),z);
SetPlayerInterior(i,interior);
}
if(pCount == 0) return SendClientMessage(playerid,COLOR_RED,"No players online!");
new string[128];
format(string,sizeof(string),"|| Administrator %s has teleported all players! ||", Name(playerid));
SendClientMessageToAll(COLOR_LIGHTBLUE, string);
}
else return SendClientMessage(playerid,COLOR_RED,"You need to be level 7 to use that command!");
return 1;
}
there, thats your code.
Re: "/getall" problem! -
Twisted_Insane - 31.03.2012
What the hell is this line?
pawn Код:
if(!IsPlayerConnected(i) || i == playerid) continue;
If the player isn't connected and 'i' is myself it should continue?
Re: "/getall" problem! -
Seven_of_Nine - 31.03.2012
Yeah, if the player isn't connected, or is you, then it skips to the next player and doesn't add to pCount.
Re: "/getall" problem! -
Twisted_Insane - 31.03.2012
Thanks, it worked!