[HELP] "#Define" using || config file to mode
#1

Firstly, hello guys.

I want to do config file for my fs like "maximum veh" etc. But this is not working.



I'm using

#define MAX_VEH dini_Int(configfile,"MAX_VEH")

this code. But this code take an error (crash).



If you know then please help me. I hope you help to me.
Reply
#2

pawn Код:
new MAX_VEH = dini_Int(configfile, MAX_VEH");
Make sure you have configfile defined of course.
Reply
#3

Quote:
Originally Posted by Carlton
Посмотреть сообщение
pawn Код:
new MAX_VEH = dini_Int(configfile, MAX_VEH");
Make sure you have configfile defined of course.
again take an error (crash)
Reply
#4

Uhmm, can you post full MAX_VEH Script?
Reply
#5

for(new i = 1; i < MAX_VEH; i++)
{
........
}
Reply
#6

Why not making it a function instead of a define? Like this:

pawn Код:
MaxVeh()
{
return dini_Int(configfile,"MAX_VEH");
}
Should work the same, i guess?!
Reply
#7

Functions are slower than constants / varibles.

I don't know, I've been through the same 'phase' for MAX_PLAYERS.

Really, just leave it as it is.

Quote Kyosaur: "Don't make assumsions"

-
If you redefine MAX_PLAYERS to 100 for example, and you forgot that it was redefined, and changed slots to 150, then your loops would be 50 iterations short.

I was thinking of ways to stop 500 iterations (MAX_PLAYERS LOOP) but really IT IS the best thing.

but when he kind of explained to me the 'IF you ever have over 1000 vehicles and you redefined them to 500' stuff.

You understand that it's best to leave it.. I mean, ofcourse it's a big loop (2000 = MAX_VEHICLES), but then you don't have to redefine in every script.

The speed results aren't that bad either.. You don't notice it ingame unless it's more than 2000 ms, and the results were WAY under that.

So to quote Kyosaur again: "Don't make assumsions"
Reply
#8

If you're really that silly, then use
pawn Код:
for (new i = 0, max = GetMaxPlayers(); i < max; i++) {}
And arguing over function vs variable vs constant/defines speed is pointless, really. Even more then sscand vs strtok
Reply
#9

Quote:
Originally Posted by dice7
Посмотреть сообщение
If you're really that silly, then use
pawn Код:
for (new i = 0, max = GetMaxPlayers(); i < max; i++) {}
And arguing over function vs variable vs constant/defines speed is pointless, really. Even more then sscand vs strtok
I hope that loop example wasn't pointed at me (as I also use that).

And arguing over functions vs varible vs constant speed is not pointless, it's the combined effect of cutting down uneeded things many times that counts.

and have you ever speed tested strtok vs. sscanf, and if I remember correctly, sscanf is a plugin, strtok is pawn, so sscanf is bound to be faster (and way easier / more functionality)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)