AFK System
#1

Hey all! i made the most basic afk system ever :P
I was wondering if anyone can help me with, if they enter /afk, that they get an announce message ( if that is how it's called ). saying that they went afk.
Also, when a player uses /back, his hp gets restored to 100. How do i make this he get's the hp he had before he entered afk mode? thanks!

EDIT: lol i forgot to post the script:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp(cmdtext, "/afk", true) == 0)
    {
    new pName[MAX_PLAYER_NAME];
    new string[128];
    GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
    format(string, sizeof(string), "--) %s Has entered AFK mode.", pName);
    SendClientMessageToAll(COLOR_YELLOW, string);
    TogglePlayerControllable(playerid, 0);
    SetPlayerHealth(playerid, 99999999999.99);
    return 1;
    }
    if )strcmp(cmdtext, "/back", true) == 0)
    {
    new pName[MAX_PLAYER_NAME];
    new string[128];
    GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
    format(string, sizeof(string), "--) %s Is now back.", pName);
    SendClientMessageToAll(COLOR_YELLOW, string);
    TogglePlayerControllable(playerid, 1);
    SetPlayerHealth(playerid, 100.00);
    return 1;
    }
    return 0;
}
Reply
#2

Use simple variables... and CMDS saying SendClientMessageToAll using

GetPlayerName and a string

and you want to save the heal to a varible with

new oldhp[playerid] = GetPlayerHealth(playerid);

when theyy type /back it does

SetPlayerHealth(playerid, oldhp[playerid]);

Seriously give it a go its very simple if you dont try you wont learn

Oldhp must be global (I think)
Reply
#3

You're right, and yes, im still learning pawno. I feel like i'm making good progress
Reply
#4

try this

pawn Код:
//make a variable for the stored health global, means write this on top of ur script under the includes.
new Float:AfkHealth[MAX_PLAYERS];

//then in ur /afk cmd this
GetPlayerHealth(playerid,AfkHealth[playerid]);

//in ure /back cmd this
SetPlayerHealth(playerid,AfkHealth[playerid]);
thats all

//edit: damn u guys are really fast
Reply
#5

Removed: Off Topic
Reply
#6

Quote:
Originally Posted by Nathy.SA-MP
Посмотреть сообщение
pawn Код:
new Float:naty[500];
Just wondering, what does the 500 mean?
Reply
#7

Its his MAX players just change it to [MAX_PLAYERS]Plus I really suggest you create your own otherwise you'll never learn. It will become a Habit and you wont stop.
Reply
#8

Yep, true. I've been scrolling through half sa-mp wiki doing tutorials and learning stuff. problem with me is i have to repeat them 20 times before i finally remember them. :P
Reply
#9

While were going off topic plus I cant get caught fordoing this yet I will...

To learn pawno you dont repat a phrase you need to use it to remember it.
I recommend you dont use WIKI as much on thgs not like variables and use the forums Wiki coding is mainly old and laggy
Reply
#10

Thanks for the usefull info, BTW, ontopic:
i did it!
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)