AFK Mode. pls help
#1

PHP код:
#include <a_samp>
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_YELLOW 0xFFFF00AA
#define c_r 0xAA3333AA
new Float:lol[3];
new 
Float:vlol[3];
public 
OnPlayerCommandText(playeridcmdtext[])
{
  if(!
strcmp(cmdtext"/goafk"true))
  {
    
GetPlayerPos(playerid,Float:lol[0],Float:lol[1],Float:lol[2]);
    
SetTimerEx("AFK",5000,0,5000);
    
SendClientMessage(playerid,COLOR_YELLOW,"( ! ) Don't move ! Please wait 5 seconds...");
    return 
1;
  }
  if(!
strcmp(cmdtext"/back"true))
  {
    new 
pName[MAX_PLAYER_NAME];
    new 
string[48];
    
GetPlayerName(playeridpNamesizeof(pName));
    
format(stringsizeof(string), "( ! ) You are back from AFK mode");
    
SetPlayerVirtualWorld(playerid,0);
    
SendClientMessage(playeridCOLOR_GREYstring);
    
GameTextForPlayer(playerid,"~w~Welcome back",2000,3);
    
format(stringsizeof(string), "( ! ) %s is back from AFK mode"pName);
    
SendPlayerMessageToAll(COLOR_GREYstring);
    
TogglePlayerControllable(playerid,1);
    return 
1;
    }
  return 
0;
}
forward AFK();
public 
AFK()
{   for(new 
0MAX_PLAYERSi++)
    {
    
GetPlayerPos(i,Float:vlol[0],Float:vlol[1],Float:vlol[2]);
    if(
Float:lol[0] == Float:vlol[0])if(Float:lol[1] == Float:vlol[1])if(Float:lol[2] == Float:vlol[2])
    {
    new 
pName[MAX_PLAYER_NAME];
    new 
string[48];
    
GetPlayerName(ipNamesizeof(pName));
    
format(stringsizeof(string), "( ! ) You are now in AFK mode");
    
SetPlayerVirtualWorld(i,1);
    
SendClientMessage(iCOLOR_GREYstring);
    
GameTextForPlayer(i,"~w~AFK Mode",2000,3);
    
format(stringsizeof(string), "( ! ) %s is now in AFK mode"pName);
    
SendPlayerMessageToAll(COLOR_GREYstring);
    
TogglePlayerControllable(i,0);
    
SendClientMessage(iCOLOR_WHITE,"( ! ) Type /back to go into game");
    return 
1;
    }
    else
    {
    
SendClientMessage(i,c_r,"( ! ) Going in afk mode was cancel reason: You moved !");
    }
    }
    return 
0;

hi, some time ago I made afk mode and when type /goafk at moment you go in afk mode in virtual world and get freeze, but I though will be abuse for players if you can go fast example in fight, you have 5% of life and you go in afk mode and you save. and then I though make timer 5secs, but doesn't work
what I forgot write? help plz !!!
Reply
#2

change ur timer to
pawn Код:
SetTimerEx("AFK",5000,0,"u",playerid);
And the AFK() to
pawn Код:
forward AFK(playerid);
public AFK(playerid)
https://sampwiki.blast.hk/wiki/SetTimerEx
Reply
#3

This should work:

pawn Код:
#include <a_samp>

#define COLOR_GREY 0xAFAFAFAA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_YELLOW 0xFFFF00AA
#define c_r 0xAA3333AA

new
    Float:lol[ 3 ],
    Float:vlol[ 3 ];
   
public OnPlayerCommandText(playerid, cmdtext[])
{
    if ( !strcmp ( cmdtext, "/goafk", true ) )
    {
        GetPlayerPos( playerid, lol[ 0 ], lol[ 1 ], lol[ 2 ]);
        SetTimerEx( "AFK", 5000, false, "ifff", playerid, lol[ 0 ], lol[ 1 ], lol[ 2 ] );
        SendClientMessage (playerid,COLOR_YELLOW,"( ! ) Don't move ! Please wait 5 seconds...");
        return ( 1 );
    }
    if ( !strcmp ( cmdtext, "/back", true ) )
    {
        new
            pName[ MAX_PLAYER_NAME ],
            string[ 48 ];
           
        GetPlayerName( playerid, pName, MAX_PLAYER_NAME );
        format( string, sizeof ( string ), "( ! ) You are back from AFK mode" );
        SetPlayerVirtualWorld( playerid, 0 );
        SendClientMessage( playerid, COLOR_GREY, string );
        GameTextForPlayer( playerid,"~w~Welcome back", 2000, 3);
        format(string, sizeof ( string ), "( ! ) %s is back from AFK mode", pName);
        SendClientMessageToAll( COLOR_GREY, string );
        TogglePlayerControllable( playerid, 1);
        return 1;
    }
    return ( 0 );
}

forward AFK( playerid, &Float:x, &Float:y, &Float:z );

public AFK( playerid, &Float:x, &Float:y, &Float:z )
{  
    GetPlayerPos( playerid, vlol[ 0 ], vlol[ 1 ], vlol[ 2 ] );
    if( x == vlol[ 0 ] && y == vlol[ 1 ] && z == vlol[ 2 ] )
    {
        new
            pName[ MAX_PLAYER_NAME ],
            string[ 48 ];
           
        GetPlayerName( playerid, pName, MAX_PLAYER_NAME );
        format(string, sizeof ( string ), "( ! ) You are now in AFK mode" );
        SetPlayerVirtualWorld( playerid, 1 );
        SendClientMessage( playerid, COLOR_GREY, string );
        GameTextForPlayer( playerid,"~w~AFK Mode", 2000, 3);
        format(string, sizeof ( string ), "( ! ) %s is now in AFK mode", pName);
        SendClientMessageToAll(COLOR_GREY, string);
        TogglePlayerControllable( playerid, 0);
        SendClientMessage(playerid, COLOR_WHITE,"( ! ) Type /back to go into game");
        return ( 1 );
    }
    else
    {
        SendClientMessage( playerid, c_r, "( ! ) Going in afk mode was cancel reason: You moved !");
    }
    return ( 1 );
}
Reply
#4

I tried both and no one from them doesn't work
Reply
#5

What doesnt work, the command or timer
Reply
#6

Quote:
Originally Posted by Tanush123
Посмотреть сообщение
What doesnt work, the command or timer
when I type /goafk I just receive message don't move but after 5 secs I not going in afk mode
Reply
#7

anybody can help me?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)