Destroy Object help
#1

pawn Код:
//Lightbar Lighting CMD
CMD:lightflashonwe(playerid,params[]){//                    admin
    if(GetPVarInt(playerid,"Lights")>0)
    {
        SetPVarInt(playerid,"Lights",0);
        if(IsValidObject(GetPVarInt(playerid,"Siren1")))
        {
            DestroyObject(GetPVarInt(playerid,"Siren1"));
            SendClientMessage(playerid, COLOR_LIGHTBLUE,"[INFO]Lightbar lighting deactivated");
        }
        if(IsValidObject(GetPVarInt(playerid,"Siren2")))
        {
            DestroyObject(GetPVarInt(playerid,"Siren2"));
        }
    }
    else
    {
        SetPVarInt(playerid,"Lights",1);
        SetPVarInt(playerid,"OB1",CreateObject(18646,0,0,0,0,0,0,200));
        SetPVarInt(playerid,"OB2",CreateObject(18646,0,0,0,0,0,0,200));
        AttachObjectToVehicle(GetPVarInt(playerid,"OB1"),GetPlayerVehicleID(playerid),-0.4000,-0.2000,0.8500,0.0000,0.0000,0.0000);
        AttachObjectToVehicle(GetPVarInt(playerid,"OB2"),GetPlayerVehicleID(playerid),00.4000,-0.2000,0.8500,0.0000,0.0000,0.0000);
    }
    return 1;
}
All works fine but when i exit a vehicle the objets got removed, how i can let them remain until I re type /Lightflashon +REP
Reply
#2

The reason is because you did
pawn Код:
GetPlayerVehicleID
Try to make the vehicles in a variable then try to see
Reply
#3

Sorry coulf you post a example?
Reply
#4

Well something like this in your script
pawn Код:
new mycar[MAX_PLAYERS];
mycar[playerid] = GetPlayerVehicleID(playerid);
        AttachObjectToVehicle(GetPVarInt(playerid,"OB1"),mycar[playerid],-0.4000,-0.2000,0.8500,0.0000,0.0000,0.0000);
        AttachObjectToVehicle(GetPVarInt(playerid,"OB2"),mycar[playerid],00.4000,-0.2000,0.8500,0.0000,0.0000,0.0000);
i think maybe this will work or not
Reply
#5

Not work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)