Define making the compiler never stop
#1

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?
Reply
#2

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

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

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.
Reply
#5

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...
Reply
#6

"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)
Reply
#7

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

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

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


Forum Jump:


Users browsing this thread: 2 Guest(s)