Use a command on dead players
#2

pawn Код:
CMD:restinpeace(playerid, params[])
{
new giveplayerid = GetClosestPlayer(playerid, 10.0);
if(giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Your not near anyone.");
if(pDead[giveplayerid] == 0) {
new string[128];
format(string, sizeof(string), "%s is alive, you cant use this command.");
return SendClientMessage(playerid, -1, string);
}
// Put the code here
return 1;
}

stock GetClosestPlayer(playerid,Float:limit)
{
    new Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2;
    GetPlayerPos(playerid,x1,y1,z1);
    new Float:Range = 999.9;
    new id = -1;
    foreach(Player,i)
    {
        if(playerid != i)
        {
            GetPlayerPos(i,x2,y2,z2);
            new Float:Dist = GetDistanceBetweenPoints(x1,y1,z1,x2,y2,z2);
            if(floatcmp(Range,Dist) == 1 && floatcmp(limit,Range) == 1)
            {
                Range = Dist;
                id = i;
            }
        }
    }
    return id;
}
The code for GetClosestPlayer is not my scripting and was found on a post by cessil.(Source: https://sampforum.blast.hk/showthread.php?tid=202122)

Just ask if you want it with sscanf...
Reply


Messages In This Thread
Use a command on dead players - by Ananisiki - 02.05.2014, 00:42
Re: Use a command on dead players - by Abagail - 02.05.2014, 01:07
Re: Use a command on dead players - by Ananisiki - 02.05.2014, 16:28
Re: Use a command on dead players - by ic3cr3am - 02.05.2014, 16:40
Re: Use a command on dead players - by Ananisiki - 02.05.2014, 22:34
Re: Use a command on dead players - by Aerotactics - 02.05.2014, 22:37
Re: Use a command on dead players - by DobbysGamertag - 02.05.2014, 22:47

Forum Jump:


Users browsing this thread: 3 Guest(s)