SA-MP Forums Archive
afk and back command getting errors - 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: afk and back command getting errors (/showthread.php?tid=400594)



afk and back command getting errors - Mustafa6155 - 19.12.2012

its in dutch but i changed it!
pawn Код:
CMD:weg(playerid,params[]) // afk command
{
        if(PlayerAFK[playerid] == 0)
        {
           new pName[MAX_PLAYER_NAME];
           GetPlayerName(playerid,pName,sizeof(pName));
           new string[120];
           format(string,sizeof(string),"%s(%d) Is nou AwayFromKeyBoard[AFK]!",pName,playerid); // name id is afk!
           TogglePlayerControllable(playerid,0);
           PlayerAFK[playerid] = 1; //afk!
           SendClientMessageToAll(-1,string);
        }
        if(PlayerAFK[playerid] == 1) return SendClientMessage(playerid,-1,"Je Bent al AwayFromKeyboard[AFK]!"); // your already afk
        } // error line one!
    } // error line second!
  return 1; // third!
}

CMD:terug(playerid,params[]) //back command!
{
   if(PlayerAFK[playerid] == 0) return SendClientMessage(playerid,-1,"Je bent niet AwayFromKeyboard[AFK]!");// your arnt afk
   if(PlayerAFK[playerid] == 1)
   {
      new pName[MAX_PLAYER_NAME];
      GetPlayerName(playerid,pName,sizeof(pName));
      new string[120];
      format(string,sizeof(string),"%s(%d) Is terug gekomen!",pName,playerid); //name id comes back
      TogglePlayerControllable(playerid,1);
      SendClientMessageToAll(-1,string);
      PlayerAFK[playerid] = 0; //not any more afk
    }
  return 1; // error last!
}
i getting this following errors i thread any thing but dont work
Код:
C:\Users\Mustafa\Desktop\SAmp SRV\ForYou\gamemodes\TDMNIEUW.pwn(1039) : warning 209: function "cmd_weg" should return a value
C:\Users\Mustafa\Desktop\SAmp SRV\ForYou\gamemodes\TDMNIEUW.pwn(1040) : error 054: unmatched closing brace ("}")
C:\Users\Mustafa\Desktop\SAmp SRV\ForYou\gamemodes\TDMNIEUW.pwn(1041) : error 010: invalid function or declaration
C:\Users\Mustafa\Desktop\SAmp SRV\ForYou\gamemodes\TDMNIEUW.pwn(1057) : warning 217: loose indentation
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Thank you for reading and i hope you can help me.


Re: afk and back command getting errors - CoaPsyFactor - 19.12.2012

delete both } before return 1;


Re: afk and back command getting errors - Mustafa6155 - 19.12.2012

pawn Код:
CMD:weg(playerid,params[])
{
        if(PlayerAFK[playerid] == 0)
        {
           new pName[MAX_PLAYER_NAME];
           GetPlayerName(playerid,pName,sizeof(pName));
           new string[120];
           format(string,sizeof(string),"%s(%d) Is nou AwayFromKeyBoard[AFK]!",pName,playerid);
           TogglePlayerControllable(playerid,0);
           PlayerAFK[playerid] = 1;
           SendClientMessageToAll(-1,string);
        }
        if(PlayerAFK[playerid] == 1) return SendClientMessage(playerid,-1,"Je Bent al AwayFromKeyboard[AFK]!");
     }
   return 1;
}
Same errors?


Re: afk and back command getting errors - LetsOWN[PL] - 19.12.2012

Quote:
Originally Posted by Mustafa6155
Посмотреть сообщение
pawn Код:
CMD:weg(playerid,params[])
{
        if(PlayerAFK[playerid] == 0)
        {
           new pName[MAX_PLAYER_NAME];
           GetPlayerName(playerid,pName,sizeof(pName));
           new string[120];
           format(string,sizeof(string),"%s(%d) Is nou AwayFromKeyBoard[AFK]!",pName,playerid);
           TogglePlayerControllable(playerid,0);
           PlayerAFK[playerid] = 1;
           SendClientMessageToAll(-1,string);
        }
        if(PlayerAFK[playerid] == 1) return SendClientMessage(playerid,-1,"Je Bent al AwayFromKeyboard[AFK]!");
     }
   return 1;
}
Same errors?
Here:
pawn Код:
CMD:weg(playerid,params[])
{
        if(PlayerAFK[playerid] == 0)
        {
           new pName[MAX_PLAYER_NAME];
           GetPlayerName(playerid,pName,sizeof(pName));
           new string[120];
           format(string,sizeof(string),"%s(%d) Is nou AwayFromKeyBoard[AFK]!",pName,playerid);
           TogglePlayerControllable(playerid,0);
           PlayerAFK[playerid] = 1;
           SendClientMessageToAll(-1,string);
        }
        if(PlayerAFK[playerid] == 1) return SendClientMessage(playerid,-1,"Je Bent al AwayFromKeyboard[AFK]!");
     
   return 1;
}
Greetz,
LetsOWN



Re: afk and back command getting errors - Mustafa6155 - 19.12.2012

Код:
C:\Users\Mustafa\Desktop\SAmp SRV\ForYou\gamemodes\TDMNIEUW.pwn(1040) : warning 217: loose indentation
C:\Users\Mustafa\Desktop\SAmp SRV\ForYou\gamemodes\TDMNIEUW.pwn(1055) : warning 217: loose indentation
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Warnings.



Re: afk and back command getting errors - LetsOWN[PL] - 19.12.2012

Quote:
Originally Posted by Mustafa6155
Посмотреть сообщение
Код:
C:\Users\Mustafa\Desktop\SAmp SRV\ForYou\gamemodes\TDMNIEUW.pwn(1040) : warning 217: loose indentation
C:\Users\Mustafa\Desktop\SAmp SRV\ForYou\gamemodes\TDMNIEUW.pwn(1055) : warning 217: loose indentation
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Warnings.
These warnings are caused by mess in the code.

What I mean is, that you would have receive same warnings, when instead of:
pawn Код:
SomecodeHere()
{
    SomeHere()
    {
        blabla
        ???
    }
    return Trollface;
}
you would have writen
pawn Код:
SomecodeHere()
{
SomecodeHere()
{
blabla
???
}
return Trollface;
}
You can fix this by either removing mess from the code or use
pawn Код:
#pragma tabsize 0
at the very top of your script

I hope you understood what I wanted to say.

How can I see, this causes problem:
pawn Код:
if(PlayerAFK[playerid] == 1) return SendClientMessage(playerid,-1,"Je Bent al AwayFromKeyboard[AFK]!");
     
   return 1; // <<<<
}
Greetz,
LetsOWN



Re: afk and back command getting errors - Mustafa6155 - 19.12.2012

Thnx
I was forgot
#pragma tabsize 0


Re: afk and back command getting errors - Mustafa6155 - 19.12.2012

How i will fix it then?
I dont have a idea!