[Tutorial] How to make AFK system
#1

INDRODUCTION
In this tutorial we will learn about how to make a AFK system
STEP 1
Include a_samp which is important for every FS
PHP Code:
#include a_samp 
STEP 2
Make a command for afk
PHP Code:
public OnPlayerCommandText(playerid,cmdtext[])
{
    if (
strcmp("//The command you like in which player go AFK"cmdtexttrue10) == 0)
    {
        new 
Float:health//make a new variable which will use in health
        
GetPlayerHealth(playerid,health);//health of player which is important or players cheat in health
        
if( health 100 )//player health is more than 100
        
{
            
TogglePlayerControllable(playerid0);//Setting player controllable to 0 to disable controlles of player
            
SetPlayerHealth(playerid99999);//If you set players health less the player can die
            //There you can do anything like send message to all or him
            
return 1;
        }
        if( 
health 100 )//player health is less than 100
        
{
            
SendClientMessage(playerid//The color you like comment end\\,"You haven't enough health");
            
return 1;
        }
        return 
1;
    }
    return 
1
STEP 3
Make a command in which player back from AFK
PHP Code:
    if (strcmp("//The command you like"cmdtexttrue10) == 0)
    {
        
TogglePlayerControllable(playerid1);//1 means Player's controll enable
        //You can add anything like message to all or him
        
return 1;
    }
    return 
0;

Reply
#2

I prefer you to make antiswear and forbidden name tutorial.
Reply
#3

Quote:
Originally Posted by Giroud12
View Post
I prefer you to make antiswear and forbidden name tutorial.
It's easy..

pawn Code:
if(strcmp("fuck you",text,false) == 0)
{
    SendClientMessage(playerid, -1, Do not use bad words);
    return 0;
}
that's it.
Reply
#4

You don't make tutorials , you copy a code from your GM/FS and then post here as TUTORIAL ,
Don't you know what tutorial mean?
In a tuturial you must explain something , not to throw a code and then say it is a tutorial
Reply
#5

@Rimmon

He explained the steps.
Reply
#6

Quote:
Originally Posted by Rayan_black
View Post
It's easy..

pawn Code:
if(strcmp("fuck you",text,false) == 0)
{
    SendClientMessage(playerid, -1, Do not use bad words);
    return 0;
}
that's it.
Actually, that's incorrect. Nice try, but now you made yourself look like an idiot.

If you're making an "anti-swear" system, wouldn't you use strfind so you can find the curse words? Strcmp checks to make sure that the strings you're comparing are an EXACT match (with toggleable case sensitivity). Note that this was a rhetorical question.

Next time, think before posting.
Reply
#7

Quote:
Originally Posted by RealCop228
View Post
Actually, that's incorrect. Nice try, but now you made yourself look like an idiot.

If you're making an "anti-swear" system, wouldn't you use strfind so you can find the curse words? Strcmp checks to make sure that the strings you're comparing are an EXACT match (with toggleable case sensitivity). Note that this was a rhetorical question.

Next time, think before posting.
I know that already, I just made a small mistake and thanks for bumping it I nearly forgot about it, here's the full working code:
pawn Code:
if((strfind(text," fuck you") != -1) || (strfind(text," FUCK YOU") != -1))
    {
        SendClientMessage(playerid,-1,"[WARNING]:Don't insult other people please.");
        return 1;
    }
return 0;
PS: Please I don't like to be called an idiot, or getting insulted.. you could've say it in a nicer way.
Reply
#8

Quote:
Originally Posted by Blackazur
View Post
@Rimmon

He explained the steps.
Not good enough , i don't think a newbie will be able to make a afk system alone , he will probably copy these codes and done
If he make a tutorial , he must explain every function ,
Why he must do this , etc..
And this is weird
Code:
if( health < 100 )//player health is less than 100
        {
            SendClientMessage(playerid, //The color you like comment end\\,"You haven't enough health");
            return 1;
        }
Why, if the player have less then 100 health he can't use /afk command ?
And this weird too
Code:
if( health > 100 )
The player can't use afk command if he have 100 hp , he must have 101 health or bigger if he wanna use afk command
Whatever , i don't wanna be rude
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)