SA-MP Forums Archive
Define making the compiler never stop - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Define making the compiler never stop (/showthread.php?tid=133474)



Define making the compiler never stop - Coicatak - 12.03.2010

Hi!

Well I have these defines:
pawn Код:
#define IsGangSkin(%0) ((%0 >= 102 && %0 <= 110) || (%0 >= 114 && %0 <= 116) || (%0 >= 173 && %0 <= 175) || (%0 >= 269 && %0 <= 270))
#define IsMafiaSkin(%0) (%0 == 112 || %0 == 124 || %0 == 126 || %0 == 127)
#define IsPublicServicesSkin(%0) ((%0 >= 274 && %0 <= 288) || (%0 >= 265 && %0 <= 267))
#define IsReservedSkin(%0) (IsGangSkin(%0) || IsGangSkin(%0) || IsMafiaSkin(%0) || IsPublicServicesSkin(%0))
And when I use it here:
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
  if(IsReservedSkin(classid)) GameTextForPlayer(playerid, "~r~Skin reserve", 1000, 6)
  return 1;
}
It fails. Actually I click the "Compile" icon then the compiler starts but ir will NEVER stop. I have to stop the pawncc.exe processus. Any idea why?


Re: Define making the compiler never stop - aircombat - 12.03.2010

it should be :
stock IsGangSkin(playerid) not #define


Re: Define making the compiler never stop - Coicatak - 12.03.2010

A function isn't needed is this case, it's less quick than a define. Call a function is slow.


Re: Define making the compiler never stop - Extremo - 12.03.2010

Lets have a direct look at your defines:
pawn Код:
#define IsGangSkin(%0) ((%0 >= 102 && %0 <= 110) || (%0 >= 114 && %0 <= 116) || (%0 >= 173 && %0 <= 175) || (%0 >= 269 && %0 <= 270))
#define IsMafiaSkin(%0) (%0 == 112 || %0 == 124 || %0 == 126 || %0 == 127)
#define IsPublicServicesSkin(%0) ((%0 >= 274 && %0 <= 288) || (%0 >= 265 && %0 <= 267))
#define IsReservedSkin(%0) (IsGangSkin(%0) || IsGangSkin(%0) || IsMafiaSkin(%0) || IsPublicServicesSkin(%0))
So now I saw you using this small line:

pawn Код:
if(IsReservedSkin(classid))
Which for the compiler will look like:

pawn Код:
if(((%0 >= 102 && %0 <= 110) || (%0 >= 114 && %0 <= 116) || (%0 >= 173 && %0 <= 175) || (%0 >= 269 && %0 <= 270)) || ((%0 >= 102 && %0 <= 110) || (%0 >= 114 && %0 <= 116) || (%0 >= 173 && %0 <= 175) || (%0 >= 269 && %0 <= 270)) || (%0 == 112 || %0 == 124 || %0 == 126 || %0 == 127) || ((%0 >= 274 && %0 <= 288) || (%0 >= 265 && %0 <= 267)))
So, what I think the problem is, is likely the fact that if you spread it out and actually do it in a small syntax way of looking:

pawn Код:
if(
  (
   (%0 >= 102 && %0 <= 110)
   ||
   (%0 >= 114 && %0 <= 116)
   ||
   (%0 >= 173 && %0 <= 175)
   ||
   (%0 >= 269 && %0 <= 270)
  )
  ||
  (
    (%0 >= 102 && %0 <= 110)
    ||
    (%0 >= 114 && %0 <= 116)
    ||
    (%0 >= 173 && %0 <= 175)
    ||
    (%0 >= 269 && %0 <= 270)
  )
  ||
  (%0 == 112 || %0 == 124 || %0 == 126 || %0 == 127)
  ||
  (
    (%0 >= 274 && %0 <= 288)
    ||
    (%0 >= 265 && %0 <= 267)
  )
)
So, what I would suggest you(because I assume its just a brakets fault, you can easily just change your defines and make them look like this:

pawn Код:
#define IsGangSkin(%0) %0 >= 102 && %0 <= 110 || %0 >= 114 && %0 <= 116 || %0 >= 173 && %0 <= 175 || %0 >= 269 && %0 <= 270
#define IsMafiaSkin(%0) %0 == 112 || %0 == 124 || %0 == 126 || %0 == 127
#define IsPublicServicesSkin(%0) %0 >= 274 && %0 <= 288 || %0 >= 265 && %0 <= 267
#define IsReservedSkin(%0) IsGangSkin(%0) || IsGangSkin(%0) || IsMafiaSkin(%0) || IsPublicServicesSkin(%0)
Now I assume it should work just fine as long as you remain using it in if's.

EDIT: Hold on. I think I found a small problem just by reading my own post again. Try this once:
pawn Код:
if(ReservedSkin(classid)
Just remove the last braket and try to compile it. See what happens.


Re: Define making the compiler never stop - Coicatak - 12.03.2010

pawn Код:
if(IsReservedSkin(classid) GameTextForPlayer(playerid, "~r~Skin reserved", 1000, 6);
Gives: error 001: expected token: ")", but found "-identifier-"

Removing the brackets in defines works fine. But the checks may fail IG then...


Re: Define making the compiler never stop - Extremo - 12.03.2010

"may"? "may" is a short for "maybe", so do they fail or not? I can't really work with a maybe :P. Well, at the very moment all you are saying at least is that it possibly doesn't work, it can work but doesn't have to? Or did you test it?

Ah I think I know what you mean, this should work fine for you then:

pawn Код:
#define IsGangSkin(%0) (%0 >= 102 && %0 <= 110) || (%0 >= 114 && %0 <= 116) || (%0 >= 173 && %0 <= 175) || (%0 >= 269 && %0 <= 270)
#define IsMafiaSkin(%0) %0 == 112 || %0 == 124 || %0 == 126 || %0 == 127
#define IsPublicServicesSkin(%0) (%0 >= 274 && %0 <= 288) || (%0 >= 265 && %0 <= 267)
#define IsReservedSkin(%0) IsGangSkin(%0) || IsGangSkin(%0) || IsMafiaSkin(%0) || IsPublicServicesSkin(%0)



Re: Define making the compiler never stop - Coicatak - 12.03.2010

Well none of the way you or me posted works now --'

I've made functions it works fine. Fuck it ><


Re: Define making the compiler never stop - Extremo - 12.03.2010

If you posted what doesn't work, I could of helped, but alright