SA-MP Forums Archive
Some Error ... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Some Error ... (/showthread.php?tid=351279)



Some Error ... - Eiy Mard - 15.06.2012

Please help me .. i got this

need fixed this ... if i type /back and /afklist its will give .: ERROR: Your status is already AFK/BRB :.

Код HTML:
	if (strcmp("/afk", cmdtext, true, 10) == 0){
	}
   		new string[256];
 		if (PlayerInfo[playerid][AFKstatus] == 1)
   		{
     		SendClientMessage(playerid, COLOR_RED, ".: ERROR: Your status is already AFK/BRB :.");
       		return 1;
         	}
          	else if (PlayerInfo[playerid][AFKstatus] == 0)
           	{
            new pname[MAX_PLAYER_NAME];
           	GetPlayerName(playerid, pname, sizeof(pname));
            format(string, sizeof(string), ".: ( %s ) is away from keyboard :.", pname,playerid);
            SendClientMessageToAll(COLOR_YELLOW, string);
            TogglePlayerControllable(playerid,0);
            SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(playerid) + 50);
            PlayerInfo[playerid][AFKstatus] = 1;
            return 1;
   	}
	if (strcmp("/brb", cmdtext, true, 10) == 0){
	}
  		if (PlayerInfo[playerid][AFKstatus] == 1)
    	{
     		SendClientMessage(playerid, COLOR_RED, "ERROR: You are Aready Afk/And or Brb");
       		return 1;
         	}
			else if (PlayerInfo[playerid][AFKstatus] == 0)
   			{
      		new pname[MAX_PLAYER_NAME];
        	GetPlayerName(playerid, pname, sizeof(pname));
         	format(string, sizeof(string), ".: ( %s ) Will Be Right Back (BRB) :.", pname,playerid);
          	SendClientMessageToAll(COLOR_GREEN, string);
           	TogglePlayerControllable(playerid,0);
       		SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(playerid) + 50);
         	PlayerInfo[playerid][AFKstatus] = 1;
          	return 1;
	}
	if (strcmp("/back", cmdtext, true, 10) == 0){
	}
 		if (PlayerInfo[playerid][AFKstatus] == 0)
   		{
     		SendClientMessage(playerid, COLOR_RED, "ERROR: You are Aready Back!");
       		return 1;
         	}
          	else if (PlayerInfo[playerid][AFKstatus] == 1)
           	{
            new pname[MAX_PLAYER_NAME];
           	GetPlayerName(playerid, pname, sizeof(pname));
            format(string, sizeof(string), ".:( %s ) has Came Back:.", pname,playerid);
            SendClientMessageToAll(COLOR_GREEN, string);
            TogglePlayerControllable(playerid,1);
            SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(playerid) - 50);
            PlayerInfo[playerid][AFKstatus] = 0;
            return 1;
	}
	if (strcmp("/afklist", cmdtext, true, 10) == 0){
	}
        new count = 0;
        new name[MAX_PLAYER_NAME];
  		SendClientMessage(playerid, COLOR_LIGHTBLUE, "The Afk List:");
        for(new i = 0; i < MAX_PLAYERS; i++)
                {
                        if (IsPlayerConnected(i))
                        {

                            if(PlayerInfo[i][AFKstatus] == 1)
                            {
                                        GetPlayerName(i, name, sizeof(name));
                                        format(string, 256, ".: Away From KeyBoard %s :. ", name,i );
                                        SendClientMessage(playerid, COLOR_YELLOW, string);
                                count++;
                                }
                        }

                }
                if (count == 0)
                {
                SendClientMessage(playerid, COLOR_RED, ".: No one Is Afk :.");
                return 1;
	}
hope can help me


Re: Some Error ... - JaTochNietDan - 15.06.2012

If you started indenting your code you would see where all of the issues are immediately. Take the first two lines for example:

pawn Код:
if (strcmp("/afk", cmdtext, true, 10) == 0){
    }
Don't you see a problem there? The code to be execute when that if statement is true is completely empty, the same is true for other commands down the line.

I recommend that you read the getting started on programming manual over at the official PAWN site. Or else find a tutorial elsewhere which teaches you the basics!


Re: Some Error ... - Eiy Mard - 15.06.2012

ok .. its fixed ..