28.04.2013, 18:11
(
Последний раз редактировалось Ananisiki; 15.12.2013 в 18:36.
)
^^^^^^^^
#define MAX_DYN_OBJECTS 1000
enum ObjectInfo {
ObjectID,
Float:ox,
Float:oy,
Float:oz,
Float:rx,
Float:ry,
Float:rz
}
new Objects[MAX_DYN_OBJECTS][ObjectInfo];
new PlayerObject[MAX_PLAYERS] = { INVALID_OBJECT_ID, ...};
// Make sure you initialize the objectids
public OnFilterScriptInit()
{
for(new = 0; i < MAX_DYN_OBJECTS; i++) { Objects[i][ObjectID] = INVALID_OBJECT_ID; }
}
AddObject(oid, Float:ox, Float:oy, Float:oz, Float:rx, Float:ry, Float:rz)
{
for(new i = 0; i < MAX_DYN_OBJECTS; i++)
{
if(Objects[i][ObjectID] == INVALID_OBJECT_ID)
{
Objects[i][ObjectID] = CreateDynamicObject(oid, ox, oy, oz, rx, ry, rz);
return i;
}
}
return INVALID_OBJECT_ID;
}
RemoveObject(oindex)
{
if(Objects[oindex][ObjectID] != INVALID_OBJECT_ID)
{
DestroyDynamicObject(Objects[oindex][ObjectID]);
Objects[oindex][ObjectID] = INVALID_OBJECT_ID;
return 1;
}
return 0;
}
PlayerObject[playerid] = AddObject(1334, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
Objects[PlayerObject[playerid]][ObjectID]
DeleteAllObjects()
{
new deletecount;
for(new i = 0; i < MAX_DYN_OBJECTS; i++)
{
if(Objects[i][ObjectID] == INVALID_OBJECT_ID) continue;
DestroyDynamicObject(Objects[i][ObjectID]);
Objects[i][ObjectID] = INVALID_OBJECT_ID;
deletecount++;
}
for(new i = 0; i < MAX_PLAYERS; i++) { PlayerObject[i] = INVALID_OBJECT_ID; }
if(deletecount) return 1;
return 0;
}