"array must be indexed" error.
#1

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 (c1997-2006ITB CompuPhase
1 Error

Codes are :
PHP код:
new MB[MAX_PLAYERS]; 
PHP код:
MB CreateObject(15500.00.00.00.00.00.0); // error on this line 
PHP код:
AttachObjectToPlayer(MB[playerid], playerid, -0.027000, -0.2519990.0000001.0000001.0000001.000000); 
Any help ?
Reply
#2

try

MB[playerid] = CreateObject(1550, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // error on this line
Reply
#3

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

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

Why don't you just use SetPlayerAttachedObject?
Reply
#6

Quote:
Originally Posted by Threshold
Посмотреть сообщение
Why don't you just use SetPlayerAttachedObject?
I'm using it already , since attachment wasn't good. Thanks anyway.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)