help if(AccInfo[playerid][AFK] == 0/1)
#1

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;
    }
Reply
#2

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.
Reply
#3

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.
Reply
#4

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)