SA-MP Forums Archive
/stats Error - 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: /stats Error (/showthread.php?tid=506308)



/stats Error - WhiteAngels - 12.04.2014

Error:

Код:
G:\GTA SA-MP Installers\SA-MP Server\0.3z Server\Golden Ghost Gamers Freeroam\gamemodes\GGG.pwn(21822) : error 076: syntax error in the expression, or invalid function call
Line 21822-21823:

Код:
 		format(sstring, sizeof(sstring),"%s's Stats:\nAdmin Level : %d\nRank : %s\n\nVIP Level : %d\nKills: %d\nDeaths: %d\nRatio: %0.2f\nMoney: $%d\nBank: $%d\nTime Played: %d hrs %d mins %d secs",PlayerName2(player1),PlayerInfo[player1][Level],GetRankFromLevel,PlayerInfo[player1][VIP],PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths], Float:PlayerInfo[player1][Kills]/Float:pDeaths,GetPlayerMoney(player1),PlayerInfo[player1][bank], h, m, s);
        return ShowPlayerDialog(playerid, DIALOG_STATS, DIALOG_STYLE_LIST, "Stats", sstring, "Ok", "");
Fix This Please !!!


Re: /stats Error - ChandraLouis - 12.04.2014

show full code ?


Re: /stats Error - WhiteAngels - 12.04.2014

Quote:
Originally Posted by ChandraLouis
Посмотреть сообщение
show full code ?
Код:
CMD:stats(playerid,params[]) {
	new sstring[1024], pDeaths, player1, h, m, s;
	if(isnull(params)) player1 = playerid;
	else player1 = strval(params);

	if(IsPlayerConnected(player1)) {
	    TotalGameTime(player1, h, m, s);
 		if(PlayerInfo[player1][Deaths] == 0) pDeaths = 1; else pDeaths = PlayerInfo[player1][Deaths];
 		format(sstring, sizeof(sstring),"%s's Stats:\nAdmin Level : %d\nRank : %s\nVIP Level : %d\nKills: %d\nDeaths: %d\nRatio: %0.2f\nMoney: $%d\nBank: $%d\nTime Played: %d hrs %d mins %d secs",PlayerName2(player1),PlayerInfo[player1][Level],GetRankFromLevel,PlayerInfo[player1][VIP],PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths], Float:PlayerInfo[player1][Kills]/Float:pDeaths,GetPlayerMoney(player1),PlayerInfo[player1][bank], h, m, s);
        return ShowPlayerDialog(playerid, DIALOG_STATS, DIALOG_STYLE_LIST, "Stats", sstring, "Ok", "");
	} else return SendClientMessage(playerid, red, "Player Not Connected!");
}



Re: /stats Error - BroZeus - 12.04.2014

the problem is due to this in format line "Float:PlayerInfo[player1][Kills]/FloatDeaths"
you cant do a calulation like this in for mat do it before it like this
pawn Код:
new Float:kdratio;
kdratio=PlayerInfo[player1][Kills]/pDeaths;
//and then that format line and in place of "Float:PlayerInfo[player1][Kills]/Float:pDeaths" use kdratio



Re: /stats Error - ChandraLouis - 12.04.2014

pawn Код:
CMD:stats(playerid,params[])
{
    new sstring[1024], pDeaths, player1, h, m, s;
    if(isnull(params)) player1 = playerid;
    else player1 = strval(params);
    if(IsPlayerConnected(player1))
    {
        TotalGameTime(player1, h, m, s);
        if(PlayerInfo[player1][Deaths] == 0) pDeaths = 1; else pDeaths = PlayerInfo[player1][Deaths];
        format(sstring, sizeof(sstring),"%s's Stats:\nAdmin Level : %d\nRank : %s\nVIP Level : %d\nKills: %d\nDeaths: %d\nRatio: %0.2f\nMoney: $%d\nBank: $%d\nTime Played: %d hrs %d mins %d secs",PlayerName2(player1),PlayerInfo[player1][Level],GetRankFromLevel,PlayerInfo[player1][VIP],PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths], Float:PlayerInfo[player1][Kills]/Float:pDeaths,GetPlayerMoney(player1),PlayerInfo[player1][bank], h, m, s);
        ShowPlayerDialog(playerid, DIALOG_STATS, DIALOG_STYLE_LIST, "Stats", sstring, "Ok", "");
    }
    else return SendClientMessage(playerid, red, "Player Not Connected!");
}
Try it
Can you use [pawn] ?


Re: /stats Error - WhiteAngels - 12.04.2014

Quote:
Originally Posted by ChandraLouis
Посмотреть сообщение
pawn Код:
CMD:stats(playerid,params[])
{
    new sstring[1024], pDeaths, player1, h, m, s;
    if(isnull(params)) player1 = playerid;
    else player1 = strval(params);
    if(IsPlayerConnected(player1))
    {
        TotalGameTime(player1, h, m, s);
        if(PlayerInfo[player1][Deaths] == 0) pDeaths = 1; else pDeaths = PlayerInfo[player1][Deaths];
        format(sstring, sizeof(sstring),"%s's Stats:\nAdmin Level : %d\nRank : %s\nVIP Level : %d\nKills: %d\nDeaths: %d\nRatio: %0.2f\nMoney: $%d\nBank: $%d\nTime Played: %d hrs %d mins %d secs",PlayerName2(player1),PlayerInfo[player1][Level],GetRankFromLevel,PlayerInfo[player1][VIP],PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths], Float:PlayerInfo[player1][Kills]/Float:pDeaths,GetPlayerMoney(player1),PlayerInfo[player1][bank], h, m, s);
        ShowPlayerDialog(playerid, DIALOG_STATS, DIALOG_STYLE_LIST, "Stats", sstring, "Ok", "");
    }
    else return SendClientMessage(playerid, red, "Player Not Connected!");
}
Try it
Can you use [pawn] ?
Still Having Errors:

Quote:

G:\GTA SA-MP Installers\SA-MP Server\0.3z Server\Golden Ghost Gamers Freeroam\gamemodes\GGG.pwn(21822) : error 076: syntax error in the expression, or invalid function call




Re: /stats Error - WhiteAngels - 12.04.2014

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
the problem is due to this in format line "Float:PlayerInfo[player1][Kills]/FloatDeaths"
you cant do a calulation like this in for mat do it before it like this
pawn Код:
new Float:kdratio;
kdratio=PlayerInfo[player1][Kills]/pDeaths;
//and then that format line and in place of "Float:PlayerInfo[player1][Kills]/Float:pDeaths" use kdratio
same error like ChandraLouis