Is it possible to create an object when you do a command?
#1

Im wondering if it is possible to create an object and put a timer that it will dissapear after lets say 30 seconds? and in that case how can i make it?
This is the command i want to put out an object but im not sure how i can make it and also i dont know how to make it with timer so please help me with this.
pawn Код:
if(strcmp(cmd, "/refillarmory", true) == 0)
    {
        if(PlayerInfo[playerid][pJob] == 16)
        {
            if(PlayerInfo[playerid][pArmoryrefill] == 1)
            {
                new tmpcar = GetPlayerVehicleID(playerid);
                if(IsPlayerInRangeOfPoint(playerid, 15, 1567.2455,-1691.3341,5.8906))
                {
                    if(GetVehicleModel(tmpcar) == 433 || GetVehicleModel(tmpcar) == 440 || GetVehicleModel(tmpcar) == 514 || GetVehicleModel(tmpcar) == 428 || GetVehicleModel(tmpcar) == 403 || GetVehicleModel(tmpcar) == 515)
                    {
                        SendClientMessage(playerid, TEAM_GROVE_COLOR, "You have delivered the armory equipment to the Police Department");
                        SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "* You have been rewarded with 2.500.");
                        PlayerInfo[playerid][pArmoryrefill] = 0;
                        SafeGivePlayerMoney(playerid, 2500);
                        Armory[ARMOUR] = 15;
                        Armory[MP5] = 20;
                        Armory[SHOTGUN] = 20;
                        Armory[SHIELD] = 15;
                        CreateDynamicObject(3066,-69.5999985,-1124.6999512,1.1000000,0.0000000,0.0000000,65.5000000);
//Can i do it like this, and then just put a timer to remove it after 30 seconds?
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GREY, "You can't load with this vehicle!");
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "You are NOT at the Armory loading place!");
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "You dont have any armory equipment in your car");
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "You are not a Trucker!");
        }
        return 1;
    }
Reply
#2

pawn Код:
new TemporaryID = CreateDynamicObject(3066,-69.5999985,-1124.6999512,1.1000000,0.0000000,0.0000000,65.5000000);
SetTimerEx("RemoveObject",30*1000,false,"d",TemporaryID);

Somewhere

pawn Код:
forward RemoveObject(objectid);
public RemoveObject(objectid)
{

    if(IsValidDynamicObject(objectid))
        DestroyDynamicObject(objectid);

    return 1;
}
Reply
#3

so i put this
pawn Код:
new TemporaryID = CreateDynamicObject(3066,-69.5999985,-1124.6999512,1.1000000,0.0000000,0.0000000,65.5000000);
SetTimerEx("RemoveObject",30*1000,false,"d",TemporaryID);
where it putted this?
pawn Код:
CreateDynamicObject(3066,-69.5999985,-1124.6999512,1.1000000,0.0000000,0.0000000,65.5000000);
Reply
#4

Technically "TemporaryID" should be declared outside of the function where you're creating the object since it's being used at another location in the mode.

pawn Код:
new TemporaryID; // put this near the top of your mode
Then put the following where you're making the object in your command:

pawn Код:
TemporaryID = CreateDynamicObject(3066,-69.5999985,-1124.6999512,1.1000000,0.0000000,0.0000000,65.5000000);
SetTimerEx("RemoveObject",30*1000,false,"d",TemporaryID);
Reply
#5

Ah ok, Is it also possible to do exact same thing exept that the object is allways there but when i type the command it removes the object for 30 seconds and after 30 seconds it comes back?
Reply
#6

Yeah. When yo call the timer just destroy the object and when the timer actually executes (30 seconds later) create the object.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)