Array index out of bounds
#10

Quote:
Originally Posted by SaiyanZ
View Post
I found the line if i remove the line the command works
any ideas what should i do to replace it with something else?
PHP Code:
CMD:ocreate(playeridparams[])
{
    if(
PlayerInfo[playerid][Level]<3) return SendClientMessage(playeridCOLOR_RED"SERVER: You're not allowed to use this command");
    new 
objectid;
    if(
sscanf(params,"d"objectid)) return SendClientMessage(playerid,COLOR_RED,"Usage:/ocreate [object id]");
    if(
objectid 321 || objectid 19999) return SendClientMessage(playerid,COLOR_RED,"SERVER: Object ID not found.");
    {
        
objects++;
        
objectsid[objects]=objectid;
        new 
Float:XFloat:YFloat:Zstr[128];
        
GetPlayerPos(playeridXYZ);
        
SpawnedObject[objects] = CreateDynamicObject(objectidXYZ+1000);
    
ObjectSpawned[SpawnedObject[objects]] = 1//  <-----  this  line
    
format(str128"SERVER: Object ID: %d - Created at your location - Index: %d"objectidobjects);
    
SendClientMessage(playeridCOLOR_REDstr);
    }
    return 
1;

Why not try printing the contents of SpawnedObject[objects] into chat or something so you can see what value it has, and then from there figure out how it reaches said value?

The way I understand it, it seems you're giving that variable a value larger than 998, which is why you break out of the array's bounds.
Reply


Messages In This Thread
Array index out of bounds - by SaiyanZ - 03.04.2019, 16:32
Re: Array index out of bounds - by raydx - 03.04.2019, 16:48
Re: Array index out of bounds - by Viggo - 03.04.2019, 17:12
Re: Array index out of bounds - by v1k1nG - 03.04.2019, 17:50
Re: Array index out of bounds - by SaiyanZ - 04.04.2019, 12:42
Re: Array index out of bounds - by raydx - 04.04.2019, 12:58
Re: Array index out of bounds - by Pottus - 06.04.2019, 03:16
Re: Array index out of bounds - by Markski - 06.04.2019, 05:07
Re: Array index out of bounds - by SaiyanZ - 06.04.2019, 12:30
Re: Array index out of bounds - by Markski - 06.04.2019, 14:19
Re: Array index out of bounds - by Y_Less - 06.04.2019, 14:46

Forum Jump:


Users browsing this thread: 1 Guest(s)