Posts: 547
Threads: 57
Joined: Dec 2010
Quote:
Originally Posted by Threshold
Your code won't work because you are using 'if' instead of 'else if'. It would work like this:
pawn Код:
new variable = 0; if(variable == 0) //Gets called because variable is equal to 0 { variable = 1; //variable is now equal to 1 } else //Gets called because variable is no longer equal to 0 { variable = 0; //variable is equal to 0 again, nothing changes. }
One solution is to use 'else if' rather than and 'if' statement. Or you can use the following code:
pawn Код:
CMD:lock(playerid, params[]) { if(!GetPVarInt(playerid, "LoggedIn")) return SendClientMessage(playerid, COLOR_RED, "[ERROR]: You need to be logged in to use this command."); for(new i = 0; i < MAX_HOUSES; i++) { if(!fexist(HousePath(i))) continue; if(IsPlayerInRangeOfPoint(playerid, 2, House[i][ExtPosX], House[i][ExtPosY], House[i][ExtPosZ]) || IsPlayerInRangeOfPoint(playerid, 2, House[i][IntPosX], House[i][IntPosY], House[i][IntPosZ])) { if(Player[playerid][HouseID] != House[i][hID]) return SendClientMessage(playerid, COLOR_GREY, "You don't own this house."); new string[60]; ApplyAnimation(playerid, "BD_FIRE", "wash_up", 4.0, 0, 0, 0, 0, 1); format(string, sizeof(string), (House[i][hLocked]) ? (" * %s unlocks the door to the house.") : (" * %s locks the door to the house."), GetName(playerid)); SetPlayerChatBubble(playerid, string, COLOR_LIGHTPURPLE, 10, 7000); SendClientMessage(playerid, COLOR_LIGHTPURPLE, string); House[i][hLocked] = (House[i][hLocked]) ? (0) : (1); break; } } return 1; }
|
It's not that the command doesn't work, it works as intended functionally, but the animation won't play no matter what I try.