Tryed to make a AFK command and it isnt working!
#1

Yo im trying to make a afk command and the cmd is /goafk but when i do it in game it says the follow: Unknown Command, it's soooo annoying please help!

Compiler and PAWN


In Game (Sorry it turned into pixels :S):


I will Rep to anyone can make it work first (BTW i have made sure the right gm is on server.cfg if you need to do anything else add me on skype and we can chat and maybe use TV (Teamviewer)

Skype: elementstars
Reply
#2

health > 100 that will never be true you want something like

if(health >= 95.0)
else if(health < 95.0)

you can also remove the two return 1; lines they only serve to inflate your code.
Reply
#3

Not to mention the obvious fact that you are defining a cell length of 10, when the command is only 5 or 6 cells long.

Change this line:
pawn Код:
if(strcmp("/goafk", cmdtext, true, 10) == 0)
to:
pawn Код:
if(strcmp(cmdtext, "/goafk", true) == 0)
NOTE: The cell length is OPTIONAL. Read here for more information on the function: https://sampwiki.blast.hk/wiki/strcmp
Reply
#4

Maybe change like this :
pawn Код:
if(strcmp("/goafk", cmdtext, true, 5) == 0)
Reply
#5

Try this AFK System
Код:
#include <a_samp>

#define COLOR_RED 0xFF0000AA
#define COLOR_GREY 0xC0C0C0AA

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" Idea By DR.Lozer | Creator: ReD_Boii1");
	print("--------------------------------------\n");
	return 1;
}

enum pinfo {
	AFK,
	Float:Px,
	Float:Py,
	Float:Pz,
};
new PlayerInfo[MAX_PLAYERS][pinfo];

PlayerName(playerid)
{
	new pname[24]; GetPlayerName(playerid, pname,24);
	return pname;
}

public OnPlayerText(playerid, text[])
{
	if(PlayerInfo[playerid][AFK] == 1)
	{
	    SendClientMessage(playerid, COLOR_RED,"ERROR: Your AFk You Cant Talk");
	    return 0;
	}
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	new string[128];
	if (strcmp("/afk", cmdtext, true, 10) == 0)
	{
	    if(PlayerInfo[playerid][AFK] == 1) return SendClientMessage(playerid, COLOR_RED,"ERROR: Your Already AFK");
        PlayerInfo[playerid][AFK] = 1;
		TogglePlayerControllable(playerid, 0);
		GameTextForPlayer(playerid,"~r~AFK",1000,1);
		format(string,128,"%s is now AFK",PlayerName(playerid));
	    SendClientMessageToAll(COLOR_GREY,string);
		return 1;
	}
	if (strcmp("/back", cmdtext, true, 10) == 0)
	{
	    if(PlayerInfo[playerid][AFK] == 0) return SendClientMessage(playerid, COLOR_RED,"ERROR: Your not AFK");
	    PlayerInfo[playerid][AFK] = 0;
	    TogglePlayerControllable(playerid, 1);
	    GameTextForPlayer(playerid,"~r~AFK BACK",1000,1);
	    format(string,128,"%s is Back From AFK",PlayerName(playerid));
	    SendClientMessageToAll(COLOR_GREY,string);
	    return 1;
	}
	if (strcmp("/afklist", cmdtext, true, 10) == 0)
	{
	    new Count = 0;
	    for(new i = 0; i< MAX_PLAYERS; i++) if(IsPlayerConnected(i) && PlayerInfo[playerid][AFK] == 1) Count++;
	    if(Count <= 0) return SendClientMessage(playerid, COLOR_RED,"No one is afk");
	    format(string,128,"There Are %d Afk Player",Count);
	    SendClientMessage(playerid, COLOR_RED,string);
	    for(new i = 0; i< MAX_PLAYERS; i++) if(IsPlayerConnected(i) && PlayerInfo[playerid][AFK] == 1) {
	        format(string,128,"%s (%d) AFK",PlayerName(i),i);
	        SendClientMessage(playerid, COLOR_GREY,string);
		}
	    return 1;
	}
	return 0;
}
This was not coded by me!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)