"array must be indexed" error. -
Moudix - 09.07.2015
Hello,
I'm trying to attach an object to player, but i'm getting this error :
PHP код:
C:\Documents and Settings\user1\My Documents\SAMP server\gamemodes\TDM.pwn(1158) : error 033: array must be indexed (variable "MB")
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
1 Error.
Codes are :
PHP код:
new MB[MAX_PLAYERS];
PHP код:
MB = CreateObject(1550, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // error on this line
PHP код:
AttachObjectToPlayer(MB[playerid], playerid, -0.027000, -0.251999, 0.000000, 1.000000, 1.000000, 1.000000);
Any help ?
Re: "array must be indexed" error. -
Kqly - 09.07.2015
try
MB[playerid] = CreateObject(1550, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // error on this line
Re: "array must be indexed" error. -
Mouiz - 09.07.2015
You dont need to write [MAX_PLAYERS] after MB.
Try this:
Код:
new MB;
MB = CreateObject(1550, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToPlayer(MB[playerid], playerid, -0.027000, -0.251999, 0.000000, 1.000000, 1.000000, 1.000000);
Or this:
Код:
new MB;
MB = CreateObject(1550, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToPlayer(MB, playerid, -0.027000, -0.251999, 0.000000, 1.000000, 1.000000, 1.000000);
Re: "array must be indexed" error. -
Moudix - 09.07.2015
So i don't need to add [MAX_PLAYERS]? i've seen on a thread that i must do it.. here's the link :
https://sampforum.blast.hk/showthread.php?tid=538604
I'll try removing it anyway.
Edit : Worked when i removed [MAX_PLAYERS], thank you Mouiz

.
I got no reputations to +rep you , sorry.
Re: "array must be indexed" error. -
Threshold - 09.07.2015
Why don't you just use SetPlayerAttachedObject?
Re: "array must be indexed" error. -
Moudix - 09.07.2015
Quote:
Originally Posted by Threshold
Why don't you just use SetPlayerAttachedObject?
|
I'm using it already , since attachment wasn't good. Thanks anyway.