Commands don't work properly
#1

Hey guys. My problem is that commands /admins and /freezeall /unfreezeall don't work properly!
Command /admins works how it should do only when i am alone on server, when someone else join it shows that all players in server are highest levels, owner.. Here is the code:
Quote:

CMD:admins(playerid,params[])
{
SendClientMessage(playerid, ORANGE, " ");
SendClientMessage(playerid, ORANGE, "----' Online Admins '----");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[playerid][Level] >= 1 || PlayerInfo[playerid][Level] <= 7)
{
new admtext[64], id[MAX_PLAYER_NAME], string[256];
if(PlayerInfo[playerid][Level] == 1) {admtext = "Level: 1 (Trial Administrator)";}
else if(PlayerInfo[playerid][Level] == 2) {admtext = "Level: 2, (Administrator)";}
else if(PlayerInfo[playerid][Level] == 3) {admtext = "Level: 3, (Master Administrator)";}
else if(PlayerInfo[playerid][Level] == 4) {admtext = "Level: 4, (Moderator)";}
else if(PlayerInfo[playerid][Level] == 5) {admtext = "Level: 5, (Master Moderator)";}
else if(PlayerInfo[playerid][Level] == 6) {admtext = "Level: 6, (Lead Moderator)";}
else if(PlayerInfo[playerid][Level] == 7) {admtext = "Level: 7, (Owner)";}
else if(IsPlayerAdmin(i)) {admtext = "RCON Administrator";}
else {admtext = "No admins online";}
GetPlayerName(i, id, sizeof(id));
format(string, 256, "%s ( %s )", id, admtext);
SendClientMessage(playerid, GREEN, string);
}
}
}
return 1;
}




Commands /freezeall and /unfreezeall problem is /freezeall freeze just player who used it and /unfreezeall don't work at all.. Here are the codes:
Quote:

CMD:freezeall(playerid,params[]) {
#pragma unused params
if(PlayerInfo[playerid][Level] >= 5) {
CMDMessageToAdmins(playerid,"FREEZEALL");
for(new i = 0; i < MAX_PLAYERS; i++) {
if(IsPlayerConnected(i) && (i != playerid) && i != ServerInfo[MaxAdminLevel]) {
PlayerPlaySound(i,1057,0.0,0.0,0.0); TogglePlayerControllable(playerid,false); PlayerInfo[i][Frozen] = 1;
}
}
new string[128]; format(string,sizeof(string),"Administrator \"%s\" has frozen all players", pName(playerid) );
return SendClientMessageToAll(blue, string);
} else return SendClientMessage(playerid,red,"ERROR: You need to be level 5 to use this command");
}



CMD:unfreezeall(playerid,params[]) {
#pragma unused params
if(PlayerInfo[playerid][Level] >= 5) {
CMDMessageToAdmins(playerid,"UNFREEZEALL");
for(new i = 0; i < MAX_PLAYERS; i++) {
if(IsPlayerConnected(i) && (i != playerid) && i != ServerInfo[MaxAdminLevel]) {
PlayerPlaySound(i,1057,0.0,0.0,0.0); TogglePlayerControllable(playerid,true); PlayerInfo[i][Frozen] = 0;
}
}
new string[128]; format(string,sizeof(string),"Administrator \"%s\" has unfrozen all players", pName(playerid) );
return SendClientMessageToAll(blue, string);
} else return SendClientMessage(playerid,red,"ERROR: You need to be level 5 to use this command");
}

Reply
#2

You're not returning 1 in (un)freezeall

In admins:
string = "whatever" isn't the right way to format it. Use format.
Also, why are you using a string with 256 while SendClientMessage limit is 128. Waste of cells.
Reply
#3

PHP код:
CMD:freezeall(playerid,params[]) {
#pragma unused params
if(PlayerInfo[playerid][Level] >= 5) {
CMDMessageToAdmins(playerid,"FREEZEALL");
for(new 
0MAX_PLAYERSi++) {
if(
IsPlayerConnected(i) && (!= playerid) && != ServerInfo[MaxAdminLevel]) {
PlayerPlaySound(i,1057,0.0,0.0,0.0); TogglePlayerControllable(i,false); PlayerInfo[i][Frozen] = 1;
}
}
new 
string[128]; format(string,sizeof(string),"Administrator \"%s\" has frozen all players"pName(playerid) );
return 
SendClientMessageToAll(bluestring);
} else return 
SendClientMessage(playerid,red,"ERROR: You need to be level 5 to use this command");

You made a simple misstake;

Your code:
PHP код:
TogglePlayerControllable(playerid,false); 
What it should be:

PHP код:
TogglePlayerControllable(i,false); 
Reply
#4

Quote:
Originally Posted by Stinged
Посмотреть сообщение
You're not returning 1 in (un)freezeall

In admins:
string = "whatever" isn't the right way to format it. Use format.
Also, why are you using a string with 256 while SendClientMessage limit is 128. Waste of cells.
I don't really understand.. Can someone give me full code for command admins?

Btw thanks for command freeze
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)