[FS|INC] GMCycle - Gamemode Rotation without bounds.
#1

GMCycle
Rotate as many gamemodes as you want!

Introduction :

GMCycle is a method of cycling as many gamemodes as you want. Currently, you are restricted to 16 gamemode choices (gamemode0 - gamemode15), but with this script you can use as many as you need. This howto is aimed at intermediate scripters.

It is very important that you read all the detail below, to fully understand how the script works.


The Filterscript :

The GMCycle filterscript is there to do all the calculation, it checks which gamemode should be running where, and put it into the correct order. Every time GameModeExit() is called, the include, which I will explain in the next section, bypasses the regular GameModeExit() native to call the scripts main function, GameModeInitEx() remotely.


The Include :

The a_samp.inc include houses out native for GameModeExit(). We need to change values in here, as they would be already defined if we tried to use them in our own include. In order to get GameModeInitEx() to be called, we have to edit the way it is accessed.

We will change:
pawn Код:
native GameModeExit();
To:
pawn Код:
native r_GameModeExit() = GameModeExit;
stock GameModeExit() CallRemoteFunction("GameModeExitEx", "");
So we can call the function. Of course, if you aren't running the filterscript when you try and call GameModeExit(), you are going to have problems.

Once you have the include changed, you must recompile all scripts you want to use with the script, or it will call the original native.

As IJzerenRita pointed out below, you can use a #define to get the job done also, this means you don't have to touch the include, but you need to add it to all the gamemodes you want to use.

Quote:
Originally Posted by IJzerenRita
Instead of changing the .inc, which could cause problems when compiling a "regular" game mode, you could add a #define like so:
pawn Код:
#define GameModeExit() CallRemoteFunction("GameModeExitEx", "")
This will replace any GameModeExit() call with the remote function call. You can add this define to the game mode you like to work with GMCycle.
The List of gamemodes :

I have not added support for multiple sessions of the same gamemode, as this can be done scriptwise anyhow. By default, your file to read from should be "/scriptfiles/gmcycle.txt." Please set it out like so:

Quote:

lvdm
sftdm
cng
area51

Replacing the gamemode names with whatever way you want, however you want. If you make a mistake with the spelling, again, your gonna have problems .


Downloads :

Filterscript (Pastebin)
a_samp.inc (Pastebin)

Cheers,
Ramjet.
Reply
#2

Well this is very good, i'm going to try it, good work.
Reply
#3

Very nice ramjet
Reply
#4

Nice
Reply
#5

pretty nice.
Reply
#6

Instead of changing the .inc, which could cause problems when compiling a "regular" game mode, you could add a #define like so:
pawn Код:
#define GameModeExit() CallRemoteFunction("GameModeExitEx", "")
This will replace any GameModeExit() call with the remote function call. You can add this define to the game mode you like to work with GMCycle.
Reply
#7

Nice ramjet! I would just like to know what inspires you these good ideas
Reply
#8

Quote:
Originally Posted by IJzerenRita
Instead of changing the .inc, which could cause problems when compiling a "regular" game mode, you could add a #define like so:
pawn Код:
#define GameModeExit() CallRemoteFunction("GameModeExitEx", "")
This will replace any GameModeExit() call with the remote function call. You can add this define to the game mode you like to work with GMCycle.
Hey that works! Thats for the tip . I decided to change the include as I don't see much reason why it shouldn't be running anyway (if you actually need to run more than 16 scripts). It won't cause problems when compiling a regular gamemode if you have GMCycle running, that was the point I was trying to make.

I'll add this tip to the post as it's more practical than editing the include I suppose.

Cheers,
Ramjet.
Reply
#9

Good idea and good work
Reply
#10

Hello, My server crashes when the last mode starts.

Quote:
Originally Posted by gmcycle.txt
Mode1
Mode2
Mode3
Mode4
Anything wrong?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)