ZCMD command returns some of the string and "Unknown command message".
#1

I am aiming to do a /stats, but when someone uses the command it sends them the first string, but then the Unknown command message underneath it without displaying the the other strings.

Code:
CMD:stats(playerid, params[])
{
 	new Float:HP, Float:ARM;
	GetPlayerHealth(playerid, HP);
	GetPlayerArmour(playerid, ARM);
 	if(p_data[playerid][AdminLevel] == 0)
        {
		new str[128], str1[128];
		format(str, sizeof(str), "Name: %s | Money: %d | Bank Money: %d | Job: %s | VIP Level: %d | Hours: %d |",getName(playerid),p_info[playerid][Money],p_data[playerid][Bank],p_info[playerid][Jobs],p_data[playerid][VIP],p_data[playerid][Hours]);
		SendClientMessage(playerid, -1, str);
		format(str1, sizeof(str1), "Deaths: %d | Kills: %d | Kill Death Ratio: %d | Group: %d | Rank: %d | ",p_data[playerid][deaths],p_data[playerid][kills],p_data[playerid][kills]/p_data[playerid][deaths],p_data[playerid][Group],p_data[playerid][Rank]);
		SendClientMessage(playerid, -1, str1);
	}
 	if(p_data[playerid][AdminLevel] >= 1)
	{
		new str[128], str1[128], str2[128];
		format(str, sizeof(str), "Name: %s | Money: %d | Bank Money: %d | Job: %s | VIP Level: %d | Armour: %.0f | Hours: %d |",getName(playerid),p_info[playerid][Money],p_data[playerid][Bank],p_info[playerid][Jobs],p_data[playerid][VIP], ARM, p_data[playerid][Hours]);
		SendClientMessage(playerid, -1, str);
		format(str1, sizeof(str1), "Admin Level: %d | Admin Actions: %d | Interior Id: %d | Virtual World: %d | Health: %.0f |",p_data[playerid][AdminLevel],p_data[playerid][actions],GetPlayerInterior(playerid),GetPlayerVirtualWorld(playerid),HP);
		SendClientMessage(playerid, -1, str1);
		format(str2, sizeof(str2), "Deaths: %d | Kills: %d | Kill Death Ratio: %d | Group: %d | Rank: %d | Skin: %d |",p_data[playerid][deaths],p_data[playerid][kills],p_data[playerid][kills]/p_data[playerid][deaths],p_data[playerid][Group],p_data[playerid][Rank],GetPlayerSkin(playerid));
		SendClientMessage(playerid, -1, str2);
	}
	return 1;
}
Also, I have placed 'return 1;' at the end of both if they're an admin or if they aren't.

Any help is greatly appreciated.
Reply
#2

Yeah same happens to me
Reply
#3

Try adding
pawn Code:
return 1;
under your different sections.
Reply
#4

Quote:
Originally Posted by MikeLovesToHelp
View Post
Try adding
pawn Code:
return 1;
under your different sections.
Already tried that pal and it displays the same message and section of string.
Reply
#5

pawn Code:
CMD:stats(playerid, params[])
{
    new Float:HP, Float:ARM;
    GetPlayerHealth(playerid, HP);
    GetPlayerArmour(playerid, ARM);
    if(p_data[playerid][AdminLevel] == 0)
        {
        new str[128], str1[128];
        format(str, sizeof(str), "Name: %s | Money: %d | Bank Money: %d | Job: %s | VIP Level: %d | Hours: %d |",getName(playerid),p_info[playerid][Money],p_data[playerid][Bank],p_info[playerid][Jobs],p_data[playerid][VIP],p_data[playerid][Hours]);
        SendClientMessage(playerid, -1, str);
        format(str1, sizeof(str1), "Deaths: %d | Kills: %d | Kill Death Ratio: %f | Group: %d | Rank: %d | ",p_data[playerid][deaths],p_data[playerid][kills],float(p_data[playerid][kills])/float(p_data[playerid][deaths]),p_data[playerid][Group],p_data[playerid][Rank]);
        SendClientMessage(playerid, -1, str1);
    }
    else if(p_data[playerid][AdminLevel] >= 1)
    {
        new str[128], str1[128], str2[128];
        format(str, sizeof(str), "Name: %s | Money: %d | Bank Money: %d | Job: %s | VIP Level: %d | Armour: %.0f | Hours: %d |",getName(playerid),p_info[playerid][Money],p_data[playerid][Bank],p_info[playerid][Jobs],p_data[playerid][VIP], ARM, p_data[playerid][Hours]);
        SendClientMessage(playerid, -1, str);
        format(str1, sizeof(str1), "Admin Level: %d | Admin Actions: %d | Interior Id: %d | Virtual World: %d | Health: %.0f |",p_data[playerid][AdminLevel],p_data[playerid][actions],GetPlayerInterior(playerid),GetPlayerVirtualWorld(playerid),HP);
        SendClientMessage(playerid, -1, str1);
        format(str2, sizeof(str2), "Deaths: %d | Kills: %d | Kill Death Ratio: %f | Group: %d | Rank: %d | Skin: %d |",p_data[playerid][deaths],p_data[playerid][kills],float(p_data[playerid][kills])/float(p_data[playerid][deaths]foat),p_data[playerid][Group],p_data[playerid][Rank],GetPlayerSkin(playerid));
        SendClientMessage(playerid, -1, str2);
    }
    return 1;
}
Why do you define armor and life values?
Reply
#6

Add return true; to both if statements.
Reply
#7

Why don't you just use else?
Reply
#8

Quote:
Originally Posted by HurtLocker
View Post
pawn Code:
CMD:stats(playerid, params[])
{
    new Float:HP, Float:ARM;
    GetPlayerHealth(playerid, HP);
    GetPlayerArmour(playerid, ARM);
    if(p_data[playerid][AdminLevel] == 0)
        {
        new str[128], str1[128];
        format(str, sizeof(str), "Name: %s | Money: %d | Bank Money: %d | Job: %s | VIP Level: %d | Hours: %d |",getName(playerid),p_info[playerid][Money],p_data[playerid][Bank],p_info[playerid][Jobs],p_data[playerid][VIP],p_data[playerid][Hours]);
        SendClientMessage(playerid, -1, str);
        format(str1, sizeof(str1), "Deaths: %d | Kills: %d | Kill Death Ratio: %f | Group: %d | Rank: %d | ",p_data[playerid][deaths],p_data[playerid][kills],float(p_data[playerid][kills])/float(p_data[playerid][deaths]),p_data[playerid][Group],p_data[playerid][Rank]);
        SendClientMessage(playerid, -1, str1);
    }
    else if(p_data[playerid][AdminLevel] >= 1)
    {
        new str[128], str1[128], str2[128];
        format(str, sizeof(str), "Name: %s | Money: %d | Bank Money: %d | Job: %s | VIP Level: %d | Armour: %.0f | Hours: %d |",getName(playerid),p_info[playerid][Money],p_data[playerid][Bank],p_info[playerid][Jobs],p_data[playerid][VIP], ARM, p_data[playerid][Hours]);
        SendClientMessage(playerid, -1, str);
        format(str1, sizeof(str1), "Admin Level: %d | Admin Actions: %d | Interior Id: %d | Virtual World: %d | Health: %.0f |",p_data[playerid][AdminLevel],p_data[playerid][actions],GetPlayerInterior(playerid),GetPlayerVirtualWorld(playerid),HP);
        SendClientMessage(playerid, -1, str1);
        format(str2, sizeof(str2), "Deaths: %d | Kills: %d | Kill Death Ratio: %f | Group: %d | Rank: %d | Skin: %d |",p_data[playerid][deaths],p_data[playerid][kills],float(p_data[playerid][kills])/float(p_data[playerid][deaths]foat),p_data[playerid][Group],p_data[playerid][Rank],GetPlayerSkin(playerid));
        SendClientMessage(playerid, -1, str2);
    }
    return 1;
}
Why do you define armor and life values?
It is the only way it works for me mate.
Reply
#9

Quote:
Originally Posted by Ultra-Gaming
View Post
Add return true; to both if statements.
Quote:
Originally Posted by LarzI
View Post
Why don't you just use else?
Nope, both give the same results.
Reply
#10

Quote:
Originally Posted by total3clipse
View Post
Nope, both give the same results.
Yeah I never said that'd fix anything, it was just a question.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)