26.03.2011, 21:26
I got this code
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.
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 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.