SA-MP Forums Archive
Moved objectvwith obj array - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Moved objectvwith obj array (/showthread.php?tid=427116)



Moved objectvwith obj array - colonel-top - 31.03.2013

Hello guys sorry for need to ask again last post im making obj array
i have 177 object so im create array
pawn Код:
new obj [178] = createobject blah blah
so now if i want when im type cmd its moving with use obj
so im try do it but it show error
array out of index
i should plus it or do something with it ?
Can someone help me plz thank you
examplez
pawn Код:
Moveobject(obj[178],0,0,10,2.0);
So what i should do help me plz thank you very much


Re: Moved objectvwith obj array - RajatPawar - 31.03.2013

178th cell would be the null terminator, you can use it up to the 177th one, I guess?


Re: Moved objectvwith obj array - colonel-top - 31.03.2013

Im use obj [177]
But it show error array out of index :P


Re: Moved objectvwith obj array - RajatPawar - 31.03.2013

pawn Код:
new objects[178];
for ( new i = 0; i < sizeof ( objects ) ; i ++ )
{
     objects[ i ] = CreateObject( ... );
     printf( "Index %d assigned to object id.", i ) ;
}
Try debugging. (It would spam) Tell us where you declare the array, how you assign it, some code mate, some code.


Re: Moved objectvwith obj array - colonel-top - 31.03.2013

Okay this my code ^_^
pawn Код:
new obj[178];
public OnFilterscriptsInit()
{

obj[1] = CreateObject(18483,836.9000200,-2102.8000500,12.0000000,0.0000000,0.0000000,90.0000000); //object(cuntsrod07) (1)
blah blah blah
.
.
obj [177] = CreateObject(1318,838.0000000,-2294.0000000,13.4483800,0.0000000,0.0000000,90.0000000); //object(arrow) (1)
MoveObject(obj[178], 0, 0, -50, 2.00);
}
public OnPlayerText(playerid, text[])
{
    if(strfind("upplz", "upplz", true) != -1)
   
   
    {
    MoveObject(obj, 0, 0, 12, 2.00);
    }
    return 1;
   
}



Re: Moved objectvwith obj array - Basssiiie - 31.03.2013

If you have new obj[178]; you can only use slot 0 to 177. (This is 178 slots total.) If you're accessing slots out of that bound, you either need to increase the bound (make the array bigger) or change the slot number.