SA-MP Forums Archive
Problem with GetPlayerName - 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: Problem with GetPlayerName (/showthread.php?tid=344310)



Problem with GetPlayerName - Sanady - 20.05.2012

Hello.I got problem with GetPlayerName.

pawn Code:
GetPlayerName(playerid, pName, sizeof(pName));
    GetPlayerName(playerid, pName[playerid2], sizeof(pName[playerid2]));
What is problem here

ERRORS:
Code:
D:\samp03dsvr_win32(1)\filterscripts\AdminScript.pwn(195) : error 048: array dimensions do not match
D:\samp03dsvr_win32(1)\filterscripts\AdminScript.pwn(196) : error 001: expected token: "]", but found "-identifier-"
D:\samp03dsvr_win32(1)\filterscripts\AdminScript.pwn(196) : warning 215: expression has no effect
D:\samp03dsvr_win32(1)\filterscripts\AdminScript.pwn(196) : error 001: expected token: ";", but found "]"
D:\samp03dsvr_win32(1)\filterscripts\AdminScript.pwn(196) : error 029: invalid expression, assumed zero
D:\samp03dsvr_win32(1)\filterscripts\AdminScript.pwn(196) : fatal error 107: too many error messages on one line

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


5 Errors.



Re: Problem with GetPlayerName - Niko_boy - 20.05.2012

you doing wrong u have to create 2d array for pName[player] stuff
and if u have already dont add that in sizeof just do like sizeof(pName)


Re: Problem with GetPlayerName - [FMJ]PowerSurge - 20.05.2012

Depends. Is 'pName' an array? If not, set it to an array.

pawn Code:
new pName[MAX_PLAYERS][MAX_PLAYER_NAME];
Also, try making it sizeof(pName) instead of sizeof(pName[playerid2]).


Re: Problem with GetPlayerName - Sanady - 20.05.2012

Also when i Add this have same errors
pawn Code:
GetPlayerName(playerid, pName[playerid], sizeof(pName[playerid]));
    GetPlayerName(playerid, pName[playerid2], sizeof(pName[playerid2]));



Re: Problem with GetPlayerName - [FMJ]PowerSurge - 20.05.2012

Did you do new pName[MAX_PLAYERS][26];?

And is 'playerid2' an integer?


Re: Problem with GetPlayerName - Niko_boy - 20.05.2012

u cant use it like sizeof(pName[playerid]) ...... or can u >? i guess no cause it will provide some error
sizeof(pName) it will just get string size u wont need to limit to an particular array .. [cant explain]


Re: Problem with GetPlayerName - [FMJ]PowerSurge - 20.05.2012

Quote:
Originally Posted by Niko_boy
View Post
u cant use it like sizeof(pName[playerid]) ...... or can u >? i guess no cause it will provide some error
sizeof(pName) it will just get string size u wont need to limit to an particular array .. [cant explain]
In other words, use
pawn Code:
sizeof(pName)
NOT

pawn Code:
sizeof(pName[playerid2])



Re: Problem with GetPlayerName - Vince - 20.05.2012

No, to get the size of the second dimension, you simply use sizeof(variable[]).

pawn Code:
new array[10][20][30];

sizeof(array) // returns 10
sizeof(array[]) // returns 20
sizeof(array[][]) // returns 30