else -
cruising - 17.11.2011
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;
}
Re: else -
SmiT - 17.11.2011
This should help you:
https://sampwiki.blast.hk/wiki/Control_Structures#else
Re: else -
cruising - 17.11.2011
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;
}
Re: else -
HyperZ - 17.11.2011
Under incs:
OnPlayerConnect:
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;
}
Re: else -
cruising - 17.11.2011
Quote:
Originally Posted by HyperZ
Under incs:
OnPlayerConnect:
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 ?
Re: else -
CSSI - 17.11.2011
Because You Can't Check Weather a Player is Freezed or Not Like That..
Re: else -
cruising - 17.11.2011
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?
Re: else -
CSSI - 17.11.2011
Do You have a Function to set the Players Score according to his Team? if yes then use it in Your /back Command.
Re: else -
cruising - 17.11.2011
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
Re: else -
CSSI - 17.11.2011
Ah My Bad i meant Color not Score