#1

Hello.

Can someone tell me how to use "else"? how many brackets you need depending on how much there is in a code etc
In this way:
pawn Код:
if bla bla
{
    //code
    }
    else
    {
    //code
    }
return 1;
}
Reply
#2

This should help you: https://sampwiki.blast.hk/wiki/Control_Structures#else
Reply
#3

Quote:
Originally Posted by SmiT
Посмотреть сообщение
Thanks, that helped me, but my command do not work, it do set you AFK, but not BACK when you type AFK again.
pawn Код:
COMMAND:afk(playerid, params[])
{
    if(TogglePlayerControllable(playerid, 1))
    {
        GetPlayerName(playerid, Name, sizeof(Name));
        TogglePlayerControllable(playerid,0);
        SetPlayerHealth(playerid, 9999);
        format(String,MAX_PLAYERS,"* %s is AFK.",Name);
        SendClientMessageToAll(COLOR_GREY,String);
        SendClientMessage(playerid, COLOR_GREY, "Type AFK again when you are back");
    }
    else
    {
        GetPlayerName(playerid, Name, sizeof(Name));
        TogglePlayerControllable(playerid,1);
        SetPlayerHealth(playerid, 100);
        format(String,MAX_PLAYERS,"* %s is BACK.",Name);
        SendClientMessageToAll(COLOR_GREY,String);
    }
    return 1;
}
Reply
#4

Under incs:
pawn Код:
new afk[MAX_PLAYERS];
OnPlayerConnect:
pawn Код:
afk[playerid] = 0;
CMD:
pawn Код:
COMMAND:afk(playerid, params[])
{
    if(afk[playerid] == 0)
    {
        GetPlayerName(playerid, Name, sizeof(Name));
        TogglePlayerControllable(playerid,0);
        SetPlayerHealth(playerid, 9999);
        format(String,MAX_PLAYERS,"* %s is AFK.",Name);
        SendClientMessageToAll(COLOR_GREY,String);
        SendClientMessage(playerid, COLOR_GREY, "Type AFK again when you are back");
        afk[playerid] = 1;
    }
    else
    {
        GetPlayerName(playerid, Name, sizeof(Name));
        TogglePlayerControllable(playerid,1);
        SetPlayerHealth(playerid, 100);
        format(String,MAX_PLAYERS,"* %s is BACK.",Name);
        SendClientMessageToAll(COLOR_GREY,String);
        afk[playerid] = 0;
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by HyperZ
Посмотреть сообщение
Under incs:
pawn Код:
new afk[MAX_PLAYERS];
OnPlayerConnect:
pawn Код:
afk[playerid] = 0;
CMD:
pawn Код:
COMMAND:afk(playerid, params[])
{
    if(afk[playerid] == 0)
    {
        GetPlayerName(playerid, Name, sizeof(Name));
        TogglePlayerControllable(playerid,0);
        SetPlayerHealth(playerid, 9999);
        format(String,MAX_PLAYERS,"* %s is AFK.",Name);
        SendClientMessageToAll(COLOR_GREY,String);
        SendClientMessage(playerid, COLOR_GREY, "Type AFK again when you are back");
        afk[playerid] = 1;
    }
    else
    {
        GetPlayerName(playerid, Name, sizeof(Name));
        TogglePlayerControllable(playerid,1);
        SetPlayerHealth(playerid, 100);
        format(String,MAX_PLAYERS,"* %s is BACK.",Name);
        SendClientMessageToAll(COLOR_GREY,String);
        afk[playerid] = 0;
    }
    return 1;
}
This worked correct, but can you tell me why mine didn't ?
Reply
#6

Because You Can't Check Weather a Player is Freezed or Not Like That..
Reply
#7

Quote:
Originally Posted by CSSI
Посмотреть сообщение
Because You Can't Check Weather a Player is Freezed or Not Like That..
Ah i understand, if i with that command set player color gray, how can i set the color back to the original team color without have to define all teams and colors?
Reply
#8

Do You have a Function to set the Players Score according to his Team? if yes then use it in Your /back Command.
Reply
#9

Quote:
Originally Posted by CSSI
Посмотреть сообщение
Do You have a Function to set the Players Score according to his Team? if yes then use it in Your /back Command.
Im not sure what you are meaning, players gets score if killing someone, doesnt matter who it is or so
Reply
#10

Ah My Bad i meant Color not Score
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)