Need little help in this code
#1

Is there anyway for me to add freezetime in this code for 10sec, when finish, it will unfreeze the player and clear player's animation ? Help me please :d
PHP код:
CMD:datbanhlenxe(playeridparams[])
{
    if(
IsPlayerInAnyVehicle(playerid)) return SendClientMessageEx(playeridCOLOR_GREY"Ban khong the lam dieu do vao luc nay.");
    if(
PlayerInfo[playerid][pRFLTeam] == 0)
    {
        
SendClientMessageEx(playerid,COLOR_GREY," Ban chua nau banh pizza !");
    }
    else
    {
        new 
closestcar GetClosestCar(playerid);
        if(
IsPlayerInRangeOfVehicle(playeridclosestcar10.0))
        {
            if(!
IsABike(closestcar))
            {
                
SendClientMessageEx(playerid,COLOR_GREY," Ban khong gan mot chiec xe nao do !");
            }
            if(
PlayerInfo[playerid][pRFLTeam] == 1)
            {
            
PlayerInfo[playerid][pFallIntoFun] = 1;
            
SendClientMessageEx(playerid,COLOR_YELLOW," Ban dang dua banh len xe , vui long cho");
            
ApplyAnimation(playerid"BOMBER""BOM_Plant"4.0000001);
            }
          }
        }
        return 
1;

Reply
#2

Use TogglePlayerControllable to freeze the player, then SetTimerEx to create a timer, in the timer use TogglePlayerControllable again and unfreeze the player.
Reply
#3

I knew it, but i didnt know how to add, so i come here
Reply
#4

This will set a timer of 10 seconds where he will be frozen:
pawn Код:
forward FreezeTimer(playerid);
public FreezeTimer(playerid) return TogglePlayerControllable(playerid, 1); // Makes the public function "FreezeTimer" unfreeze the player

CMD:datbanhlenxe(playerid, params[])
{
    if(IsPlayerInAnyVehicle(playerid)) return SendClientMessageEx(playerid, COLOR_GREY, "Ban khong the lam dieu do vao luc nay.");
    if(PlayerInfo[playerid][pRFLTeam] == 0)
    {
        SendClientMessageEx(playerid,COLOR_GREY," Ban chua nau banh pizza !");
    }
    else
    {
        new closestcar = GetClosestCar(playerid);
        TogglePlayerControllable(playerid, 0); // Freezes the player
        SetTimerEx("FreezeTimer", 10000, false, "i", playerid); // Sets the timer, using the public function "FreezeTimer"
        if(IsPlayerInRangeOfVehicle(playerid, closestcar, 10.0))
        {
            if(!IsABike(closestcar))
            {
                SendClientMessageEx(playerid,COLOR_GREY," Ban khong gan mot chiec xe nao do !");
            }
            if(PlayerInfo[playerid][pRFLTeam] == 1)
            {
                PlayerInfo[playerid][pFallIntoFun] = 1;
                SendClientMessageEx(playerid,COLOR_YELLOW," Ban dang dua banh len xe , vui long cho");
                ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0, 1);
            }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)