SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 11/05/2013, 08:48 AM   #1
BlackHorse
Big Clucker
 
BlackHorse's Avatar
 
Join Date: Feb 2013
Location: tunnle of zombies
Posts: 60
Reputation: 4
Default How to make AFK system

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;

BlackHorse is offline   Reply With Quote
Old 11/05/2013, 09:28 AM   #2
Giroud12
Huge Clucker
 
Giroud12's Avatar
 
Join Date: Mar 2013
Location: New World
Posts: 284
Reputation: 8
Default Re: How to make AFK system

I prefer you to make antiswear and forbidden name tutorial.
__________________
_________________________________________
Mama put my guns in the ground,
I can't shoot them anymore,
That cold black cloud is comin' down,
Feels like I'm knockin' on heaven's door. -GNR-
_________________________________________
Giroud12 is offline   Reply With Quote
Old 11/05/2013, 10:43 AM   #3
Rayan_black
Huge Clucker
 
Rayan_black's Avatar
 
Join Date: Jan 2012
Posts: 328
Reputation: 46
Default Re : Re: How to make AFK system

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.
Rayan_black is offline   Reply With Quote
Old 14/05/2013, 05:05 PM   #4
Rimmon
Big Clucker
 
Join Date: Nov 2011
Posts: 142
Reputation: 5
Default Re: How to make AFK system

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
__________________
If you have scripts ideas pm me(i know dini and SQLite)

My Scripts:

Rimmon is offline   Reply With Quote
Old 14/05/2013, 05:08 PM   #5
Blackazur
High-roller
 
Join Date: Apr 2012
Posts: 1,408
Reputation: 12
Default AW: How to make AFK system

@Rimmon

He explained the steps.
Blackazur is offline   Reply With Quote
Old 14/05/2013, 05:38 PM   #6
Scenario
Godfather
 
Scenario's Avatar
 
Join Date: Feb 2010
Location: Heaven
Posts: 7,809
Reputation: 701
Default Re: How to make AFK system

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.
Scenario is offline   Reply With Quote
Old 14/05/2013, 05:54 PM   #7
Rayan_black
Huge Clucker
 
Rayan_black's Avatar
 
Join Date: Jan 2012
Posts: 328
Reputation: 46
Default Re : Re: How to make AFK system

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.
Rayan_black is offline   Reply With Quote
Old 15/05/2013, 12:23 PM   #8
Rimmon
Big Clucker
 
Join Date: Nov 2011
Posts: 142
Reputation: 5
Default Re: AW: How to make AFK system

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
__________________
If you have scripts ideas pm me(i know dini and SQLite)

My Scripts:

Rimmon is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make Admins Levels and how to make gates system and more Loranzo_De_Andreas Scripting Help 2 22/03/2013 12:56 PM
Make GPS System [HELP] MichaelProPlayer Scripting Help 6 02/06/2012 05:11 AM
How to make a car system like this? Snowman12 Scripting Help 17 08/01/2012 06:51 PM
[Tutorial] How to make an AFK system Cjgogo Tutorials 6 21/10/2011 04:40 PM


All times are GMT. The time now is 08:55 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.