Command HELP -
necrobg3 - 24.09.2012
Hey guys. I was wondering if i have afk system and when player is freezed ( toggle ) how to make if he try to type anythinng to return sendclientmessage You are afk, type /back to get back in the game ?
+REP for the dude who help me.
Re: Command HELP -
ejul - 25.09.2012
like this??
Код:
new pMuted[MAX_PLAYERS];
new Text:afk;
public OnPlayerText(playerid, text[])
{
if(pMuted[playerid] == 1)
{
SendClientMessage(playerid,red,"Error:You're muted so you cannot talk");
return 0;
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/afk", true) == 0)
{
new name[32], szString[64];
GetPlayerName(playerid, name, 32);
SetPVarInt(playerid, "AFK", 1);
format(string, sizeof(string), "%s is now away from keyboard", name);
SendClientMessageToAll(0xFFFFFFAA, string);
TogglePlayerControllable(playerid, 0);
SetPlayerHealth(playerid, 10000000);
(pMuted[playerid] == 1);
OldName[playerid] = name;
format(szString, 64, "[AFK]%s", name);
SetPlayerName(playerid, szString);
return 1;
}
}
Re: Command HELP -
clarencecuzz - 25.09.2012
STRCMP
pawn Код:
new PlayerAFK[MAX_PLAYERS]; //At the top of your script
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/afk", true) == 0)
{
if(PlayerAFK[playerid] == 1) return SendClientMessage(playerid, 0xFF0000FF, "You Are Already AFK, Use {00FF00}/BACK {FF0000}To Return To The Game.");
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
new string[60];
format(string,sizeof(string),"Player %s Is Now AFK.",name);
SendClientMessageToAll(0x00FF00FF, string);
PlayerAFK[playerid] = 1;
return 1;
}
if(strcmp(cmdtext, "/back", true) == 0)
{
if(PlayerAFK[playerid] == 0) return SendClientMessage(playerid, 0xFF0000FF, "You Are Not AFK. Use {00FF00}/AFK {FF0000}.");
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
new string[60];
format(string,sizeof(string),"Player %s Has Returned To The Game.",name);
SendClientMessageToAll(0x00FF00FF, string);
PlayerAFK[playerid] = 0;
return 1;
}
return 0;
}
public OnPlayerText(playerid, text[])
{
if(PlayerAFK[playerid] == 1)
{
SendClientMessage(playerid, 0xFF0000FF, "You Are AFK And Cannot Speak. Use {00FF00}/BACK{FF0000} To Return To The Game.");
return 0;
}
return 1;
}
ZCMD
pawn Код:
new PlayerAFK[MAX_PLAYERS]; //Top of your script
CMD:afk(playerid,params[])
{
if(PlayerAFK[playerid] == 1) return SendClientMessage(playerid, 0xFF0000FF, "You Are Already AFK, Use {00FF00}/BACK {FF0000}To Return To The Game.");
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
new string[60];
format(string,sizeof(string),"Player %s Is Now AFK.",name);
SendClientMessageToAll(0x00FF00FF, string);
PlayerAFK[playerid] = 1;
return 1;
}
CMD:back(playerid,params[])
{
if(PlayerAFK[playerid] == 0) return SendClientMessage(playerid, 0xFF0000FF, "You Are Not AFK. Use {00FF00}/AFK {FF0000}.");
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
new string[60];
format(string,sizeof(string),"Player %s Has Returned To The Game.",name);
SendClientMessageToAll(0x00FF00FF, string);
PlayerAFK[playerid] = 0;
return 1;
}
public OnPlayerText(playerid, text[])
{
if(PlayerAFK[playerid] == 1)
{
SendClientMessage(playerid, 0xFF0000FF, "You Are AFK And Cannot Speak. Use {00FF00}/BACK{FF0000} To Return To The Game.");
return 0;
}
return 1;
}
Re: Command HELP -
necrobg3 - 25.09.2012
Tried it but don't work. Anyways it will be easy if i give my command and you guys can reply with the edit.
pawn Код:
if (strcmp("/afk", cmdtext, true, 10) == 0)
{
if(AFK[playerid] == 0)
{
new pname[MAX_PLAYER_NAME], string[39 + MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(string, 280, "%s has gone AFK.", pname);
SendClientMessageToAll(COLOR_PINK, string);
TogglePlayerControllable(playerid,0);
AFK[playerid] = 1;
}
else return SendClientMessage(playerid, COLOR_RED, "ERROR: You are already AFK.");
return 1;
}
if (strcmp("/back", cmdtext, true, 10) == 0)
{
if(AFK[playerid] == 1)
{
new pname[MAX_PLAYER_NAME], string[39 + MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(string, 280, "%s is now back from being AFK.", pname);
SendClientMessageToAll(COLOR_PINK, string);
TogglePlayerControllable(playerid,1);
AFK[playerid] = 0;
}
else return SendClientMessage(playerid, COLOR_RED, "ERROR: You aren't AFK.");
return 1;
}
I want when player is afk to be unable to speak. ( only the player can type /back )
Re: Command HELP -
XtremeR - 25.09.2012
very easy one
pawn Код:
public OnPlayerText(playerid, text[])
{
if(AFK[playerid] == 1)
{
SendClientMessage(playerid,-1,"SERVER:You Cant Speak While AFK");
}
else if(AFK[playerid] == 0)
{
//ur code here
}
return 1;
}
Tested it Works with 0 Warnings i hope that i helped
Re: Command HELP -
YourLord - 25.09.2012
this should work, XtremeR, your code won't work. it should return instead of keep going.
pawn Код:
new bool:isafk[MAX_PLAYERS];
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/afk", true))
{
if(isafk[playerid]) return SendClientMessage(playerid, 0xFF0000FF, "You Are Already AFK, Use {00FF00}/BACK {FF0000}To Return To The Game.");
format(cmdtext,128,"Player %s Is Now AFK.",getname(playerid));
SendClientMessageToAll(0x00FF00FF, cmdtext);
isafk[playerid] = true;
return 1;
}
if(!strcmp(cmdtext, "/back", true))
{
if(!isafk[playerid]) return SendClientMessage(playerid, 0xFF0000FF, "You Are Not AFK. Use {00FF00}/AFK {FF0000}.");
format(cmdtext,128,"Player %s Has Returned To The Game.",getname(playerid));
SendClientMessageToAll(0x00FF00FF, cmdtext);
isafk[playerid] = false;
return 1;
}
return 0;
}
getname(p)
{
static name[24];
GetPlayerName(p,name,sizeof name);
return name;
}
public OnPlayerText(playerid, text[])
{
if(isafk[playerid]) return SendClientMessage(playerid,-1,"SERVER:You Cant Speak While AFK");
return 1;
}
Re: Command HELP -
necrobg3 - 25.09.2012
Didn't work guys. I make it same like you said and the player is able to speak.
Re: Command HELP -
YourLord - 25.09.2012
post here, your onplayertext, you're doing something wrong.
Re: Command HELP -
necrobg3 - 25.09.2012
pawn Код:
public OnPlayerText(playerid, text[])
{
if(isafk[playerid]) return SendClientMessage(playerid, COLOR_RED, "ERROR: You are AFK and cannot speak. Use /back to return into the game.");
return 1;
}
Only this.
Re: Command HELP -
necrobg3 - 25.09.2012
So? Can anyone help me?