/viplist - is there any thing wrong? -
RyderX - 06.02.2017
PHP код:
CMD:viplist(playerid, params[])
{
new count = 0, string[128];
for(new i = 0; i < MAX_PLAYERS; i ++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pVIP] >= 1)
{
format(string, sizeof(string),"- {ffff00}%s{00ff00}| {0066ff}(ID:%s) {00ff00}| {996600}Bronze V.I.P\n", GetName(i), i);
count++;
}
if(PlayerInfo[i][pVIP] >= 2)
{
format(string, sizeof(string),"- {ffff00}%s {00ff00}| {0066ff}(ID:%d) {00ff00}| {adad85}Silver V.I.P\n", GetName(i), i);
count++;
}
if(PlayerInfo[i][pVIP] >= 3)
{
format(string, sizeof(string),"- {ffff00}%s {00ff00}| {0066ff}(ID:%d) {00ff00}| {e68a00}GOLD V.I.P\n", GetName(i), i);
count++;
}
}
}
if(count == 0)
{
ShowPlayerDialog(playerid, 18, DIALOG_STYLE_MSGBOX,"{00ff00}Online V.I.P(s):",string, "Ok", "");
}
else
{
ShowPlayerDialog(playerid, 18, DIALOG_STYLE_MSGBOX,"{00ff00}Online V.I.P(s):","There isn't any online V.I.P", "Ok", "");
}
return 1;
}
is there any error anything something not normal with this code? if so hope you correct it for me
Re: /viplist - is there any thing wrong? -
AndreiWow - 06.02.2017
Why didn't you compile it? The compiler would have told you.. anyway, I don't see anything wrong.
Re: /viplist - is there any thing wrong? -
RyderX - 06.02.2017
Yes, that's the point i have compiled it, no errors no warnings allthings is clean...
but when i types it it show
There isn't any online vip... while there are..
Re: /viplist - is there any thing wrong? -
SyS - 06.02.2017
Yes there is:
- Consider my vip level is 4 then
Код:
if(PlayerInfo[i][pVIP] >= 1)
{
format(string, sizeof(string),"- {ffff00}%s{00ff00}| {0066ff}(ID:%s) {00ff00}| {996600}Bronze V.I.P\n", GetName(i), i);
count++;
}
if(PlayerInfo[i][pVIP] >= 2)
{
format(string, sizeof(string),"- {ffff00}%s {00ff00}| {0066ff}(ID:%d) {00ff00}| {adad85}Silver V.I.P\n", GetName(i), i);
count++;
}
if(PlayerInfo[i][pVIP] >= 3)
{
format(string, sizeof(string),"- {ffff00}%s {00ff00}| {0066ff}(ID:%d) {00ff00}| {e68a00}GOLD V.I.P\n", GetName(i), i);
count++;
}
The all that if condition is true for me you can use else ifs in this case or use switch to check values of variable PlayerInfo[i][pVIP] rather putting ranges (cause that better in this case i believe).
- Next thing is use of general looping mechanism use foreach with Player iterator instead.
Код:
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pVIP] >= 1)
{
format(string, sizeof(string),"- {ffff00}%s{00ff00}| {0066ff}(ID:%s) {00ff00}| {996600}Bronze V.I.P\n", GetName(i), i);
count++;
}
if(PlayerInfo[i][pVIP] >= 2)
{
format(string, sizeof(string),"- {ffff00}%s {00ff00}| {0066ff}(ID:%d) {00ff00}| {adad85}Silver V.I.P\n", GetName(i), i);
count++;
}
if(PlayerInfo[i][pVIP] >= 3)
{
format(string, sizeof(string),"- {ffff00}%s {00ff00}| {0066ff}(ID:%d) {00ff00}| {e68a00}GOLD V.I.P\n", GetName(i), i);
count++;
}
That will reset the string variable use strcat to concatenate strings
Код:
if(count == 0)
{
ShowPlayerDialog(playerid, 18, DIALOG_STYLE_MSGBOX,"{00ff00}Online V.I.P(s):",string, "Ok", "");
}
else
{
ShowPlayerDialog(playerid, 18, DIALOG_STYLE_MSGBOX,"{00ff00}Online V.I.P(s):","There isn't any online V.I.P", "Ok", "");
}
You mismatched conditions.
Re: /viplist - is there any thing wrong? - iLearner - 06.02.2017
PHP код:
if(count == 0)
{
ShowPlayerDialog(playerid, 18, DIALOG_STYLE_MSGBOX,"{00ff00}Online V.I.P(s):",string, "Ok", "");
}
else
{
ShowPlayerDialog(playerid, 18, DIALOG_STYLE_MSGBOX,"{00ff00}Online V.I.P(s):","There isn't any online V.I.P", "Ok", "");
}
Re: /viplist - is there any thing wrong? -
Logic_ - 06.02.2017
PHP код:
#if defined Loop
#undef Loop(%1)
#endif
#define Loop(%1) for(new %1 = GetPlayerPoolSize(); %1 != -1; %1 --) if(IsPlayerConnected(%1))
CMD:viplist(playerid)
{
new count;
Loop(i)
{
if(PlayerInfo[i][pVIP])
{
format(string, sizeof string, "- {ffff00}%s{00ff00}| {0066ff}(ID:%s) {00ff00}| %x %s\n", GetName(i), i, GetVipColor(i), GetVipLevel(i));
strcat(string, string, sizeof string);
count += 1;
}
}
if(!count) return ShowPlayerDialog(playerid, 18, DIALOG_STYLE_MSGBOX, "{00ff00}Online VIPs:","There isn't any online V.I.P", "Ok", "");
else return ShowPlayerDialog(playerid, 18, DIALOG_STYLE_MSGBOX, "{00ff00}Online VIPs:",string, "Okay", "");
}
GetVipLevel(playerid)
{
new str[10];
switch(PlayerInfo[playerid][pVIP])
{
case 0: str = "None";
case 1: str = "Bronze";
case 2: str = "Silver";
case 3: str = "Gold";
}
return str;
}
GetVipColor(playerid)
{
new str[10];
switch(PlayerInfo[playerid][pVIP])
{
case 1: str = "{996600}";
case 2: str = "{adad85}";
case 3: str = "{e68a00}";
}
return str;
}
Re: /viplist - is there any thing wrong? -
RyderX - 06.02.2017
Fixed.
Thanks for you support