01.06.2014, 14:11
You need to look deeper into your statements. Currently you are doing:
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 Код:
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.
}
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;
}