PDA

View Full Version : Problem with GetPlayerName


Sanady
20/05/2012, 03:44 PM
Hello.I got problem with GetPlayerName.


GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerName(playerid, pName[playerid2], sizeof(pName[playerid2]));

What is problem here

ERRORS:

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

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


5 Errors.

Niko_boy
20/05/2012, 03:50 PM
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)

[FMJ]PowerSurge
20/05/2012, 03:51 PM
Depends. Is 'pName' an array? If not, set it to an array.

new pName[MAX_PLAYERS][MAX_PLAYER_NAME];

Also, try making it sizeof(pName) instead of sizeof(pName[playerid2]).

Sanady
20/05/2012, 04:05 PM
Also when i Add this have same errors

GetPlayerName(playerid, pName[playerid], sizeof(pName[playerid]));
GetPlayerName(playerid, pName[playerid2], sizeof(pName[playerid2]));

[FMJ]PowerSurge
20/05/2012, 04:10 PM
Did you do new pName[MAX_PLAYERS][26];?

And is 'playerid2' an integer?

Niko_boy
20/05/2012, 04:13 PM
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]

[FMJ]PowerSurge
20/05/2012, 04:15 PM
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
sizeof(pName)

NOT

sizeof(pName[playerid2])

Vince
20/05/2012, 04:56 PM
No, to get the size of the second dimension, you simply use sizeof(variable[]).


new array[10][20][30];

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