Object cmd problem
#1

So, if i add a few objects and do /deleteobject 1

after i delete this one and add another object, it is supposed to spawn as id 1 since i removed it, but it is getting created as a id that already excists, so multiple ids so when i remove one object the other one is still there....
pawn Код:
CMD:deleteobject(playerid, params[])
{
    new objectid;
    if(IsPlayerEditingObject[playerid] == 1) CancelEdit(playerid);
    if(PlayerObjectCount[playerid] == 0 ) return SendClientMessage(playerid, COLOR_RED, "Invalid Object ID.");
    if(!IsValidDynamicObject(PlayerObject[playerid][objectid]) || objectid < 1) return SendClientMessage(playerid, COLOR_RED, "Invalid Object Editing ID.");
    DestroyDynamicObject(PlayerObject[playerid][objectid]);
    PlayerObject[playerid][objectid] = INVALID_OBJECT_ID;
    PlayerObjectCount[playerid]--;
    return 1;
}
Reply
#2

pawn Код:
new objectid = strval(params);
Reply
#3

SAme....
Reply
#4

Bump
Reply
#5

Bump
Reply
#6

i cant understand what u are trying to say can u explain in more detail maybe with pics
Reply
#7

When i add , lets say 5 objects, they all get a different object editing id, but if i delete number 1, 2, 3 or 4 and after that i add another object, the newest object i've added gets the same id as 5 so there are two objects as 5 and when i delete them all one is left there
Reply
#8

Bump
Reply
#9

Bump
Reply
#10

Dynamic object has global id, as it's streamed for all players in the server. you can't make the id to per-player dynamic object.
In this case, you have to figure out by yourself by changing the way you create variable for a player (if that's mean the dynamic object creator). You have to flip the playerid to objectid, but i think you should use player name instead, because id will always change, but you can still use playerid if the dynamic object also destroyed when the player left the server, and you reset the variable.
What i mean is like this:
pawn Код:
PlayerObject[playerid][objectid]
to this:
pawn Код:
DynamicObject[objectid][playerid]
so we make the playerid as the objectid's property (same goes to the Position, Rotation, etc)
Please read this thread how to manipulate the dynamic object data directly, since you can't just assign with your own variable:
https://sampforum.blast.hk/showthread.php?tid=102865

If that's not what you mean, and you are just having problem with the id, you have to show us the code where you define the variable (as the objectid) and how you modify it, because it might be the reason (you are just showing when you delete it, not when created, modified)

I am sorry that i couldn't help you much since i don't know about dynamic objects at all and you didn't provide us some other code or what you want to do with it
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)