Command PD1 help
#1

I have created this command but i want it so i can also destroy the attached object within the same command any idea how would i do this?

Код:
CMD:pd1(playerid, params[])
{
	if (GetFactionType(playerid) != FACTION_POLICE)
	    return SendErrorMessage(playerid, "You are not a police officer.");

	new vehicleid = GetPlayerVehicleID(playerid);

	if (!IsPlayerInAnyVehicle(playerid))
	    return SendErrorMessage(playerid, "You must be inside a vehicle.");

	new g_Object[2];
	new g_Vehicle[1];
	g_Object[0] = CreateObject(19419, 1252.6768, -1320.4995, 13.6476, 0.0000, 0.0000, 0.0000); //police_lights01
	g_Object[1] = CreateObject(19419, 1059.0290, -1580.8629, 10.8403, 0.0000, 0.0000, 0.0000); //police_lights01
	//g_Vehicle[0] = CreateVehicle(596, 1060.4080, -1576.1466, 13.0340, 84.4289, 0, 1, -1); //Police Car (LSPD)
	AttachObjectToVehicle(g_Object[0], g_Vehicle[0], 0.0000, 2.4000, 0.0000, 0.0000, 0.0000, 0.0000);
	AttachObjectToVehicle(g_Object[1], g_Vehicle[0], 0.0000, -2.0000, 0.0000, 0.0000, 0.0000, 0.0000);
	return 1;
}
Reply
#2

Something like this
pawn Код:
enum some
{
     bool:flag,
     obj1,
     obj2
};
new obj[MAX_PLAYERS][some];

CMD:pd1(playerid, params[])
{
    if (GetFactionType(playerid) != FACTION_POLICE)
        return SendErrorMessage(playerid, "You are not a police officer.");

   

    if (!IsPlayerInAnyVehicle(playerid))
        return SendErrorMessage(playerid, "You must be inside a vehicle.");
    new vehicleid = GetPlayerVehicleID(playerid);
    if(obj[playerid][flag] == true)
    {
        DestroyObject(obj[playerid][obj1]);
        DestroyObject(obj[playerid][obj2]);
        obj[playerid][flag] = false;
        return 1;
    }
   
    obj[playerid][obj1] = CreateObject(19419, 1252.6768, -1320.4995, 13.6476, 0.0000, 0.0000, 0.0000); //police_lights01
    obj[playerid][obj2] = CreateObject(19419, 1059.0290, -1580.8629, 10.8403, 0.0000, 0.0000, 0.0000); //police_lights01
    //g_Vehicle = CreateVehicle(596, 1060.4080, -1576.1466, 13.0340, 84.4289, 0, 1, -1); //Police Car (LSPD)
    AttachObjectToVehicle(obj[playerid][obj1], vehicleid, 0.0000, 2.4000, 0.0000, 0.0000, 0.0000, 0.0000);
    AttachObjectToVehicle(obj[playerid][obj2], vehicleid, 0.0000, -2.0000, 0.0000, 0.0000, 0.0000, 0.0000);
    obj[playerid][flag] = true;
    return 1;
}

//under on player disconnect -
 if(obj[playerid][flag] == true)
    {
        DestroyObject(obj[playerid][obj1]);
        DestroyObject(obj[playerid][obj2]);
        obj[playerid][flag] = false;
    }
Reply
#3

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
Something like this
pawn Код:
enum some
{
     bool:flag,
     obj1,
     obj2
};
new obj[MAX_PLAYERS][some];

CMD:pd1(playerid, params[])
{
    if (GetFactionType(playerid) != FACTION_POLICE)
        return SendErrorMessage(playerid, "You are not a police officer.");

   

    if (!IsPlayerInAnyVehicle(playerid))
        return SendErrorMessage(playerid, "You must be inside a vehicle.");
    new vehicleid = GetPlayerVehicleID(playerid);
    if(obj[playerid][flag] == true)
    {
        DestroyObject(obj[playerid][obj1]);
        DestroyObject(obj[playerid][obj2]);
        obj[playerid][flag] = false;
        return 1;
    }
   
    obj[playerid][obj1] = CreateObject(19419, 1252.6768, -1320.4995, 13.6476, 0.0000, 0.0000, 0.0000); //police_lights01
    obj[playerid][obj2] = CreateObject(19419, 1059.0290, -1580.8629, 10.8403, 0.0000, 0.0000, 0.0000); //police_lights01
    //g_Vehicle = CreateVehicle(596, 1060.4080, -1576.1466, 13.0340, 84.4289, 0, 1, -1); //Police Car (LSPD)
    AttachObjectToVehicle(obj[playerid][obj1], vehicleid, 0.0000, 2.4000, 0.0000, 0.0000, 0.0000, 0.0000);
    AttachObjectToVehicle(obj[playerid][obj2], vehicleid, 0.0000, -2.0000, 0.0000, 0.0000, 0.0000, 0.0000);
    obj[playerid][flag] = true;
    return 1;
}

//under on player disconnect -
 if(obj[playerid][flag] == true)
    {
        DestroyObject(obj[playerid][obj1]);
        DestroyObject(obj[playerid][obj2]);
        obj[playerid][flag] = false;
    }
Hell yea man thank's pal. +REP

Beta testers fault.
Код:
This forum requires that you wait 120 seconds between posts. Please try again in 5 seconds.
Oh shit also i made it so it's only for the Copcarla but am pretty sure this is gonna work for all vehicles any idea about that?
Reply
#4

Player Variables.

edit: whoops.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)