GetPlayerName & GetPlayerPing Errors
#1

Alright. I'm getting a few errors for the same line. Not sure how to solve them. I'm trying to get this function to alert players on the server of high ping. (Annoying function? yes i know but its a small server trololol.) I believe I'm handling the name variable wrong. I've included a_players and put this all under public pingchecktimer(playerid).

Code
Код:
237|     if(GetPlayerPing(playerid) > 350)
238|     GetPlayerName(playerid, pName, sizeof(pName[MAX_PLAYER_NAME]));
239|     format(string,sizeof(string), "Warning: %s is playing with a high ping of %s.", pName, GetPlayerPing(playerid));
240|     SendClientMessageToAll (0x550000FF, string);
Errors
Код:
C:\Users\Dennis\Desktop\SAMP\Servers\roleplay by me\gamemodes\roleplay.pwn(238) : error 017: undefined symbol "pName"
C:\Users\Dennis\Desktop\SAMP\Servers\roleplay by me\gamemodes\roleplay.pwn(238) : error 017: undefined symbol "pName"
C:\Users\Dennis\Desktop\SAMP\Servers\roleplay by me\gamemodes\roleplay.pwn(238) : error 029: invalid expression, assumed zero
C:\Users\Dennis\Desktop\SAMP\Servers\roleplay by me\gamemodes\roleplay.pwn(238) : fatal error 107: too many error messages on one line

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


4 Errors.
What do I need to do to define pName? And what is causing line 238 to be assumed zero?

Any help is appreciated!
Reply
#2

Replace
pawn Код:
GetPlayerName(playerid, pName, sizeof(pName[MAX_PLAYER_NAME]));
with
pawn Код:
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(MAX_PLAYER_NAME));
Reply
#3

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
pawn Код:
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(MAX_PLAYER_NAME));
i assume that you had a typo.

use this instead:

pawn Код:
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
Reply
#4

or use

Код:
stock GetName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    return name;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)