[FilterScript] OnPlayerEscapeInAmmu
#1

OnPlayerEscapeInAmmu

This code detects when the player runs to ammu-nation, after a fight

Code:
pawn Код:
/*
 *  Copyright © 2012 [iPs]TeaM
 *  Bruno da Silva (brunoemail@r7.com)
 *  Detect when player runs in ammu - OnPlayerEscapeInAmmu
 *
 * http://www.brunodasilva.com.br
 * http://www.ips-team.forumeiros.com
*/

 

new gIssuerid  [MAX_PLAYERS];
new gTickshoot [MAX_PLAYERS];

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    //detect recent shoots
    gTickshoot[playerid] = gettime();
    gIssuerid [playerid] = issuerid ;
    return true;
}


public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{

// Ammunation IDS
    if(newinteriorid == 1 || newinteriorid == 7 || newinteriorid == 4 || newinteriorid == 6) {

// detect if the last shot in 3 seconds
        if((gettime() - gTickshoot[playerid]) < 3 && IsPlayerConnected(gIssuerid[playerid])) {

            static
                Float:Health1,
                Float:Health2,
                Float:Armour
            ;

            GetPlayerHealth(playerid, Health1);
            GetPlayerHealth(gIssuerid[playerid], Health2);
            GetPlayerArmour(playerid, Armour);

// check if health loss.
            if( (Health1 < Health2 && Health1 < 55.0) || (Armour < 20.0 && 30.0 > Health1 && Health1  < Health2)) {

// callback
// or OnPlayerEscapeInAmmu(playerid, gIssuerid[playerid]);

                CallLocalFunction("OnPlayerEscapeInAmmu", "ii", playerid, gIssuerid[playerid]);
            }
        }
    }
    return true;
}

So, edit:
pawn Код:
forward OnPlayerEscapeInAmmu(playerid, shooter);
public OnPlayerEscapeInAmmu(playerid, shooter) {

// example
    static
        string[128]
    ;
    format(string, 128, "The player %d run to ammu  (nOoBzOr)", playerid);
    SetPlayerHealth(playerid, 0.0);
    return SendClientMessageToAll(-1, string);

}
Reply
#2

Very nice!
Reply
#3

Nice for regular servers
Reply
#4

Great!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)