Why this isn't working?
#1

I made this to detonate a C4
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_FIRE))
    {
        if(GetPlayerWeapon(playerid) == 40)
        {
            ClearAnimations(playerid);
            ApplyAnimation(playerid,"PED","bomber",4.0,0,0,0,0,1000,1);
            SetTimerEx("Explode", 1200, 0, "i", playerid);
            SetPlayerArmedWeapon(playerid, 0);
            Planted[playerid] = 0;
        }
    }
    return 1;
}
It should work... but it doesn't, it just does nothing, even if the player has the detonator (weapon id 40)
Thanks
Reply
#2

Anyone?
Reply
#3

The remote control is deleted from the players weapons before OnPlayerKeyStatceChange is called, so the player wont have it as active weapon then. You will have to use another key, so it is not deleted, or use a LastWeapon system in OnPlayerUpdate: check if lastweapon[playerid] is 40 and player presses fire key, if yes detonate, if not set lastweapon to the players current weapon (only a short example, not sure if it works exactly that way, im just too lazy to check how i did get it working )
Reply
#4

Yeah, it was easy, I made a global variable, then on player update I got the weapon ID, OnPlayerKeyStateChange I compared the string with the weapon ID, in this case number 40, and got it working.

Thank you very much!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)