xObjects not working help
#1

if i put: scroll down!
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] = {
    {11507, 1460.113281, -108.135841, 194.861435, 0.0, 0.0, 180.0, 1000.0},
    {11507, 1214.021240, -107.197754, 197.665619, 0.0, 0.0, 180.0,1000.0},
    {11507, 960.208008, -106.939079, 217.257339, 0.0, 0.0, 180.0,1000.0},
    //airport
  {987, 1840.7855, -2468.1655, 12.5547, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1460.8590, -2609.0474, 12.5469, 0.0000, 0.0000, 45.0000, 500.0},
{980, 1385.5576, -2688.8289, 272.7346, 0.0000, 0.0000, 270.0000, 500.0},
{980, 1557.5109, -2539.1060, 15.3203, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1551.8846, -2539.1541, 12.5469, 0.0000, 0.0000, 180.0000, 500.0},
{987, 1529.8875, -2539.2014, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1517.9420, -2539.1858, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1563.3389, -2538.9661, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1575.1006, -2539.1848, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1507.5676, -2539.2651, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1496.1644, -2539.1794, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1485.5868, -2539.2180, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1475.5398, -2539.1577, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1464.0690, -2539.2698, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1453.7406, -2539.3801, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1443.0624, -2539.3206, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1431.4468, -2539.3311, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1420.0522, -2539.3564, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1408.6526, -2539.3789, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1397.5867, -2539.3174, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1385.4867, -2539.0315, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1375.3092, -2538.9758, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1365.5204, -2538.9382, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1361.5760, -2538.9121, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1587.0972, -2539.3508, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1598.8966, -2539.4500, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1610.8196, -2539.5847, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1622.6140, -2539.8210, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1634.5681, -2539.9722, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1646.0840, -2540.0688, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1657.8278, -2540.0654, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1669.9886, -2540.4087, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1681.6096, -2540.2998, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1693.3783, -2540.3735, 12.5469, 0.0000, 0.0000, 90.0000, 500.0},
{987, 1693.4919, -2528.4368, 12.5469, 0.0000, 0.0000, 90.0000, 500.0},
{987, 1693.5156, -2516.5154, 12.5469, 0.0000, 0.0000, 90.0000, 500.0},
{987, 1693.6061, -2504.9602, 12.5547, 0.0000, 0.0000, 90.0000, 500.0},
{987, 1693.5784, -2494.0554, 12.5547, 0.0000, 0.0000, 90.0000, 500.0},
{987, 1693.6902, -2482.2251, 12.5547, 0.0000, 0.0000, 90.0000, 500.0},
{987, 1693.6738, -2470.8389, 12.5547, 0.0000, 0.0000, 90.0000, 500.0},
{987, 1693.8419, -2458.9265, 12.5547, 0.0000, 0.0000, 90.0000, 500.0},
{987, 1693.9969, -2447.1667, 12.5547, 0.0000, 0.0000, 90.0000, 500.0},
{987, 1694.1008, -2435.3855, 12.5547, 0.0000, 0.0000, 90.0000, 500.0},
{2780, 1551.1478, -2538.0283, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{2780, 1563.9075, -2540.3066, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{3877, 1537.1174, -2412.3579, 24.5643, 0.0000, 0.0000, 0.0000, 500.0},
{3877, 1534.6589, -2421.4109, 24.6637, 0.0000, 0.0000, 0.0000, 500.0},
{3877, 1523.3618, -2420.4397, 25.3767, 0.0000, 0.0000, 0.0000, 500.0},
{3877, 1518.1720, -2408.4167, 25.3767, 0.0000, 0.0000, 0.0000, 500.0},
{3877, 1526.0609, -2418.4595, 23.7204, 0.0000, 0.0000, 0.0000, 500.0},
{7916, 1411.2079, -2485.9836, 16.3934, 0.0000, 0.0000, 90.0000, 500.0},
{3603, 1459.6163, -2423.7927, 18.4259, 0.0000, 0.0000, 0.0000, 500.0},
{3605, 1499.4247, -2443.7324, 18.6603, 0.0000, 0.0000, 326.2500, 500.0},
{3607, 1461.1407, -2522.8779, 18.6525, 0.0000, 0.0000, 180.0000, 500.0},
{3606, 1430.5703, -2439.7026, 15.9588, 0.0000, 0.0000, 45.0000, 500.0},
{3606, 1423.9237, -2517.9717, 15.9510, 0.0000, 0.0000, 146.2500, 500.0},
{672, 1473.4529, -2440.5425, 13.5027, 0.0000, 0.0000, 0.0000, 500.0},
{672, 1465.0110, -2465.0366, 13.5027, 0.0000, 0.0000, 0.0000, 500.0},
{672, 1445.2883, -2458.5422, 13.5027, 0.0000, 0.0000, 0.0000, 500.0},
{672, 1439.7694, -2427.0999, 13.5027, 0.0000, 0.0000, 0.0000, 500.0},
{672, 1436.8102, -2516.4207, 13.4949, 0.0000, 0.0000, 0.0000, 500.0},
{672, 1504.6593, -2467.1191, 13.5027, 0.0000, 0.0000, 0.0000, 500.0},
{672, 1493.3818, -2509.6287, 13.5027, 0.0000, 0.0000, 0.0000, 500.0},
{672, 1447.9247, -2484.5986, 13.5027, 0.0000, 0.0000, 0.0000, 500.0},
{6965, 1469.4219, -2488.6672, 16.1672, 0.0000, 0.0000, 0.0000, 500.0},
{1280, 1482.0319, -2491.7971, 12.9560, 0.0000, 0.0000, 348.7500, 500.0},
{1280, 1479.9116, -2496.8462, 12.9560, 0.0000, 0.0000, 326.2500, 500.0},
{1280, 1475.5529, -2501.0225, 12.9560, 0.0000, 0.0000, 292.5000, 500.0},
{1280, 1469.4791, -2501.4902, 12.9560, 0.0000, 0.0000, 270.0000, 500.0},
{1280, 1463.0237, -2499.7964, 12.9560, 0.0000, 0.0000, 236.2501, 500.0},
{1280, 1457.9866, -2495.6665, 12.9560, 0.0000, 0.0000, 225.0000, 500.0},
{1280, 1456.0226, -2491.1899, 12.9560, 0.0000, 0.0000, 191.2500, 500.0},
{1280, 1482.0267, -2485.6135, 12.9560, 0.0000, 0.0000, 11.2500, 500.0},
{1280, 1479.1321, -2480.5371, 12.9560, 0.0000, 0.0000, 45.0000, 500.0},
{1280, 1475.1278, -2477.1135, 12.9560, 0.0000, 0.0000, 67.5000, 500.0},
{1280, 1469.4990, -2475.9343, 12.9560, 0.0000, 0.0000, 90.0000, 500.0},
{1280, 1463.1923, -2477.7510, 12.9560, 0.0000, 0.0000, 123.7500, 500.0},
{1280, 1458.8314, -2481.5085, 12.9560, 0.0000, 0.0000, 146.2501, 500.0},
{1280, 1456.3102, -2486.2720, 12.9560, 0.0000, 0.0000, 168.7501, 500.0},
{3566, 1662.8910, -2414.0938, 15.1683, 0.0000, 0.0000, 180.0000, 500.0},
{3568, 1654.0399, -2413.9319, 15.1683, 0.0000, 0.0000, 180.0000, 500.0},
{3569, 1645.8594, -2412.8403, 15.1683, 0.0000, 0.0000, 180.0000, 500.0},
{3573, 1640.7562, -2444.8022, 15.2464, 0.0000, 0.0000, 337.5000, 500.0},
{3575, 1624.4197, -2432.7849, 15.2464, 0.0000, 0.0000, 292.5000, 500.0},
{1383, 1631.7095, -2414.5544, 45.0850, 0.0000, 0.0000, 0.0000, 500.0},
{1384, 1631.5927, -2414.5818, 77.6241, 0.0000, 0.0000, 213.7501, 500.0},
{11400, 1631.9247, -2416.6438, 80.0009, 0.0000, 0.0000, 0.0000, 500.0},
{1381, 1657.8687, -2454.0918, 82.4848, 0.0000, 0.0000, 0.0000, 500.0},
{1689, 1684.8113, -2429.6135, 23.2656, 0.0000, 0.0000, 180.0000, 500.0},
{3633, 1641.1809, -2448.6172, 18.4241, 0.0000, 0.0000, 0.0000, 500.0},
{3633, 1637.5133, -2446.6704, 15.7268, 0.0000, 0.0000, 0.0000, 500.0},
{3633, 1634.3842, -2444.0957, 18.4241, 0.0000, 0.0000, 0.0000, 500.0},
{5132, 1551.9211, -2419.8352, 15.6171, 0.0000, 0.0000, 337.5001, 500.0},
{17055, 1572.8882, -2414.0596, 14.8969, 0.0000, 0.0000, 0.0000, 500.0}
   
    // {modelid,x,y,z,rotx,roty,rotz,viewdistance}
    // all params are same as create object, except there is an additional viewdistance parameter. This is the distance
    // a player should be to see the object
};

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);
pawn Код:
{987, 1840.7855, -2468.1655, 12.5547, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1460.8590, -2609.0474, 12.5469, 0.0000, 0.0000, 45.0000, 500.0},
{980, 1385.5576, -2688.8289, 272.7346, 0.0000, 0.0000, 270.0000, 500.0},
{980, 1557.5109, -2539.1060, 15.3203, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1551.8846, -2539.1541, 12.5469, 0.0000, 0.0000, 180.0000, 500.0},
{987, 1529.8875, -2539.2014, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1517.9420, -2539.1858, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
{987, 1563.3389, -2538.9661, 12.5469, 0.0000, 0.0000, 0.0000, 500.0},
in it it dont work i compile it and it is good
i put it in the server and cant see the objects

can any one help me plzzz

thx...alot...
Reply
#2

please anyone
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)