/afk and /back commands
#4

Quote:
Originally Posted by grand.Theft.Otto
Посмотреть сообщение
Untested:

EDIT: Like Mike said, it's not a bug, you need to create a variable.

pawn Код:
// top of script

new IsAFK[MAX_PLAYERS];

// new /afk command

COMMAND:afk(playerid, params[])
{
    if (APlayerData[playerid][LoggedIn] == true)
    {
        if(IsAFK[playerid] == 0)
        {
            SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}You are afk, when you come back, do /back");
            TogglePlayerControllable(playerid,0);

            new string3[160];
            new name[MAX_PLAYER_NAME];
            GetPlayerName(playerid, name, sizeof(name));

            format(string3, sizeof(string3), "{FF6600}%s {FFFFFF}is now AFK - {FF6600}%s", name, params);
            SendClientMessageToAll(0xFFFFFFFF, string3);
           
            IsAFK[playerid] = 1;
        } else return SendClientMessage(playerid,-1,"You Are Already Away From Keyboard.");
    }
    return 1;
}

// new /back command

COMMAND:back(playerid, params[])
{
    if (APlayerData[playerid][LoggedIn] == true)
    {
        if(IsAFK[playerid] == 1)
        {
            SendClientMessage(playerid, 0xFFFFFFFF, "Welcome Back!!");
            TogglePlayerControllable(playerid,1);
            SetPlayerFacingAngle(playerid, 180);

            new string3[70];
            new name[MAX_PLAYER_NAME];
            GetPlayerName(playerid, name, sizeof(name));

            format(string3, sizeof(string3), "{FF6600}%s {FFFFFF}is back from being afk!", name);
            SendClientMessageToAll(0xFFFFFFFF, string3);
           
            IsAFK[playerid] = 0;
        } else return SendClientMessage(playerid,-1,"You Are Not Away From Keyboard.");
    }
    return 1;
}
Thanks, these errors i get:
Код:
C:\Users\Barbara\Desktop\SAMP Kevin\hoi\gamemodes\PPC_Trucking.pwn(22) : error 017: undefined symbol "MAX_PLAYERS"
C:\Users\Barbara\Desktop\SAMP Kevin\hoi\gamemodes\PPC_Trucking.pwn(22) : error 009: invalid array size (negative, zero or out of bounds)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
"new IsAFK[MAX_PLAYERS];"
Is on top of my script.
Reply


Messages In This Thread
/afk and /back commands - by SomebodyAndMe - 09.12.2011, 13:10
Re: /afk and /back commands - by xMichaelx - 09.12.2011, 13:17
Re: /afk and /back commands - by grand.Theft.Otto - 09.12.2011, 13:18
Re: /afk and /back commands - by SomebodyAndMe - 09.12.2011, 13:23
Re: /afk and /back commands - by Rob_Maate - 09.12.2011, 13:27
Re: /afk and /back commands - by SomebodyAndMe - 09.12.2011, 13:35
Re: /afk and /back commands - by grand.Theft.Otto - 09.12.2011, 19:43

Forum Jump:


Users browsing this thread: 1 Guest(s)