SA-MP Forums Archive
I was wondering.. - 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: I was wondering.. (/showthread.php?tid=279251)



I was wondering.. - Azzeto - 26.08.2011

I was wondering if there was a way to make it like auto have all the classes so when a player chooses classes or if I need to
AddPlayerClass
manually with all the skins, Thanks.


Re: I was wondering.. - Bakr - 26.08.2011

pawn Код:
public OnGameModeInit( )
{
   for( new i = 0; i < 299; i++ )
   {
      switch( i ) case 1..6, 8, 42, 65, 74, 86, 119, 149, 208, 239, 265..273: continue;
      AddPlayerClass( i, 0.00, 0.00, 0.00, 0.00, 0, 0, 0, 0, 0, 0 );
   }
   return 1;
}
Replace the X, Y, and Z coordinates with your desired ones.


Re: I was wondering.. - Azzeto - 26.08.2011

2 errors (ignore the warnings)
pawn Код:
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\SDKFreeRoam.pwn(83) : error 001: expected token: "{", but found "case"
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\SDKFreeRoam.pwn(84) : error 002: only a single statement (or expression) can follow each "case"
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\SDKFreeRoam.pwn(84) : warning 215: expression has no effect
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\SDKFreeRoam.pwn(90) : warning 225: unreachable code
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\SDKFreeRoam.pwn(554) : warning 217: loose indentation
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\SDKFreeRoam.pwn(558) : warning 217: loose indentation
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\SDKFreeRoam.pwn(842) : warning 203: symbol is never used: "label"
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\SDKFreeRoam.pwn(1055) : warning 225: unreachable code
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\SDKFreeRoam.pwn(1342) : warning 217: loose indentation
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\SDKFreeRoam.pwn(339) : warning 204: symbol is assigned a value that is never used: "a51gate"



Re: I was wondering.. - Bakr - 26.08.2011

Sorry, I forgot you cannot use the switch statement like so:
pawn Код:
public OnGameModeInit( )
{
   for( new i = 0; i < 299; i++ )
   {
      switch( i )
      {
         case 1..6, 8, 42, 65, 74, 86, 119, 149, 208, 239, 265..273: continue;
      }
      AddPlayerClass( i, 0.00, 0.00, 0.00, 0.00, 0, 0, 0, 0, 0, 0 );
   }
   return 1;
}
And you should never ignore your warnings! After all, the compiler is telling you SOMETHING is wrong. Especially unreachable code warnings.


Re: I was wondering.. - Azzeto - 26.08.2011

Meh, im a nooby scripter, and I'v read some where that warnings were telling you somthing, but it wasnt a big deal if they were there.


Re: I was wondering.. - Bakr - 26.08.2011

Technically, you can run your server with them, but they CAN alter the output of the code. Not to mention, it looks ugly when your compilation output is filled with warning lines.

Loose indention errors are caused by incorrect horizontal indention
pawn Код:
// Bad indention
if( a == 1 )
{
   function( );
     function( );
}

//Good indention
if( a == 1 )
{
   function( );
   function( );
}
Symbol is ever used is caused for you creating a variable, or stock function, that you never use. You can simply delete that variable/function. In this case, it seems to be a variable called "label" on line 842.

Symbol is assigned to a value that is never used is when you assign a variable a value, and you never use that value later in the script. My guess, with your script, is that you have assigned a variable to the "a51gate" variable and never use it, with CreateObject line. Simply remove the variable from that line, and where you declare it.

Unreachable code is when you end the function/callback before it can execute specific code. This is mostly caused by using return statement too much. An example:
pawn Код:
function( a )
{
   if( a == 1 )
   {
      print( "a = 1" );
      return 1;
   }
   else
   {
      print( "a != 1" );
      return 1;
   }

   print( "function finished" );
   return 1;
}
As you can see, "function finished" would never be printed because regardless of what a equals, it'll already return a value, and end the function (inside the if or else check)

Expression has no effect warning, it depends. Please show the line that that warning occurs on.


Re: I was wondering.. - Azzeto - 26.08.2011

Okay, ill fix the errors thanks, but when I added that one code it removed my mapping .


Re: I was wondering.. - Bakr - 26.08.2011

You shouldn't have REPLACED the callback, but add the data I posted into the existing one.


Re: I was wondering.. - Azzeto - 26.08.2011

I know,I didnt replace it, because i commented it out and now my mappings back.