Quick question for my afk system
#1

Ok guys im making an afk system but i want it like this, if i type /afk it will set my health to 100000 for example which i already know how to do that but i want when the playe type /back the old health restores how can i do that.

And if there is any way to avoid when a player pause and another player cant kill them even when they dont type /afk please tell me or set a link where i can find a tutorial on it
Reply
#2

store the health to a variable before he goes to afk and give the health using that variable on /back
Reply
#3

store the health to a variable example
PHP код:

new hh//write this up
//this under AFK CMD
hh GetPlayerHealth(playerid);
//then 
//under back CMD
SetPlayerHealth(playeridhh); 
Reply
#4

Quote:
Originally Posted by Slawiii
Посмотреть сообщение
store the health to a variable example
PHP код:

new hh//write this up
//this under AFK CMD
hh GetPlayerHealth(playerid);
//then 
//under back CMD
SetPlayerHealth(playeridhh); 
Thats not going to work
i suggeset you ro use pvars
Reply
#5

Like this ?
PHP код:
new Float:afkHealth[MAX_PLAYER]
// AFK CMD | Get player health :
GetPlayerHealth(playeridafkHealth[playerid]);

// Restore health
SetPlayerHealth(playeridafkHealth[playerid]); 
Reply
#6

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
Like this ?
PHP код:
new Float:afkHealth[MAX_PLAYER]
// AFK CMD | Get player health :
GetPlayerHealth(playeridafkHealth[playerid]);
// Restore health
SetPlayerHealth(playeridafkHealth[playerid]); 
that will work you can try it
Reply
#7

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
Like this ?
PHP код:
new Float:afkHealth[MAX_PLAYER]
// AFK CMD | Get player health :
GetPlayerHealth(playeridafkHealth[playerid]);
// Restore health
SetPlayerHealth(playeridafkHealth[playerid]); 
Ok i will be testing
Reply
#8

Uhm, you have to edit something. I did a mistake :
MAX_PLAYER » MAX_PLAYERS

PHP код:
new Float:afkHealth[MAX_PLAYERS
// AFK CMD | Get player health : 
GetPlayerHealth(playeridafkHealth[playerid]); 

// Restore health 
SetPlayerHealth(playeridafkHealth[playerid]); 
Reply
#9

Quote:
Originally Posted by Sreyas
Посмотреть сообщение
that will work you can try it
How Could i make it so if the player is /afk for 2-3 mins they get kick.
pawn Код:
CMD:afk(playerid,params[])
{
    if( pInfo[playerid][Spawned]    != 1)
    {
        ShowMessage(playerid, red, 9);
        return 1;
    }
    else
    {
        GetPlayerHealth(playerid, afkH[playerid]);
        TogglePlayerControllable(playerid,0);
        GetPlayerArmour(playerid, afkA[playerid]);
        SetPlayerHealth(playerid,300000);
        SetPlayerArmour(playerid,100000);
        AFK[playerid]++;
        SetTimer("AFKCheck",1000,1);
    }
    return 1;
}
CMD:back(playerid,params[])
{
    if( pInfo[playerid][Spawned]    != 1)
    {
        ShowMessage(playerid, red, 9);
        return 1;
    }
    else
    {
        TogglePlayerControllable(playerid,1);
        SetPlayerHealth(playerid, afkH[playerid]);
        SetPlayerArmour(playerid, afkA[playerid]);
        SendClientMessage(playerid,red,"Your status has been set to Playing.");
        AFK[playerid] =0;
    }
    return 1;
forward AFKCheck(playerid);
public AFKCheck(playerid)
{
    if(AFK[playerid] == 60)
    {
        AFK[playerid] = 0;
        format(astring,sizeof(astring),"Andre[BOT]: Player %s has been kicked. [Reason: Inactivity ]",GetName(playerid));
        SendClientMessageToAll(yellow,astring);
        SetTimerEx("KickPlayer",200,false,"d", playerid);
    }
}
}
Because i attempt it but doesnt work
Reply
#10

Try this :
PHP код:
CMD:afk(playerid,params[])
{
     if(
pInfo[playerid][Spawned] != 1)
    {
        
ShowMessage(playeridred9);
        return 
1;
    }
    else
     {
        
GetPlayerHealth(playeridafkH[playerid]);
        
TogglePlayerControllable(playerid,0);
        
GetPlayerArmour(playeridafkA[playerid]);
        
SetPlayerHealth(playerid,300000);
        
SetPlayerArmour(playerid,100000);
        
AFK[playerid]++;
        
SetTimerEx("AFKCheck"60000,false,"i"playerid);
        return 
1;
    }
}
CMD:back(playerid,params[])
{
    if(
pInfo[playerid][Spawned] != 1)
    {
        
ShowMessage(playeridred9);
        return 
1;
    }
    else
    {
        
TogglePlayerControllable(playerid,1);
        
SetPlayerHealth(playeridafkH[playerid]);
        
SetPlayerArmour(playeridafkA[playerid]);
        
SendClientMessage(playerid,red,"Your status has been set to Playing.");
        
AFK[playerid] = 0;
        return 
1;
    }
}
forward AFKCheck(playerid);
public 
AFKCheck(playerid)
{
    if(
AFK[playerid] == 1)
    {
        
AFK[playerid] = 0;
        
format(astring,sizeof(astring),"Andre[BOT]: Player %s has been kicked. [Reason: Inactivity ]",GetName(playerid));
        
SendClientMessageToAll(yellow,astring);
        
SetTimerEx("KickPlayer",200,false,"d"playerid);
        return 
1;
    }
    else return 
printf("[Error] Can't check the afk status of %s (ID:%i)"GetName(playerid), playerid);

- Added an error message.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)