Helmet bug
#6

You need to look deeper into your statements. Currently you are doing:
pawn Код:
if(var == 1) //var must be '1' to proceed.
{
    SetPlayerAttachedObject(...
    var = 0; //var is now 0.
}
else //var is NOT '1' at this point to proceed. Because var is now '0', this will now be continued.
{
    RemovePlayerAttachedObject(...
    var = 1; //var is now 1.
}
In order to resolve this, you simply change 'else' to 'else if(var == 0)'. Read here: https://sampwiki.blast.hk/wiki/Control_Structures#else

The correct code:
pawn Код:
CMD:kask(playerid,params[])
{
    if(!AracMotorsa(GetPlayerVehicleID(playerid))) return SendClientMessage(playerid, COLOR_YELLOW2, "{FF0000}(( {00FF00}[HATA]: {FFFFFF}Bu komut sadece motorlarda ve bisikletlerde зalisir. {FF0000} ))");
    new string[50], hname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, hname, sizeof(hname);
    if(!KaskTakili[playerid])
    {
        SetPlayerAttachedObject(playerid, 1, 18977, 2, 0.07, 0, 0, 88, 75, 0);
        format(string,sizeof(string),"*%s kaskini takar.",string);
    }
    else if(KaskTakili[playerid])
    {
        RemovePlayerAttachedObject(playerid, 1);
        format(string,sizeof(string),"*%s kaskini зikartir.",string);
    }
    KaskTakili[playerid] = (KaskTakili[playerid]) ? (0) : (1);
    ProxDetector(30.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    return 1;
}
Reply


Messages In This Thread
Helmet bug - by Rufio - 01.06.2014, 12:52
Re: Helmet bug - by Drago987 - 01.06.2014, 12:56
Re: Helmet bug - by Rufio - 01.06.2014, 12:58
Re: Helmet bug - by Drago987 - 01.06.2014, 13:05
Re: Helmet bug - by Rufio - 01.06.2014, 13:12
Re: Helmet bug - by Threshold - 01.06.2014, 14:11

Forum Jump:


Users browsing this thread: 2 Guest(s)