SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 20/05/2012, 03:44 PM   #1
Sanady
High-roller
 
Sanady's Avatar
 
Join Date: May 2012
Location: Los Santos
Posts: 1,174
Reputation: 132
Exclamation Problem with GetPlayerName

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 (c) 1997-2006, ITB CompuPhase


5 Errors.
__________________

Sanady is offline   Reply With Quote
Old 20/05/2012, 03:50 PM   #2
Niko_boy
High-roller
 
Niko_boy's Avatar
 
Join Date: Aug 2010
Location: Somewhere i belong
Posts: 1,336
Reputation: 138
Default Re: Problem with GetPlayerName

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)
__________________
nope[IMG]http://*******/1r0SOkH_[/IMG]
•••[CLOSED]LCS•Freeroam•DM•Stunts•••AutoArena [0.3z][No SkinShot][sixtytiger.com]Want a decent Attack Defend Gamemode?
N/A176.31.229.148:7830Get This! Attack-Defend(v2.3.1)
Niko_boy is offline   Reply With Quote
Old 20/05/2012, 03:51 PM   #3
[FMJ]PowerSurge
Big Clucker
 
Join Date: May 2012
Location: Nottingham, England
Posts: 125
Reputation: 19
Default Re: Problem with GetPlayerName

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]).
[FMJ]PowerSurge is offline   Reply With Quote
Old 20/05/2012, 04:05 PM   #4
Sanady
High-roller
 
Sanady's Avatar
 
Join Date: May 2012
Location: Los Santos
Posts: 1,174
Reputation: 132
Default Re: Problem with GetPlayerName

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

Sanady is offline   Reply With Quote
Old 20/05/2012, 04:10 PM   #5
[FMJ]PowerSurge
Big Clucker
 
Join Date: May 2012
Location: Nottingham, England
Posts: 125
Reputation: 19
Default Re: Problem with GetPlayerName

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

And is 'playerid2' an integer?
[FMJ]PowerSurge is offline   Reply With Quote
Old 20/05/2012, 04:13 PM   #6
Niko_boy
High-roller
 
Niko_boy's Avatar
 
Join Date: Aug 2010
Location: Somewhere i belong
Posts: 1,336
Reputation: 138
Default Re: Problem with GetPlayerName

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]
__________________
nope[IMG]http://*******/1r0SOkH_[/IMG]
•••[CLOSED]LCS•Freeroam•DM•Stunts•••AutoArena [0.3z][No SkinShot][sixtytiger.com]Want a decent Attack Defend Gamemode?
N/A176.31.229.148:7830Get This! Attack-Defend(v2.3.1)
Niko_boy is offline   Reply With Quote
Old 20/05/2012, 04:15 PM   #7
[FMJ]PowerSurge
Big Clucker
 
Join Date: May 2012
Location: Nottingham, England
Posts: 125
Reputation: 19
Default Re: Problem with GetPlayerName

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])
[FMJ]PowerSurge is offline   Reply With Quote
Old 20/05/2012, 04:56 PM   #8
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,067
Reputation: 2660
Default Re: Problem with GetPlayerName

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
__________________
Vince is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VIP GetPlayerName help [M.A]Angel[M.A] Scripting Help 3 10/09/2011 06:43 PM
[HELP] GetPlayerName Problem Larsey123IsMe Help Archive 2 17/05/2011 02:03 PM
Getplayername problem [nL]W0rfleR Help Archive 3 04/03/2011 08:06 AM
GetPlayerName Kingunit Help Archive 14 26/01/2011 01:02 PM
GetPlayerName juuleman Help Archive 4 05/04/2010 10:28 AM


All times are GMT. The time now is 03:37 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.