13.03.2012, 07:49
Here is a quick tutorial.
I hope you understood! Goodluck!
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;
}