Posts: 29
Threads: 5
Joined: Oct 2012
Reputation:
0
You are checking if the object is valid/invalid using a fuction from Incognito's streamer plugin but you are creating and destroying the objects using the default sa:mp natives.
To fix this problem you must either check if the object is valid/invalid using the sa:mp native function or use Incognito's streamer plugin to create and destroy the object.
Posts: 1,167
Threads: 57
Joined: Jul 2010
Reputation:
0
at top of the script add
new Object[MAX_PLAYERS] = {-1,...};
Then when you destroy an object, set object handle to -1 and dont use IsValid... object, but just check if Object[playerid] is -1, and if it is, object is destroyed. otherwise destroy and set it to -1, this is how you MUST do to keep it in order, cuz IsValidDynamicObject doesnt actually check if its right object, it just check if object with such a handle is created at all.
Posts: 1,266
Threads: 6
Joined: Oct 2014
change this
PHP код:
forward Destroy(playerid);
public Destroy(playerid)
{
DestroyObject(Object[playerid]);
}
to
PHP код:
forward Destroy(playerid);
public Destroy(playerid)
{
DestroyObject(Object[playerid]);
Object[playerid] = INVALID_OBJECT_ID;
}
Posts: 1,208
Threads: 36
Joined: Apr 2015
you need glasses :P
Код:
CMD:obj(playerid)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x,y,z);
if(!IsValidDynamicObject(Object[playerid]))
{
Object[playerid]=CreateObject(866, x, y, z, 0, 0,0, 50);
SetTimerEx("Destroy", 2000, false, "i", playerid);
}
return 1;
}
forward Destroy(playerid);
public Destroy(playerid)
{
DestroyObject(Object[playerid]);
}