SA-MP Forums Archive
[Help] Code not working properly - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Help] Code not working properly (/showthread.php?tid=244309)



[Help] Code not working properly - Maxips2 - 26.03.2011

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.


Re: [Help] Code not working properly - Maxips2 - 29.03.2011

Bump.
4char


Re: [Help] Code not working properly - -Rebel Son- - 29.03.2011

Your Code is in the wrong house foo.


Re: [Help] Code not working properly - Maxips2 - 29.03.2011

No, its not.


Re: [Help] Code not working properly - -Rebel Son- - 29.03.2011

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


Re: [Help] Code not working properly - Maxips2 - 29.03.2011

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.