[SNIPPET] AFK and Back feature [NOOB FRIENDLY / SIMPLE]
#1

Got bored today so I decided to read the forums and download a few scripts. What I found was that the majority of non roleplay servers didnt have an afk system, so heres a real simple one. Don't point out the problems, I don't care. If I get it wrong, dont blame me, its been a long time since I coded.

pawn Код:
// AFK and back feature by Jonty
// please dont remove this if its a public script, feel free to remove it if your script is private

// afk
if(strcmp(cmdtext, "/afk") == 0) //afk command
{
SetPlayerSpectating(playerid, 1); // I think its setplayerspectating, not sure.
SendClientMessage(playerid, COLOR_HERE, "You are now AFK. Type /back to return.");
return 1;
}
// back
if(strcmp(cmdtext, "/back") == 0) //back command
{
SetPlayerSpectating(playerid, 0); // I think its setplayerspectating, not sure.
SendClientMessage(playerid, COLOR_HERE, "Welcome back!");
return 1;
}
Put that in your
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
Reply
#2

Quote:
Originally Posted by Jonteh
Got bored today so I decided to read the forums and download a few scripts. What I found was that the majority of non roleplay servers didnt have an afk system, so heres a real simple one. Don't point out the problems, I don't care. If I get it wrong, dont blame me, its been a long time since I coded.
There are tons of Filterscripts and if the code is wrong Dont blame you?

Btw the code is correct and not bad work
Reply
#3

really simple but nice
in future versions you could add 3DTextLabels saying "I am AFK" or smth
Reply
#4

Or you could do:

pawn Код:
// AFK and back feature by Jonty
// please dont remove this if its a public script, feel free to remove it if your script is private

// afk
if(strcmp(cmdtext, "/afk") == 0) //afk command
{
SetPlayerSpectating(playerid, 1); // I think its setplayerspectating, not sure.
SendClientMessage(playerid, COLOR_HERE, "You are now AFK. Type /back to return.");
SetPlayerColor(playerid, COLOR_GREY);
return 1;
}
// back
if(strcmp(cmdtext, "/back") == 0) //back command
{
SetPlayerSpectating(playerid, 0); // I think its setplayerspectating, not sure.
SendClientMessage(playerid, COLOR_HERE, "Welcome back!");
SpawnPlayer(playerid);
SetPlayerColorToTeamColor(playerid);
return 1;
}
Reply
#5

If you would have even tested this, or used the wiki, you would have found out that it is TogglePlayerSpectating and not SetPlayerSpectating.
Reply
#6

It took me a couple mins, I got bored at 1.00am, give me a damn break.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)