ERROR ?
#1

Hello today i have added the player stats to dialog..but i got errors..many i fix some of them but others didn't fix

the old stats:
Код:
CMD:stats(playerid,params[])
{
     new id, string[1028];
	 sscanf(params, "u", id);
	 if (isnull(params))
	 {
		format(string, sizeof(string), "_Statistics for '%s'_",PlayerName(playerid));
		SendClientMessage(playerid, green, string);
		format(string, sizeof(string), "Score: %d | Money: $%d | Kills: %d | Deaths: %d | Ratio: %0.2f ", GetPlayerScore(playerid), GetPlayerMoney(playerid), PlayerInfo[playerid][pKills], PlayerInfo[playerid][pDeaths], Float:PlayerInfo[playerid][pKills]/Float:PlayerInfo[playerid][pDeaths]);
		SendClientMessage(playerid, yellow, string);
		format(string, sizeof(string), "Team: %s | Rank: %s | Class: %s | Admin Level: %d | Helper: %d ", GetTeamName(playerid), GetRankName(playerid), GetClassName(playerid), PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pHelper]);
		SendClientMessage(playerid, yellow, string);
     }
	 else if(IsPlayerConnected(id))
	 {
		format(string, sizeof(string), "_Statistics for '%s'_",PlayerName(id));
		SendClientMessage(playerid, green, string);
		format(string, sizeof(string), "Score: %d | Money: $%d | Kills: %d | Deaths: %d | Ratio: %0.2f ", GetPlayerScore(id), GetPlayerMoney(id), PlayerInfo[id][pKills], PlayerInfo[id][pDeaths], Float:PlayerInfo[id][pKills]/Float:PlayerInfo[id][pDeaths]);
	    SendClientMessage(playerid, yellow, string);
		format(string, sizeof(string), "Team: %s | Rank: %s | Class: %s | Admin Level: %d | Helper: %d ", GetTeamName(id), GetRankName(id), GetClassName(id), PlayerInfo[id][pAdmin], PlayerInfo[id][pHelper]);
	    SendClientMessage(playerid, yellow, string);
     }
	 else SendClientMessage(playerid,RED,"[ERROR]: Player is not connected");
	 return 1;
}
the new stats(dialog)
Код:
CMD:stats(playerid, params[])
{
    new str2[1000];
	new str[1000], Deaths, playerid,h, m, s, name[MAX_PLAYER_NAME];
	if(isnull(params) (name) = playerid;
	else playerid = strval(params);
    if(IsPlayerConnected(playerid)) {
        TotalGameTime(playerid, h, m, s);
        GetPlayerName(playerid, name, sizeof(name));
 	    if(PlayerInfo[playerid][pDeaths] == 0) pDeaths = 1; else pDeaths = PlayerInfo[playerid][pDeaths];
	    format(str, sizeof str, "Name: %s\n\n Scores: %d\n\n Money: $%d\n\n Kills: %d\n\n Deaths: %d\n\n K/D Ratio: %0.2f \n\n",  PlayerName2(playerid), GetPlayerScore(playerid), GetPlayerMoney(playerid), PlayerInfo[playerid][pKills], PlayerInfo[playerid][pDeaths], Float:PlayerInfo[playerid][pKills]/Float:pDeaths);
        strcat(str2, str);
        format(str, sizeof str, "Admin Level: %d\n\n Operator: %s\n\n Rank: %s\n\n Team:\n %s\n Class: %s\n\n", PlayerInfo[playerid][padmin], PlayerInfo[playerid][pHelper] ? ("Yes") : ("No"), GetRankName(playerid), GetTeamName(playerid), GetClass(playerid));
	    strcat(str2, str);
	    format(str, sizeof str, "Vip:%s\n\nTimePlayed: [%d] hrs [%d] mins [%d] secs\n\nZones:\n", PlayerInfo[playerid][pVIP] ? ("Yes") : ("No"), h, m, s);
	    strcat(str2, str);

	ShowPlayerDialog(playerid, 44, DIALOG_STYLE_MSGBOX, ""cred"User Statistics", str2, "Close", "");
    } else return SendClientMessage(playerid, red, "[ERROR]: Player Not Connected!");
	return 1;
}
ERRORS:
Код:
C:\Users\PC\Desktop\Younes\SAMP Version\gamemodes\COD-DW-v1.50.pwn(1424) : warning 219: local variable "playerid" shadows a variable at a preceding level
C:\Users\PC\Desktop\Younes\SAMP Version\gamemodes\COD-DW-v1.50.pwn(1425) : error 029: invalid expression, assumed zero
C:\Users\PC\Desktop\Younes\SAMP Version\gamemodes\COD-DW-v1.50.pwn(1425) : error 033: array must be indexed (variable "name")
C:\Users\PC\Desktop\Younes\SAMP Version\gamemodes\COD-DW-v1.50.pwn(1428) : error 017: undefined symbol "TotalGameTime"
C:\Users\PC\Desktop\Younes\SAMP Version\gamemodes\COD-DW-v1.50.pwn(1430) : error 022: must be lvalue (non-constant)
C:\Users\PC\Desktop\Younes\SAMP Version\gamemodes\COD-DW-v1.50.pwn(1430) : warning 215: expression has no effect
C:\Users\PC\Desktop\Younes\SAMP Version\gamemodes\COD-DW-v1.50.pwn(1430) : error 029: invalid expression, assumed zero
C:\Users\PC\Desktop\Younes\SAMP Version\gamemodes\COD-DW-v1.50.pwn(1430) : error 022: must be lvalue (non-constant)
C:\Users\PC\Desktop\Younes\SAMP Version\gamemodes\COD-DW-v1.50.pwn(1430) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


7 Errors.
any solution ? Fast pls ..and i have already added admins/donor on dialog ..
EDIT: this dialog was working on my old cod gamemode..and now didn't work on my new cod server
Reply
#2

PHP код:
CMD:stats(playeridparams[])
{
    new 
id;
    if (
isnull(params)) id playerid;
    else 
sscanf(params"r"id);
        
    if (
id == INVALID_PLAYER_ID) return SendClientMessage(playeridred"[ERROR]: Player Not Connected!");
    
    new 
str[400], hms;
    
TotalGameTime(idhms);
    
    
format(strsizeof str,
    
"Name: %s\n\n Scores: %d\n\n Money: $%d\n\n Kills: %d\n\n Deaths: %d\n\n K/D Ratio: %.2f \n\n" \
    
"Admin Level: %d\n\n Operator: %s\n\n Rank: %s\n\n Team:\n %s\n Class: %s\n\n" \
    
"Vip:%s\n\nTimePlayed: [%d] hrs [%d] mins [%d] secs\n\nZones:\n",
    
PlayerName2(id), GetPlayerScore(id), GetPlayerMoney(id), PlayerInfo[id][pKills], PlayerInfo[id][pDeaths], floatdiv(PlayerInfo[id][pKills], !PlayerInfo[id][pDeaths] ? PlayerInfo[id][pDeaths]),
    
PlayerInfo[id][padmin], PlayerInfo[id][pHelper] ? ("Yes") : ("No"), GetRankName(id), GetTeamName(id), GetClass(id),
    
PlayerInfo[id][pVIP] ? ("Yes") : ("No"), hms);
    
    
ShowPlayerDialog(playerid44DIALOG_STYLE_MSGBOX""cred"User Statistics"str"Close""");
    return 
1;

Reply
#3

Код:
C:\Users\PC\Desktop\Younes\SAMP Version\gamemodes\COD-DW-v1.50.pwn(1430) : error 017: undefined symbol "TotalGameTime"
C:\Users\PC\Desktop\Younes\SAMP Version\gamemodes\COD-DW-v1.50.pwn(1432 -- 1436) : error 017: undefined symbol "PlayerName2"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
hm....
1430:
TotalGameTime(id, h, m, s);

1436:
PlayerName2(id), GetPlayerScore(id), GetPlayerMoney(id), PlayerInfo[id][pKills], PlayerInfo[id][pDeaths], floatdiv(PlayerInfo[id][pKills], !PlayerInfo[id][pDeaths] ? 1 : PlayerInfo[id][pDeaths]),



edit: i have try to fix the playername2
and got this
Код:
C:\Users\PC\Desktop\Younes\SAMP Version\gamemodes\COD-DW-v1.50.pwn(1430) : error 017: undefined symbol "TotalGameTime"
C:\Users\PC\Desktop\Younes\SAMP Version\gamemodes\COD-DW-v1.50.pwn(1432 -- 1437) : error 017: undefined symbol "GetClass"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
1437:
PlayerInfo[id][pAdmin], PlayerInfo[id][pHelper] ? ("Yes") : ("No"), GetRankName(id), GetTeamName(id), GetClass(id),
Reply
#4

That's actually something you have added, all I did was copying your modified version, fixing it and adding sscanf as extra. Those functions were added by you and I assumed you have them defined.
Reply
#5

ye only i got this error

C:\Users\PC\Desktop\Younes\SAMP Version\gamemodes\COD-AW-v8.0.pwn(1430) : error 017: undefined symbol "TotalGameTime"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#6

Hello i have just remove it now xD..i forget to put totalgametime

anyway when i try to compile again

C:\Users\PC\Desktop\Younes\SAMP Version\gamemodes\COD-DW-v1.50.pwn(1430) : error 017: undefined symbol "str"
C:\Users\PC\Desktop\Younes\SAMP Version\gamemodes\COD-DW-v1.50.pwn(1430) : error 017: undefined symbol "str"
C:\Users\PC\Desktop\Younes\SAMP Version\gamemodes\COD-DW-v1.50.pwn(143 : error 017: undefined symbol "str"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
3 Errors.


1430:
format(str, sizeof str,

1438:
ShowPlayerDialog(playerid, 44, DIALOG_STYLE_MSGBOX, ""cred"User Statistics", str, "Close", "");
Reply
#7

I guess you removed str along with h, m and s variables. See my post again and declare it as a string before the format line.
Reply
#8

done thx..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)