Detecting Fighting
#5

Here is a quick tutorial.


pawn Код:
new bool:IsFighting[MAX_PLAYERS] = false; // Sets a bool for each player and sets it to false automatically.

public OnPlayerGiveDamage(playerid,damageid,Float:amount,weaponid)
{
    if(playerid != INVALID_PLAYER_ID || damageid != INVALID_PLAYER_ID) // If both the players are online then
    {
        IsFighting[playerid] = true; // It sets their is fighting bool to true.
        // Now since they are fighting we are gonna need a cool down timer sow that they can use TP commands again.
        SetTimer("CanTeleport",30000,false); // Sets a timer of 30 seconds.
        return 1;
    }
    return 1;
}
forward CanTeleport(playerid);
public CanTeleport(playerid) // When that 30 seconds is up..
{
    IsFighting[playerid] = false; // Then make it so they can telelport again.
    return 1;
}

// Now let's make a command.

CMD:teleport(playerid,params[])
{
    if(IsFighting[playerid] == true) // If the player has fought within the last 30 seconds.
    {
        SendClientMessage(playerid,-1,"You are currently fighting an enemy and cannot teleport!");
        return 1;
    }
    else // If they are NOT fighting then it teleports them
    {
        SetPlayerPos(playerid,x,y,z); // You put your coordinates here
        SendClientMessage(playerid,-1,"You have teleported.");
        return 1;
    }
    return 1;
}
I hope you understood! Goodluck!
Reply


Messages In This Thread
Detecting Fighting - by FreshRio - 12.03.2012, 10:29
Re: Detecting Fighting - by Infamous - 12.03.2012, 10:38
Re: Detecting Fighting - by FreshRio - 13.03.2012, 07:21
Re: Detecting Fighting - by KingHual - 13.03.2012, 07:25
Re: Detecting Fighting - by ReneG - 13.03.2012, 07:49
Re: Detecting Fighting - by FreshRio - 13.03.2012, 08:19
Re: Detecting Fighting - by KingHual - 13.03.2012, 08:39
Re: Detecting Fighting - by MP2 - 13.03.2012, 08:46
Re: Detecting Fighting - by FreshRio - 13.03.2012, 09:06
Re: Detecting Fighting - by MP2 - 13.03.2012, 10:28

Forum Jump:


Users browsing this thread: 1 Guest(s)