AFK System -
dahley5 - 03.09.2011
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;
}
Re: AFK System -
IceCube! - 03.09.2011
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)
Re: AFK System -
dahley5 - 03.09.2011
You're right, and yes, im still learning pawno. I feel like i'm making good progress
Re: AFK System -
BlackWolf120 - 03.09.2011
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
Re: AFK System -
IceCube! - 03.09.2011
Removed: Off Topic
Re: AFK System -
dahley5 - 03.09.2011
Quote:
Originally Posted by Nathy.SA-MP
|
Just wondering, what does the 500 mean?
Re: AFK System -
IceCube! - 03.09.2011
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.
Re: AFK System -
dahley5 - 03.09.2011
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
Re: AFK System -
IceCube! - 03.09.2011
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
Re: AFK System -
dahley5 - 03.09.2011
Thanks for the usefull info, BTW, ontopic:
i did it!