Use a command on dead players
#1

I have a command there i want to do so only it can be used on dead people, if the player is alive and he type the command like


/restinpiece id/nick

he will get a msg like

%s is alive, you cant use this command
Reply
#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
#3

not what am looking for
Reply
#4

PHP код:
#include <a_samp>
new DEAD[MAX_PLAYERS];
public 
OnPlayerConnect(playerid)
{
    
DEAD[playerid] = 0;//player is alive
    
return 1;
}
public 
OnPlayerSpawn(playerid)
{
    
DEAD[playerid] = 0;//player is alive
    
return 1;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
    
DEAD[playerid] = 1;//player is dead
    
return 1;
}
public 
OnPlayerCommandText(playeridcmdtext[])
{
    if(
DEAD[playerid] == 1)
    {
        
//dead commands
        
if (strcmp("/mycommand"cmdtexttrue10) == 0)
        {
            return 
1;
        }
    }
    else
    {
        
//alive commands
        
if (strcmp("/mycommand"cmdtexttrue10) == 0)
        {
        }
    }
     return 
0;

Reply
#5

um?
Reply
#6

Quote:
Originally Posted by Ananisiki
Посмотреть сообщение
um?
I hate it when people post here wanting a script made for them. Both the previous helpers posted scripts that both work. They did exactly what you asked for.
Reply
#7

Use:

pawn Код:
if(GetPlayerState(id) == PLAYER_STATE_WASTED)
"id" being the target you'd use in the command.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)