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



Statement Error - NealPeteros - 04.05.2017

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.



Re: Statement Error - Vince - 04.05.2017

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


Re: Statement Error - NealPeteros - 04.05.2017

Forgot to introduce pName

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




Re: Statement Error - BiosMarcel - 04.05.2017

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


Re: Statement Error - NealPeteros - 04.05.2017

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


Re: Statement Error - Logic_ - 04.05.2017

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]);