Az
xObject-hez csak egy fs kell, vagy a módba is tehet
#include <a_samp>
forward Timer();
forward SetPlayerPosWithObjects(playerid,Float:x,Float:y,Float:z);
enum object_info
{
modelid,
Float:ox,
Float:oy,
Float:oz,
Float:orx,
Float:ory,
Float:orz,
Float:viewdist
}
new Objects[][object_info] = {
//objectek, xobject formátumba, az utolsohoz nem kell vesszo (,) !
};
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[view]
{
Player[view]
DestroyPlayerObject(i,Player[objid]
}
}
}
KillTimer(timer);
}
//------------------------------------------------------------------------------
public OnPlayerConnect(playerid)
{
for(new i = 0; i < sizeof(Objects); i++) Player[playerid][view] = false;
}
public OnPlayerDisconnect(playerid)
{
for(new i = 0; i < sizeof(Objects); i++)
{
if(Player[playerid][view])
{
Player[playerid][view] = false;
DestroyPlayerObject(playerid,Player[playerid][objid]);
}
}
}
//------------------------------------------------------------------------------
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])
{
if(IsInReach(pos[0],pos[1],pos[2],Objects[ox],Objects[oy],Objects[oz],Objects[viewdist]))
{
Player[playerid][view] = true;
Player[playerid][objid] = CreatePlayerObject(playerid,Objects[modelid],Objects[ox],Objects[oy],Objects[oz],Objects[orx],Objects[ory],Objects[orz]);
}
} else if(!IsInReach(pos[0],pos[1],pos[2],Objects[ox],Objects[oy],Objects[oz],Objects[viewdist]))
{
Player[playerid][view] = false;
DestroyPlayerObject(playerid,Player[playerid][objid]);
}
}
}
public SetPlayerPosWithObjects(playerid,Float:x,Float:y,Float:z)
{
for(new i = 0; i < sizeof(Objects); i++)
{
if(!Player[playerid][view])
{
if(IsInReach(x,y,z,Objects[ox],Objects[oy],Objects[oz],Objects[viewdist]))
{
Player[playerid][view] = true;
Player[playerid][objid] = CreatePlayerObject(playerid,Objects[modelid],Objects[ox],Objects[oy],Objects[oz],Objects[orx],Objects[ory],Objects[orz]);
}
} else if(!IsInReach(x,y,z,Objects[ox],Objects[oy],Objects[oz],Objects[viewdist]))
{
Player[playerid][view] = false;
DestroyPlayerObject(playerid,Player[playerid][objid]);
}
}
SetPlayerPos(playerid,Float:x,Float:y,Float:z);
}
public OnPlayerSpawn(playerid)
PlayerObjectUpdate(playerid);
Y_Object letöltése: www.gergo222.extra.hu/Y_Object.rar Y_Object használata:Szkript mód elejére:
#include <Y_Objects>
OnPlayerDisconnect() függvény.-hez:
Object_OnPlayerDisconnect(playerid, reason);
És add hozzá az OnPlayerDisconnect() függvény paramétereihez a \"reason\" szót, tehát:
public OnPlayerDisconnect(playerid, reason)
{
Object_OnPlayerDisconnect(playerid, reason);
return 1;
}
OnGameModeInit(), ha mód, OnFilterScriptInit(), ha szkript:
Object_Object();
//ide jöhetnek az objectek YSI object formátumba
xStreamer: Onnan lehet letölteni, amit Depi az elozo hsz-ba leírt. És az elején beágyazod (#include <xStreamer>) és CreateObject formátumba teszed be az objecteket stb., de keress rá bovebben a hív. fórumon.