Statement Error
#1

Is there anything unusual here

PHP код:
/*Error line is here*/if(!strcmp(HInfo[hid][hOwner], pName(playerid), true))
{
    
SendClientMessage(playerid,-1,"Welcome!");

Errors
Код:
(32913) : error 012: invalid function call, not a valid address
(32913) : warning 215: expression has no effect
(32913) : error 001: expected token: ";", but found ")"
(32913) : error 029: invalid expression, assumed zero
(32913) : fatal error 107: too many error messages on one line

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


4 Errors.
Reply
#2

"pName" is likely not a function, which is what "invalid function call" means. Note the use of round and square brackets.
Reply
#3

Forgot to introduce pName

PHP код:
stock pName(playerid)
{
    new 
Nick[MAX_PLAYER_NAME];
    
GetPlayerName(playeridNickMAX_PLAYER_NAME);
     return 
Nick;

Reply
#4

What if you isolate the code, that you believe leads to the problem, does it still happen?
Reply
#5

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
What if you isolate the code, that you believe leads to the problem, does it still happen?
Well, found out that pName was already defined in an enumerator, which confuses the compiler
Reply
#6

A better practice according to what I've studied is that you should make an array which stores the player name and make it global, so you won't need to use pName again and again, but only have to use the GetPlayerName native with the global variable in it, and then you can fetch the player name by just using the variable. Which doesn't only makes it easy to use but faster as well (and helps in some situations!).

PHP код:
#undef MAX_PLAYERS
    #define MAX_PLAYERS your_sv_slots
new pName[MAX_PLAYERS][MAX_PLAYER_NAME];
GetPlayerName(playeridpName[i], MAX_PLAYER_NAME);
print(
pName[playerid]); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)