[Tutorial] How To Make AFK System ?
#1

Introduction
i Will Show You How To Create AFK System.
Sorry If Im bad in scripting and english


pawn Code:
#include <a_samp>   // We Need This Include
#include <zcmd>     // We Need This Include
#include <sscanf2>  // We Need This Include

new IsAfk[MAX_PLAYERS]; // Global Variable

// This CallBack Work When Player Connect
public OnPlayerConnect(playerid)
{ // Opening Bracket
    IsAfk[playerid] = 0; // To Set This To 0
    return 1;
} // Closing Bracket

// This CallBack Work When Player Disconnect
public OnPlayerDisconnect(playerid, reason)
{ // Opening Bracket
    IsAfk[playerid] = 0; // To Set This To 0
    return 1;
} // Closing Bracket

// We Will Gonna Make A AFK Command
CMD:afk(playerid,params[])
{ // Opening Bracket
    new string[128], pName[MAX_PLAYER_NAME]; // Variables
    if(IsAfk[playerid] == 1) return SendClientMessage(playerid, 0xFF0000FF,"You Are Already AFK"); // To Check When Player Is Already AFK
    TogglePlayerControllable(playerid, 0); // To Freeze The Player
    format(string,sizeof(string),"Server: %s Is Now Afk", pName); // will format a message
    SendClientMessageToAll(0xFFFF00,string); // Will Send A Public Message To All
    SendClientMessage(playerid, 0xFF00FFFF,"Type /back if you want to continue"); // Will Send A Message
    IsAfk[playerid] = 1; // To Set This To 1
    return 1;
} // Closing Bracket

// We Will Gonna Make A BACK Command
CMD:back(playerid,params[])
{ // Opening Bracket
    new string[128], pName[MAX_PLAYER_NAME]; // Variables
    if(IsAfk[playerid] == 0) return SendClientMessage(playerid, 0xFF0000FF,"You Are Not AFK"); // To Check When Player is Not AFK
    TogglePlayerControllable(playerid, 1); // Unfreeze The Player
    format(string,sizeof(string),"Server: %s Is Back!", pName); // will format a message
    SendClientMessageToAll(0xFFFF00,string); // To Send A Public Message To All
    IsAfk[playerid] = 0; // To Set This To 0
    return 1;
} // Closing Bracket
Reply


Messages In This Thread
How To Make AFK System ? - by Windrush - 12.01.2013, 14:27
Re: How To Make AFK System ? - by [WA]iRonan - 12.01.2013, 18:32
Re: How To Make AFK System ? - by zJordioz - 12.01.2013, 19:07
Re: How To Make AFK System ? - by spedico - 02.02.2013, 12:27
Re: How To Make AFK System ? - by xMCx - 02.02.2013, 12:53

Forum Jump:


Users browsing this thread: 1 Guest(s)