SA-MP Forums Archive
help if(AccInfo[playerid][AFK] == 0/1) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: help if(AccInfo[playerid][AFK] == 0/1) (/showthread.php?tid=178861)



help if(AccInfo[playerid][AFK] == 0/1) - cca - 24.09.2010

hi gays I have cmd to be afk
pawn Код:
if (strcmp("/afk", cmdtext, true) == 0)
    {
        if(IsPlayerVipMember(playerid))
        {
            TogglePlayerControllable(playerid, 0);
            SetPlayerPos(playerid, 293, 2414, 17);
            SendClientMessage(playerid, COLOR_Red, "to back type /back");
            AFKCount++;
            s = SetTimer("stop", 1000, true);
           
        }
        else
        {
            TogglePlayerControllable(playerid, 0);
            SetPlayerPos(playerid, 293, 2414, 17);
            SendClientMessage(playerid, COLOR_Red, "you will kick after 10 min if you didn't type /back");
            AFKCount++;
            s = SetTimer("stop", 1000, true);
            k = SetTimer("kick", 600000, true);
        }
        return 1;
    }
    if (strcmp("/back", cmdtext, true) == 0)
    {
        if(IsPlayerVipMember(playerid))
        {
            TogglePlayerControllable(playerid, 1);
            SetPlayerPos(playerid, 334, 2417, 17);
            KillTimer(s);
            AFKCount--;
        }
        else
        {
            KillTimer(s);
            TogglePlayerControllable(playerid, 1);
            SetPlayerPos(playerid, 334, 2417, 17);
            KillTimer(k);
            AFKCount--;
        }
        return 1;
    }
I want it to be like this
pawn Код:
if (strcmp("/afk", cmdtext, true) == 0)
    {
        if(AccInfo[playerid][AFK] == 0)
        (
            if(IsPlayerVipMember(playerid))
            {
                AccInfo[playerid][AFK] = 1;
                TogglePlayerControllable(playerid, 0);
                SetPlayerPos(playerid, 293, 2414, 17);
                SendClientMessage(playerid, COLOR_Red, "to back type /back");
                AFKCount++;
                s = SetTimer("stop", 1000, true);
           
            }
            else
            {
                AccInfo[playerid][AFK] = 1;
                TogglePlayerControllable(playerid, 0);
                SetPlayerPos(playerid, 293, 2414, 17);
                SendClientMessage(playerid, COLOR_Red, "you will kick after 10 min if you didn't type /back");
                AFKCount++;
                s = SetTimer("stop", 1000, true);
                k = SetTimer("kick", 600000, true);
            }
        }
        else SendClientMessage(playerid. COLOR_Red, "you are alredy AFK");
        return 1;
    }
    if (strcmp("/back", cmdtext, true) == 0)
    {
        if(AccInfo[playerid][AFK] == 1)
        (
            if(IsPlayerVipMember(playerid))
            {
                AccInfo[playerid][AFK] = 0;
                TogglePlayerControllable(playerid, 1);
                SetPlayerPos(playerid, 334, 2417, 17);
                KillTimer(s);
                AFKCount--;
            }
            else
            {
                AccInfo[playerid][AFK] = 0;
                KillTimer(s);
                TogglePlayerControllable(playerid, 1);
                SetPlayerPos(playerid, 334, 2417, 17);
                KillTimer(k);
                AFKCount--;
            }
        }
        else SendClientMessage(playerid. COLOR_Red, "you are not AFK");
        return 1;
    }



Re: help if(AccInfo[playerid][AFK] == 0/1) - wups - 24.09.2010

Oh my god! The code is terrible.
pawn Код:
new AFK[MAX_PLAYERS]; // after include a_samp
new AKick[MAX_PLAYERS]; // after include a_samp
new ASTOP[MAX_PLAYERS]; // after include a_samp

public OnPlayerConnect(playerid)
{
       AFK[playerid]=0;
       AKick[playerid]=0;
       ASTOP[playerid]=0;
}

if (strcmp("/afk", cmdtext, true) == 0)
    {
        if(!AFK[playerid])
        (
            if(IsPlayerVipMember(playerid))
            {
                AFK[playerid] = 1;
                TogglePlayerControllable(playerid, 0);
                SetPlayerPos(playerid, 293, 2414, 17);
                SendClientMessage(playerid, COLOR_Red, "to back type /back");
                AFKCount++;
                ASTOP[playerid] = SetTimer("stop", 1000, true);
           
            }
            else
            {
                AFK[playerid] = 1;
                TogglePlayerControllable(playerid, 0);
                SetPlayerPos(playerid, 293, 2414, 17);
                SendClientMessage(playerid, COLOR_Red, "you will kick after 10 min if you didn't type /back");
                AFKCount++;
                ASTOP[playerid] = SetTimer("stop", 1000, true);
                AKick[playerid] = SetTimer("kick", 600000, true);
            }
        }
        else SendClientMessage(playerid. COLOR_Red, "you are alredy AFK");
        return 1;
    }
    if (strcmp("/back", cmdtext, true) == 0)
    {
        if(AFK[playerid] == 1)
        (
            if(IsPlayerVipMember(playerid))
            {
                AccInfo[playerid][AFK] = 0;
                TogglePlayerControllable(playerid, 1);
                SetPlayerPos(playerid, 334, 2417, 17);
                KillTimer(ASTOP[playerid]);
                AFKCount--;
            }
            else
            {
                AFK[playerid] = 0;
                KillTimer(ASTOP[playerid]);
                TogglePlayerControllable(playerid, 1);
                SetPlayerPos(playerid, 334, 2417, 17);
                KillTimer(AKick[playerid]);
                AFKCount--;
            }
        }
        else SendClientMessage(playerid. COLOR_Red, "you are not AFK");
        return 1;
    }
Should work just fine.


Re: help if(AccInfo[playerid][AFK] == 0/1) - Ash. - 24.09.2010

Problem?

You've just typed it how you wanted it?

Grr...
This forum requires that you wait 120 seconds between posts. Please try again in 77 seconds.


Re: help if(AccInfo[playerid][AFK] == 0/1) - cca - 24.09.2010

Quote:
Originally Posted by wups
Посмотреть сообщение
Oh my god! The code is terrible.
pawn Код:
new AFK[MAX_PLAYERS]; // after include a_samp
new AKick[MAX_PLAYERS]; // after include a_samp
new ASTOP[MAX_PLAYERS]; // after include a_samp

public OnPlayerConnect(playerid)
{
       AFK[playerid]=0;
       AKick[playerid]=0;
       ASTOP[playerid]=0;
}

if (strcmp("/afk", cmdtext, true) == 0)
    {
        if(!AFK[playerid])
        (
            if(IsPlayerVipMember(playerid))
            {
                AFK[playerid] = 1;
                TogglePlayerControllable(playerid, 0);
                SetPlayerPos(playerid, 293, 2414, 17);
                SendClientMessage(playerid, COLOR_Red, "to back type /back");
                AFKCount++;
                ASTOP[playerid] = SetTimer("stop", 1000, true);
           
            }
            else
            {
                AFK[playerid] = 1;
                TogglePlayerControllable(playerid, 0);
                SetPlayerPos(playerid, 293, 2414, 17);
                SendClientMessage(playerid, COLOR_Red, "you will kick after 10 min if you didn't type /back");
                AFKCount++;
                ASTOP[playerid] = SetTimer("stop", 1000, true);
                AKick[playerid] = SetTimer("kick", 600000, true);
            }
        }
        else SendClientMessage(playerid. COLOR_Red, "you are alredy AFK");
        return 1;
    }
    if (strcmp("/back", cmdtext, true) == 0)
    {
        if(AFK[playerid] == 1)
        (
            if(IsPlayerVipMember(playerid))
            {
                AccInfo[playerid][AFK] = 0;
                TogglePlayerControllable(playerid, 1);
                SetPlayerPos(playerid, 334, 2417, 17);
                KillTimer(ASTOP[playerid]);
                AFKCount--;
            }
            else
            {
                AFK[playerid] = 0;
                KillTimer(ASTOP[playerid]);
                TogglePlayerControllable(playerid, 1);
                SetPlayerPos(playerid, 334, 2417, 17);
                KillTimer(AKick[playerid]);
                AFKCount--;
            }
        }
        else SendClientMessage(playerid. COLOR_Red, "you are not AFK");
        return 1;
    }
Should work just fine.
Quote:
Originally Posted by funky1234
Посмотреть сообщение
Problem?

You've just typed it how you wanted it?

Grr...
This forum requires that you wait 120 seconds between posts. Please try again in 77 seconds.
thnx all