Little help ? :)
#1

Hello.

I have a error on my script. I have command: /stats. It gave me 4 ERRORS. The command is BELOW !

Код:
#if defined USE_STATS
CMD:stats(playerid,params[]) {
	new string[128], 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(string, sizeof(string), "{5EFF00}| %s's Stats: Level: %d | Kills: %d | Deaths: %d | Ratio: %0.2f | Money: $%d | Bank: $%d | Time: %d hrs %d mins %d secs |",PlayerName2(player1),PlayerInfo[player1][Level],PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths], Float:PlayerInfo[player1][Kills]/Float:pDeaths,GetPlayerMoney(player1),PlayerInfo[playerid][bank], h, m, s);
		return SendClientMessage(playerid, red, string);
	} else return SendClientMessage(playerid, red, "Player Not Connected!");
}
#endif
The error:

Код:
C:\Users\ўггелпт\Desktop\samp037_svr_R2-1-1_win32\samp037_svr_R2-1-1_win32\gamemodes\NFTDM.pwn(11520) : error 012: invalid function call, not a valid address
C:\Users\ўггелпт\Desktop\samp037_svr_R2-1-1_win32\samp037_svr_R2-1-1_win32\gamemodes\NFTDM.pwn(11520) : warning 215: expression has no effect
C:\Users\ўггелпт\Desktop\samp037_svr_R2-1-1_win32\samp037_svr_R2-1-1_win32\gamemodes\NFTDM.pwn(11520) : error 001: expected token: ";", but found ")"
C:\Users\ўггелпт\Desktop\samp037_svr_R2-1-1_win32\samp037_svr_R2-1-1_win32\gamemodes\NFTDM.pwn(11520) : error 029: invalid expression, assumed zero
C:\Users\ўггелпт\Desktop\samp037_svr_R2-1-1_win32\samp037_svr_R2-1-1_win32\gamemodes\NFTDM.pwn(11520) : fatal error 107: too many error messages on one line

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


4 Errors.
The LINE:

Код:
format(string, sizeof(string), "{5EFF00}| %s's Stats: Level: %d | Kills: %d | Deaths: %d | Ratio: %0.2f | Money: $%d | Bank: $%d | Time: %d hrs %d mins %d secs |",PlayerName2(player1),PlayerInfo[player1][Level],PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths], Float:PlayerInfo[player1][Kills]/Float:pDeaths,GetPlayerMoney(player1),PlayerInfo[playerid][bank], h, m, s);
Reply
#2

Try with:

Код:
#if defined USE_STATS
CMD:stats(playerid,params[]) {
	new string[128], 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(string, sizeof(string), "{5EFF00}| %s's Stats: Level: %d | Kills: %d | Deaths: %d | Ratio: %0.2f | Money: $%d | Bank: $%d | Time: %d hrs %d mins %d secs |",PlayerName2(player1),PlayerInfo[player1][Level],PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths], Float:PlayerInfo[player1][Kills]/Float:pDeaths,GetPlayerMoney(player1),PlayerInfo[playerid][bank], h, m, s);
		return SendClientMessage(playerid, red, string);
	} else return SendClientMessage(playerid, red, "Player Not Connected!");
}
#endif
If it still with error, send the error line.
Reply
#3

Same error.
Reply
#4

I think you should set bigger string size, try string[256]

EDIT:
Try using:
pawn Код:
GetPlayerName(player1, free_string, sizeof(free_string))
instead of

pawn Код:
PlayerName2(player1)
Reply
#5

PlayerName2 is not a function. It is probably a 2D array defined as:
pawn Код:
new PlayerName2[MAX_PLAYERS][MAX_PLAYER_NAME];
that stores the player's name. If that is the case, you can access it by using PlayerName2[player1] instead.
Reply
#6

Most likely PlayerName2 may not be a function it might be any other variables like array.
EDIT: sorry i didnt refresh
Reply
#7

So, What's the Correct code?
Reply
#8

Can you give me the right code for it ? If so, Please send.
Reply
#9

Quote:
Originally Posted by Knowinne
Посмотреть сообщение
Can you give me the right code for it ? If so, Please send.
pawn Код:
#if defined USE_STATS
CMD:stats(playerid,params[]) {
    new string[256], pDeaths, player1, pname[32], s, h, m;
    if(isnull(params)) player1 = playerid;
    else player1 = strval(params);

    if(IsPlayerConnected(player1)) {
                TotalGameTime(player1, h, m, s);
        GetPlayerName(player1, pname, sizeof(pname));
        if(PlayerInfo[player1][Deaths] == 0) pDeaths = 1;
        else pDeaths = PlayerInfo[player1][Deaths];
        format(string, sizeof(string), "{5EFF00}| %s's Stats: Level: %d | Kills: %d | Deaths: %d | Ratio: %0.2f | Money: $%d | Bank: $%d | Time: %d hrs %d mins %d secs |",pname,PlayerInfo[player1][Level],PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths], Float:PlayerInfo[player1][Kills]/Float:pDeaths,GetPlayerMoney(player1),PlayerInfo[playerid][bank], h, m, s);
        return SendClientMessage(playerid, red, string);
    } else return SendClientMessage(playerid, red, "Player Not Connected!");
}
#endif
EDIT: oopss sorry i removed your time system ill return it in few seconds, i was just testing it, it's all fine now
Reply
#10

Worked. Just changed something !

+REP.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)