[HELP] It won't unfreeze player
#1

So I have in public fuelcheck when fuel of some vehicle reach 0 then it send to player there's no fuel left in vehicle press button Y to exit and of course it freeze player and I set NoFuel{i} = 1;

then in onplayerkeystatechange I have

pawn Код:
if(newkeys & KEY_YES)
{
if(NoFuel{playerid} == 1)
{
TogglePlayerControllable(playerid,1);//it should unfreeze player when he is pressed button y but the player is removed from vehicle and still remain frozen and if I again for second time press Y then the player is unfreezed.
RemovePlayerFromVehicle(playerid);
NoFuel{playerid} = 0;
}
}
Reply
#2

RemovePlayerFromVehicle(playerid); TRy without this
Reply
#3

if I remove it how then will player be removed from vehicle.
Reply
#4

Just try to use it, and check the player unfreeze or not.
Reply
#5

Try to add a timer of 2/3 seconds to TogglePlayerControllable and first he will be removed from the vehicle then unfreezed from the timer
Reply
#6

Here's a quick recreation:

pawn Код:
// ** INCLUDES

#include <a_samp>
#include <zcmd>

// ** DEFINES

// *** KEY SIMULATIONS

#define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

// ** VARIABLES

// *** PER-PLAYER VARIABLES

// **** GLOBAL

new bool:pNoFuel[MAX_PLAYERS] = false;

// ** MAIN

main()
{
    print("Loaded \"no_fuel_key.amx\".");
}

// ** CALLBACKS

public OnGameModeInit()
{
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_YES))
    {
        if(pNoFuel[playerid])
        {
            TogglePlayerControllable(playerid, true);
            RemovePlayerFromVehicle(playerid);

            pNoFuel[playerid] = false;
        }
    }
    return 1;
}

// ** COMMANDS

CMD:nofuel(playerid, params[])
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "You must be inside a vehicle to use this command.");
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1, "You must be driving the vehicle to use this command.");

    if(!pNoFuel[playerid])
    {
        TogglePlayerControllable(playerid, false);

        pNoFuel[playerid] = true;
    }
    else
    {
        TogglePlayerControllable(playerid, true);

        pNoFuel[playerid] = false;
    }
    return 1;
}
Reply
#7

have u debugged this ?
And just an idea
why not just turn off the engine instead of freezing the player ?
https://sampwiki.blast.hk/wiki/SetVehicleParamsEx
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)