HELP !!!
#1

Hi, I need help with xObjects. Script does not have any errors or warning in fact it works fine...all objects are shown but in some areas it constantly crashers

This is the code of the script...is something wrong in it but doesn't show the error or what
pawn Код:
#include <a_samp>

forward Timer();
forward SetPlayerPosWithObjects(playerid,Float:x,Float:y,Float:z);
/*
    SetPlayerPosWithObjects usage in your gamemode:

        CallRemoteFunction("SetPlayerPosWithObjects","ifff",playerid,newx,newy,newz);
*/


//------------------------------------------------------------------------------

enum object_info
{
    modelid,
    Float:ox,
    Float:oy,
    Float:oz,
    Float:orx,
    Float:ory,
    Float:orz,
    Float:viewdist
}

new Objects[][object_info] = {
    //---------------------------BURGER SHOT----------------------------------------
    {700, 1225.874390, -922.005981, 41.914085, 0.0000, 0.0000, 0.0000, 1000.0},
    {700, 1210.125854, -924.952576, 42.440826, 0.0000, 0.0000, 0.0000, 1000.0},
    {777, 1201.924561, -926.014832, 41.967731, 0.0000, 0.0000, 11.2500, 1000.0},
    {1281, 1180.751587, -924.900085, 43.024994, 0.0000, 0.0000, 11.1727, 1000.0},
    {1281, 1184.504395, -924.136108, 42.981861, 0.0000, 0.0000, 11.1727, 1000.0},
    {1281, 1188.030640, -923.357361, 42.947521, 0.0000, 0.0000, 11.1727, 1000.0},
    {1281, 1191.383057, -922.506653, 42.911713, 0.0000, 0.0000, 11.1727, 1000.0},
    {1281, 1177.860352, -919.790405, 43.089825, 0.0000, 0.0000, 97.0121, 1000.0},
    {1281, 1177.175781, -915.864563, 43.100082, 0.0000, 0.0000, 97.0121, 1000.0},
    {1281, 1176.656006, -912.159973, 43.092846, 0.0000, 0.0000, 97.0121, 1000.0},
    {18284, 1222.772583, -881.385925, 44.847000, 0.0000, 0.0000, 6.8755, 1000.0},
    {18284, 1225.057495, -899.824463, 44.839207, 0.0000, 0.0000, 6.8755, 1000.0},
    {18284, 1205.763794, -878.249268, 44.873699, 0.0000, 0.0000, 277.4941, 1000.0},
    {18284, 1180.734375, -881.255859, 45.134827, 0.0000, 0.0000, 277.4941, 1000.0},
    {622, 1189.268921, -960.057373, 39.804420, 8.5944, 0.0000, 0.0000, 1000.0},
    {622, 1183.847168, -930.430664, 41.850361, 10.3132, 344.5301, 192.4096, 1000.0},
    {622, 1243.392334, -950.769531, 38.502052, 10.3132, 342.8113, 352.1612, 1000.0},
    {622, 1237.907349, -920.237244, 40.909061, 14.6104, 342.8113, 181.9931, 1000.0},
    {16776, 1195.769531, -901.633240, 48.813343, 0.0000, 0.0000, 98.8352, 1000.0}
    //------------------------------------------------------------------------------
};

enum player_info
{
    objid[sizeof(Objects)],
    bool:view[sizeof(Objects)]
}
new Player[MAX_PLAYERS][player_info];

//------------------------------------------------------------------------------

bool:IsInReach(Float:x,Float:y,Float:z,Float:x2,Float:y2,Float:z2,Float:dist)
{
    x = (x > x2) ? x - x2 : x2 - x;
    if(x > dist) return false;
    y = (y > y2) ? y - y2 : y2 - y;
    if(y > dist) return false;
    z = (z > z2) ? z - z2 : z2 - z;
    if(z > dist) return false;
    return true;
}

//------------------------------------------------------------------------------

new timer;

public OnFilterScriptInit()
{
    print("---\nLoaded xObjects by Boylett\n---");
    timer = SetTimer("Timer",500,1);
    return 1;
}

public OnFilterScriptExit()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        for(new o = 0; o < sizeof(Objects); o++)
        {
            if(Player[i][view][o])
            {
                Player[i][view][o] = false;
                DestroyPlayerObject(i,Player[i][objid][o]);
            }
        }
    }
   
    KillTimer(timer);
}

//------------------------------------------------------------------------------

public OnPlayerConnect(playerid)
{
    for(new i = 0; i < sizeof(Objects); i++) Player[playerid][view][i] = false;
}

public OnPlayerDisconnect(playerid)
{
    for(new i = 0; i < sizeof(Objects); i++)
    {
        if(Player[playerid][view][i])
        {
            Player[playerid][view][i] = false;
            DestroyPlayerObject(playerid,Player[playerid][objid][i]);
        }
    }
}

//------------------------------------------------------------------------------

public Timer()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
        if(IsPlayerConnected(i))
          PlayerObjectUpdate(i);
}

PlayerObjectUpdate(playerid)
{
    new Float:pos[3];
    GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
    for(new i = 0; i < sizeof(Objects); i++)
    {
      if(!Player[playerid][view][i])
      {
        if(IsInReach(pos[0],pos[1],pos[2],Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][viewdist]))
        {
          Player[playerid][view][i] = true;
          Player[playerid][objid][i] = CreatePlayerObject(playerid,Objects[i][modelid],Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][orx],Objects[i][ory],Objects[i][orz]);
        }
      } else if(!IsInReach(pos[0],pos[1],pos[2],Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][viewdist]))
      {
      Player[playerid][view][i] = false;
      DestroyPlayerObject(playerid,Player[playerid][objid][i]);
      }
    }
}

public SetPlayerPosWithObjects(playerid,Float:x,Float:y,Float:z)
{
    for(new i = 0; i < sizeof(Objects); i++)
    {
      if(!Player[playerid][view][i])
      {
        if(IsInReach(x,y,z,Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][viewdist]))
        {
          Player[playerid][view][i] = true;
          Player[playerid][objid][i] = CreatePlayerObject(playerid,Objects[i][modelid],Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][orx],Objects[i][ory],Objects[i][orz]);
        }
      } else if(!IsInReach(x,y,z,Objects[i][ox],Objects[i][oy],Objects[i][oz],Objects[i][viewdist]))
      {
      Player[playerid][view][i] = false;
      DestroyPlayerObject(playerid,Player[playerid][objid][i]);
      }
    }
    SetPlayerPos(playerid,Float:x,Float:y,Float:z);
}

public OnPlayerSpawn(playerid)
    PlayerObjectUpdate(playerid);
Please someone help me
Reply
#2

Maybe you have too many obejcts in one area, Causing lagg causing you to crash?
Reply
#3

Change 1000.0 to lower, 500.0 etc.
Reply
#4

My view distance works perfect at 200, 1000 is nearly half the size of Los Santos
Reply
#5

I out it on 200 and it work excellent
Thanks guys :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)