ALL Object delete
#1

Hello i have a problem when i create one object ingame and i delete it its works but when i create 2 object and delete them all the same it doesnt work

Here's the code

Commands :

Код:
dcmd_adobj(playerid,params[])
{
    #pragma unused params
	ShowPlayerDialog(playerid,10000,DIALOG_STYLE_INPUT,"{A80000}Insert Object ID","Insert the object ID that you wan't to create.","Create","Close");
	return 1;
}

dcmd_addeleteobj(playerid,params[])
{
    #pragma unused params
	DestroyDynamicObject(EDIT_OBJECT_ID[playerid]);
	return 1;
}

dcmd_addeleteallobj(playerid,params[])
{
    #pragma unused params
    #pragma unused playerid
	for(new i = 0; i < sizeof(EDIT_OBJECT_ID); i++)
	{
		DestroyDynamicObject(EDIT_OBJECT_ID[i]);

	}
	return 1;
}
DIALOG OF ADOBJ
Код:
	if(dialogid == 10000 && response)
	{
	    if(!Numbers(inputtext)) return SendClientMessage(playerid,COLOR_RED,"Vous ne pouvez que utiliser des nombres."),ShowPlayerDialog(playerid,10000,DIALOG_STYLE_INPUT,"{A80000}Createur d'Objet","Insйrer l'ID de l'objet que vous voulez crйer.","Crйer","Fermer");
	    new Float:editor[3],id;
	    GetPlayerPos(playerid,editor[0],editor[1],editor[2]);
	    id = CreateDynamicObject(strval(inputtext), editor[0]+1, editor[1]+1, editor[2], 0.0,0.0,0.0, -1, -1, -1, 100.0);

		if(id > DEF_MAX_OBJECTS) return SendClientMessageToAll(COLOR_WHITE,"Erreur lors de la crйation de l'objet, il semble que vous essayez de crйer d'autres objets alors le montant maximum est de 5000 objets.");

     	EDITOR_OBJECT[id][OBJ_MODEL] = strval(inputtext);
        EDITOR_OBJECT[id][OBJ_X] = editor[0]+1;
        EDITOR_OBJECT[id][OBJ_Y] = editor[1]+1;
        EDITOR_OBJECT[id][OBJ_Z] = editor[2];
        EDITOR_OBJECT[id][OBJ_RX] = 0.0;
        EDITOR_OBJECT[id][OBJ_RY] = 0.0;
        EDITOR_OBJECT[id][OBJ_RZ] = 0.0;
        EDITOR_OBJECT[id][OBJ_VW] = -1;
        EDITOR_OBJECT[id][OBJ_INTERIOR] = -1;
        EDIT_OBJECT_ID[playerid] = id;
        EditDynamicObject(playerid, id);
 	}
Код:
public OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
{
    EDITOR_OBJECT[objectid][OBJ_X] = x;
    EDITOR_OBJECT[objectid][OBJ_Y] = y;
    EDITOR_OBJECT[objectid][OBJ_Z] = z;
    EDITOR_OBJECT[objectid][OBJ_RX] = rx;
    EDITOR_OBJECT[objectid][OBJ_RY] = ry;
    EDITOR_OBJECT[objectid][OBJ_RZ] = rz;
    SetDynamicObjectPos(objectid,x,y,z);
	SetDynamicObjectRot(objectid,rx,ry,rz);
	return 1;
}
Reply
#2

You mean all the objects created by a playerid get destroyed when he does /addeleteobject ?
Reply
#3

EDIT_OBJECT_ID[] variables need to be two dimensional

new EDIT_OBJECT_ID[MAX_PLAYERS][MAX_EDIT_OBJECTS] = { INVALID_OBJECT_ID, ... };
Reply
#4

Thank you but i dont understand ....
Reply
#5

realy need help !
Reply
#6

You need in EDIT_OBJECT_ID the playerid and object id.

Ex. EDIT_OBJECT_ID[playerid][1] will delete object ID 1 created by player with ID - playerid
Reply
#7

and what whil delete all the object created by all the players
Reply
#8

You need to make two for functions:

Код:
        for(new i = 0; i < MAX_PLAYERS; i++)
	{
                for(new o = 0; o < sizeof(EDIT_OBJECT_ID); o++)
	        {
		         DestroyDynamicObject(EDIT_OBJECT_ID[i][o]);
                }
	}
Reply
#9

Sorry but i have an error

Код:
error 001: expected token: ",", but found "["
Код:
DestroyDynamicObject(EDIT_OBJECT_ID[i][o]);
Reply
#10

Just found out that you make objects like this -> id = CreateDynamicObject....

You can't do it like this because each time you create an object its ID replaces with the previously created object. You need to make a define of MAX_EDIT_OBJECTS and edit new id; to new id[MAX_EDIT_OBJECTS];
When you create an object it should look like this: id[SOME ID] = CreateDynamicObject....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)