PDA

View Full Version : why it shows only 1 admin ;(


KillerStrike23
17/04/2014, 10:52 PM
CMD:ksadmins(playerid,params[]){
#pragma unused params
new Count = 0;
new n[MAX_PLAYER_NAME];
new string[1000];
new AdmRank[40];
new ChangeColor;
SendClientMessage(playerid, green, " ");
SendClientMessage(playerid, blue, "___________ |- Online KS Members -| ___________");
SendClientMessage(playerid, green, " ");
for(new i = 0; i < MAX_PLAYERS; i++)
{
switch(PlayerInfo[i][KsLevel])
{
case 1:
{
AdmRank = "Newest Member";
ChangeColor = blue;
}
case 2:
{
AdmRank = "Junior Member";
ChangeColor = blue;
}
case 3:
{
AdmRank = "Executive Member";
ChangeColor = blue;
}
case 4:
{
AdmRank = "Senior Member";
ChangeColor = blue;
}
case 5:
{
AdmRank = "Head Member";
ChangeColor = blue;
}
case 6:
{
AdmRank = "Lieutenant";
ChangeColor = blue;
}
case 7:
{
AdmRank = "General";
ChangeColor = blue;
}
case 8:
{
AdmRank = "Leader";
ChangeColor = red;
}
}
if(!IsPlayerConnected(i)) continue;
if(PlayerInfo[i][KsLevel] < 1) continue;
GetPlayerName(i,n,sizeof(n));
format(string, 128, "Rank: %d - %s (Id:%i) | %s |", PlayerInfo[i][KsLevel], n, i, AdmRank);
Count++;}
if(Count == 0)
{
SendClientMessage(playerid, red, "no online KS members");
SendClientMessage(playerid, blue, " _______________________________________");
return 1;
}
SendClientMessage(playerid, ChangeColor, string);
SendClientMessage(playerid, blue, " _______________________________________");
return 1;}

PrivatioBoni
17/04/2014, 10:54 PM
Could you indent properly and put it in [pawn] tags? Would be much easier to read.

KillerStrike23
17/04/2014, 10:55 PM
okey now can you help me ?

awsomedude
17/04/2014, 11:05 PM
Try this:

CMD:ksadmins(playerid,params[])
{
new Count=0,Name[MAX_PLAYER_NAME],string[128],AdmRank,ChangeColor;
SendClientMessage(playerid, green, " ");
SendClientMessage(playerid, blue, "___________ |- Online KS Members -| ___________");
SendClientMessage(playerid, green, " ");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(PlayerInfo[i][KsLevel] > 0 && IsPlayerConnected(i))
{
switch(PlayerInfo[i][KsLevel])
{
case 1:
{
AdmRank = "Newest Member";
ChangeColor = blue;
}
case 2:
{
AdmRank = "Junior Member";
ChangeColor = blue;
}
case 3:
{
AdmRank = "Executive Member";
ChangeColor = blue;
}
case 4:
{
AdmRank = "Senior Member";
ChangeColor = blue;
}
case 5:
{
AdmRank = "Head Member";
ChangeColor = blue;
}
case 6:
{
AdmRank = "Lieutenant";
ChangeColor = blue;
}
case 7:
{
AdmRank = "General";
ChangeColor = blue;
}
case 8:
{
AdmRank = "Leader";
ChangeColor = red;
}
}
GetPlayerName(i,Name,sizeof(Name));
format(string, 128, "Rank: %d - %s (Id:%i) | %s |", PlayerInfo[i][KsLevel], Name, i, AdmRank);
SendClientMessage(playerid, ChangeColor, string);
Count++;
}
}
if(Count == 0)
{
SendClientMessage(playerid, red, "No online KS members");
return 1;
}
SendClientMessage(playerid, blue, " _______________________________________");
return 1;
}

gtakillerIV
17/04/2014, 11:08 PM
Because you're formatting the string over and over again instead of adding more lines to it. Use Strcat (wiki.sa-mp.com/wiki/Strcat) instead.

KillerStrike23
17/04/2014, 11:09 PM
can you show da code please ?

awsomedude
17/04/2014, 11:10 PM
Have you tested my code?

KillerStrike23
17/04/2014, 11:12 PM
sorry dude but I got those errors ;(
C:\Users\kamal\Desktop\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(16168) : warning 219: local variable "Name" shadows a variable at a preceding level
C:\Users\kamal\Desktop\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(16180) : error 006: must be assigned to an array
C:\Users\kamal\Desktop\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(16185) : error 006: must be assigned to an array
C:\Users\kamal\Desktop\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(16190) : error 006: must be assigned to an array
C:\Users\kamal\Desktop\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(16195) : error 006: must be assigned to an array
C:\Users\kamal\Desktop\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(16200) : error 006: must be assigned to an array
C:\Users\kamal\Desktop\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(16205) : error 006: must be assigned to an array
C:\Users\kamal\Desktop\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(16210) : error 006: must be assigned to an array
C:\Users\kamal\Desktop\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(16215) : error 006: must be assigned to an array
C:\Users\kamal\Desktop\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(16219) : error 035: argument type mismatch (argument 2)
C:\Users\kamal\Desktop\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(16219) : error 035: argument type mismatch (argument 2)
C:\Users\kamal\Desktop\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(16220) : warning 213: tag mismatch
C:\Users\kamal\Desktop\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(16168) : warning 204: symbol is assigned a value that is never used: "Name"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase

awsomedude
17/04/2014, 11:14 PM
Try now
CMD:ksadmins(playerid,params[])
{
new Count=0,n[MAX_PLAYER_NAME],string[128],AdmRank,ChangeColor;
SendClientMessage(playerid, green, " ");
SendClientMessage(playerid, blue, "___________ |- Online KS Members -| ___________");
SendClientMessage(playerid, green, " ");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(PlayerInfo[i][KsLevel] > 0 && IsPlayerConnected(i))
{
switch(PlayerInfo[i][KsLevel])
{
case 1:
{
AdmRank = "Newest Member";
ChangeColor = blue;
}
case 2:
{
AdmRank = "Junior Member";
ChangeColor = blue;
}
case 3:
{
AdmRank = "Executive Member";
ChangeColor = blue;
}
case 4:
{
AdmRank = "Senior Member";
ChangeColor = blue;
}
case 5:
{
AdmRank = "Head Member";
ChangeColor = blue;
}
case 6:
{
AdmRank = "Lieutenant";
ChangeColor = blue;
}
case 7:
{
AdmRank = "General";
ChangeColor = blue;
}
case 8:
{
AdmRank = "Leader";
ChangeColor = red;
}
}
GetPlayerName(i,n,sizeof(n));
format(string, 128, "Rank: %d - %s (Id:%i) | %s |", PlayerInfo[i][KsLevel], n, i, AdmRank);
SendClientMessage(playerid, ChangeColor, string);
Count++;
}
}
if(Count == 0)
{
SendClientMessage(playerid, red, "No online KS members");
}
SendClientMessage(playerid, blue, " _______________________________________");
return 1;
}

KillerStrike23
18/04/2014, 08:59 AM
;( :

C:\Users\kamal\Desktop\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(16179) : error 006: must be assigned to an array
C:\Users\kamal\Desktop\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(16184) : error 006: must be assigned to an array
C:\Users\kamal\Desktop\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(16189) : error 006: must be assigned to an array
C:\Users\kamal\Desktop\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(16194) : error 006: must be assigned to an array
C:\Users\kamal\Desktop\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(16199) : error 006: must be assigned to an array
C:\Users\kamal\Desktop\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(16204) : error 006: must be assigned to an array
C:\Users\kamal\Desktop\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(16209) : error 006: must be assigned to an array
C:\Users\kamal\Desktop\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(16214) : error 006: must be assigned to an array
C:\Users\kamal\Desktop\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(16224) : warning 217: loose indentation
C:\Users\kamal\Desktop\3x-Rc1-2 Server\Gamemodes\KSTDM.pwn(16228) : warning 217: loose indentation

taylorcro
18/04/2014, 09:09 AM
SendClientMessage(playerid, ChangeColor, string);

are the colours (blue, red etc) defined?

KillerStrike23
18/04/2014, 11:26 AM
yes bro its is the colors works fine but they just shows one admin
bump
bump again and again

Conradus
18/04/2014, 11:47 AM
I just made a small change in awesomedude's code, "AdmRank" is declared as an integer but is used as a string:

CMD:ksadmins(playerid,params[])
{
new Count=0,n[MAX_PLAYER_NAME],string[128],AdmRank[40],ChangeColor;
SendClientMessage(playerid, green, " ");
SendClientMessage(playerid, blue, "___________ |- Online KS Members -| ___________");
SendClientMessage(playerid, green, " ");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(PlayerInfo[i][KsLevel] > 0 && IsPlayerConnected(i))
{
switch(PlayerInfo[i][KsLevel])
{
case 1:
{
AdmRank = "Newest Member";
ChangeColor = blue;
}
case 2:
{
AdmRank = "Junior Member";
ChangeColor = blue;
}
case 3:
{
AdmRank = "Executive Member";
ChangeColor = blue;
}
case 4:
{
AdmRank = "Senior Member";
ChangeColor = blue;
}
case 5:
{
AdmRank = "Head Member";
ChangeColor = blue;
}
case 6:
{
AdmRank = "Lieutenant";
ChangeColor = blue;
}
case 7:
{
AdmRank = "General";
ChangeColor = blue;
}
case 8:
{
AdmRank = "Leader";
ChangeColor = red;
}
}
GetPlayerName(i,n,sizeof(n));
format(string, 128, "Rank: %d - %s (Id:%i) | %s |", PlayerInfo[i][KsLevel], n, i, AdmRank);
SendClientMessage(playerid, ChangeColor, string);
Count++;
}
}
if(Count == 0)
{
SendClientMessage(playerid, red, "No online KS members");
}
SendClientMessage(playerid, blue, " _______________________________________");
return 1;
}