Jump to content

problema DestroyObject


Recommended Posts

    Ok, am vrut sa fac un sistem de spike uri pentru politisti. Problema este ca nu i se da remove. Un solve va rog??

 

if (strcmp("/pdspikes", cmdtext, true, 10) == 0)
    {
        new Float:Pos[4];
        GetPlayerPos(playerid, Pos[0],Pos[1],Pos[2]);
        GetPlayerFacingAngle(playerid, Pos[3]);
        SendClientMessage(playerid, 0xF31C2B, "*Succesfully Placed Spike*");
        GameTextForPlayer(playerid,"~r~Police Spike ~n~~b~Spike Deployed!",3000,4);
        CreateDynamicObject(2899, Pos[0],Pos[1],Pos[2]-0.9, 00.00,  00.00,  Pos[3]+90);
        return 1;
    }
    if (strcmp("/removepdspikes", cmdtext, true, 10) == 0)
// Problema
    {
        new Float:Pos[4];
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, Pos[0],Pos[1],Pos[2]);
        GetPlayerFacingAngle(playerid, Pos[3]);
        SendClientMessage(playerid, 0xF31C2B, "*Succesfully Removed Spike*");
        GameTextForPlayer(playerid,"~r~Police Spike ~n~~b~Spike Removed!",3000,4);
        GetObjectPos(2899, x, y, z);
        DestroyDynamicObject(2899);
        return 1;
    }

Link to comment
Share on other sites

Nu trebuie sa dai destroy la id-ul obiectului in sine, ci la id-ul lui de pe server, adica al catelea a fost creat pe server (ca la vehicule).

Ai putea sa faci ceva de genul (dar asta va functiona pentru un singur spike per player):


new Spike[MAX_PLAYERS];

if (strcmp("/pdspikes", cmdtext, true, 10) == 0)
{

        if(Spike[playerid] > 0) return SendClientMessage(playerid, -1, "Ai creat deja un Spike!");
        new Float:Pos[4];
        GetPlayerPos(playerid, Pos[0],Pos[1],Pos[2]);
        GetPlayerFacingAngle(playerid, Pos[3]);
        SendClientMessage(playerid, 0xF31C2B, "*Succesfully Placed Spike*");
        GameTextForPlayer(playerid,"~r~Police Spike ~n~~b~Spike Deployed!",3000,4);
        Spike[playerid] = CreateDynamicObject(2899, Pos[0],Pos[1],Pos[2]-0.9, 00.00,  00.00,  Pos[3]+90);
        return 1;
    }


    if (strcmp("/removepdspikes", cmdtext, true, 10) == 0)
    {

        if(Spike[playerid] == 0)  return SendClientMessage(playerid, -1, "Nu ai creat nici un Spike!");
        SendClientMessage(playerid, 0xF31C2B, "*Succesfully Removed Spike*");
        GameTextForPlayer(playerid,"~r~Police Spike ~n~~b~Spike Removed!",3000,4);
        DestroyDynamicObject(Spike[playerid]), 
Spike[playerid] = 0;
        return 1;
    }

Edited by Akan
  • Thanks 1

Discord:
! Akan !#6675

Link to comment
Share on other sites

20 hours ago, Akan said:

Nu trebuie sa dai destroy la id-ul obiectului in sine, ci la id-ul lui de pe server, adica al catelea a fost creat pe server (ca la vehicule).

Ai putea sa faci ceva de genul (dar asta va functiona pentru un singur spike per player):


new Spike[MAX_PLAYERS];

if (strcmp("/pdspikes", cmdtext, true, 10) == 0)
{

        if(Spike[playerid] > 0) return SendClientMessage(playerid, -1, "Ai creat deja un Spike!");
        new Float:Pos[4];
        GetPlayerPos(playerid, Pos[0],Pos[1],Pos[2]);
        GetPlayerFacingAngle(playerid, Pos[3]);
        SendClientMessage(playerid, 0xF31C2B, "*Succesfully Placed Spike*");
        GameTextForPlayer(playerid,"~r~Police Spike ~n~~b~Spike Deployed!",3000,4);
        Spike[playerid] = CreateDynamicObject(2899, Pos[0],Pos[1],Pos[2]-0.9, 00.00,  00.00,  Pos[3]+90);
        return 1;
    }


    if (strcmp("/removepdspikes", cmdtext, true, 10) == 0)
    {

        if(Spike[playerid] == 0)  return SendClientMessage(playerid, -1, "Nu ai creat nici un Spike!");
        SendClientMessage(playerid, 0xF31C2B, "*Succesfully Removed Spike*");
        GameTextForPlayer(playerid,"~r~Police Spike ~n~~b~Spike Removed!",3000,4);
        DestroyDynamicObject(Spike[playerid]), 
Spike[playerid] = 0;
        return 1;
    }

multumesc mult bro, solved

Link to comment
Share on other sites

  • Mister locked this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.