Problem with GetPlayerName
#1

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.
Reply
#2

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)
Reply
#3

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]).
Reply
#4

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

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

And is 'playerid2' an integer?
Reply
#6

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]
Reply
#7

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])
Reply
#8

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)