Was hab ichen Falsch gemacht???
#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] = {
{13011, 1575.2775, -1638.2158, 13.5911, 0.0000, 0.0000, 270.0000, 500.0},
{13011, 1580.1600, -1637.2178, 15.4157, 0.0000, 0.0000, 270.0000, 500.0},
{13011, 1578.6787, -1743.1615, 20.5874, 0.0000, 0.0000, 180.0000, 500.0},
{13011, 1578.6731, -1647.1849, 24.0958, 0.0000, 0.0000, 180.0000, 500.0},
{9339, 1563.9646, -1637.2042, 28.1012, 0.0000, 0.0000, 90.0000, 500.0},
{9339, 1555.9840, -1637.1831, 28.1052, 0.0000, 0.0000, 90.0000, 500.0},
{9339, 1553.6857, -1963.7239, 28.0947, 0.0000, 0.0000, 180.0000, 500.0},
{9339, 1577.7406, -1665.5879, 28.0947, 0.0000, 0.0000, 180.0000, 500.0},
{8674, 1548.3936, -1650.6851, 28.8690, 0.0000, 0.0000, 0.0000, 500.0},
{8674, 1543.2126, -1615.5243, 28.8690, 0.0000, 0.0000, 90.0000, 500.0},
{8674, 1543.2162, -1642.9352, 28.8908, 0.0000, 0.0000, 90.0000, 500.0},
{8674, 1577.8949, -1642.6829, 28.8690, 0.0000, 0.0000, 90.0000, 500.0},
{8674, 1572.4274, -1668.3419, 28.8625, 0.0000, 0.0000, 180.0000, 500.0},
{8674, 1552.9703, -1667.9292, 28.8625, 0.0000, 0.0000, 180.0000, 500.0},
{8673, 1559.9321, -1617.5913, 14.0138, 0.0000, 0.0000, 0.0000, 500.0},
{8674, 1572.5365, -1617.6165, 14.0138, 0.0000, 0.0000, 0.0000, 500.0},
{8674, 1544.9766, -1637.8193, 13.8729, 0.0000, 0.0000, 90.0000, 500.0},
{8674, 1544.8175, -1618.6626, 14.0215, 0.0000, 0.0000, 90.0000, 500.0},
{7933, 1543.7762, -1607.6158, 12.9434, 0.0000, 0.0000, 258.7500, 500.0},
{8167, 1577.1949, -1637.6921, 13.7340, 0.0000, 0.0000, 0.0000, 500.0},
{11547, 1558.1824, -1606.6802, 15.3275, 0.0000, 0.0000, 90.0000, 500.0},
{9314, 2506.1124, -1621.4502, 17.3504, 0.0000, 0.0000, 0.0000, 500.0},
{9833, 1479.7930, -1638.9169, 16.3510, 0.0000, 0.0000, 0.0000, 500.0},
{3686, 1550.0829, -1606.7775, 12.5986, 0.0000, 0.0000, 0.0000, 500.0},
{1686, 1566.3818, -1106.8513, 12.5986, 0.0000, 0.0000, 0.0000, 500.0},
{1686, 1555.6116, -1606.8152, 12.5986, 0.0000, 0.0000, 0.0000, 500.0},
{3686, 1560.8494, -1606.9944, 12.5986, 0.0000, 0.0000, 0.0000, 500.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);