[Help] Code not working properly
#1

I got this code

pawn Код:
if(HOLDING(KEY_CROUCH))
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            if(GetPlayerFaction(playerid) == 1)
            {
                new veh = GetPlayerVehicleID(playerid);
                if(VehicleInfo[veh][vFaction] == 1 && GetVehicleModel(veh) == 467)
                {
                    if(VehicleInfo[veh][vObjSet] == 1)
                    {
                        DestroyObject(VehicleInfo[veh][vObj]);
                        VehicleInfo[veh][vObjSet] = 0;
                    }
                    else
                    {
                        VehicleInfo[veh][vObjSet] = 1;
                        VehicleInfo[veh][vObj] = CreateObject(18646, 0, 0, 0, 0, 0, 0);
                        AttachObjectToVehicle(VehicleInfo[veh][vObj], veh, 0, 0, 0.90, 0, 0, 0);
                    }
                }
               
            }
        }
    }
When I'm holding the button, it works fine at the first time, the object is being attached and vObjSet is 1!.
When I'm holding the button again it creates the object and attaches it again.
It counts vObjSet as 0.

What's wrong with the code? I can't see anything wrong here.
Reply
#2

Bump.
4char
Reply
#3

Your Code is in the wrong house foo.
Reply
#4

No, its not.
Reply
#5

Destroy the object, then add it again. Simple. when you hit the b utton, create it, if pressed again, delete it. then add it.
Reply
#6

What the hell are you talking about it?
Can't you see the statement vObjSet ?
if its 1 it will remove, if its 0 it will add it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)