Using callbacks in a include -
Remi-X - 29.11.2009
Hi, I wanted to know how I can use normal callbacks in includes? I thought I saw it earlier in other includes, but I don't know which anymore.
Explanation:
I want to use OnGameModeInit with a include, but I want to hold that callback in my GameMode. I know I can make a callback in the include called OnGameModeInit2, and start it with a script.
But I don't want to do that. I want to use OnGameModeInit in my includes, and in my GM. Without any scripts that calls a callback, or namechanges.
How?
Re: Using callbacks in a include -
saiberfun - 29.11.2009
Quote:
Originally Posted by Remi-X
Hi, I wanted to know how I can use normal callbacks in includes? I thought I saw it earlier in other includes, but I don't know which anymore.
Explanation:
I want to use OnGameModeInit with a include, but I want to hold that callback in my GameMode. I know I can make a callback in the include called OnGameModeInit2, and start it with a script.
But I don't want to do that. I want to use OnGameModeInit in my includes, and in my GM. Without any scripts that calls a callback, or namechanges.
How?
|
you can't since the include isnt ur gm i guess :P
so OnGameModeInit doesn't get called there
Re: Using callbacks in a include -
Luka P. - 29.11.2009
Yeah, I try that too, and getting ""OnGameModeInit" is already defined."
Hmm, I think that isn't possible.
Re: Using callbacks in a include -
Remi-X - 29.11.2009
But I saw enough includes (dunno which anymore) who does what I want.
Код:
//ChocolateInclude
public OnGameModeInit()
{
//Code
}
#if defined ALS_OnGameModeInit
undef OnGameModeInit
//or something, with a little more script. It was a bit like this, I thought.
Код:
//GameMode
#include <ChocolateInclude>
public OnGameModeInit()
{
//script
}
Without any errors, warnings or problems.
Re: Using callbacks in a include - Zeex - 29.11.2009
http://forum.sa-mp.com/index.php?topic=110767.0
Re: Using callbacks in a include -
Luka P. - 29.11.2009
Thanks
Re: Using callbacks in a include -
Remi-X - 29.11.2009
So, I'm supposed to do this:
ChocolateInclude
pawn Код:
public OnGameModeInit()
{
//script
if (funcidx("Chocolate_OnGameModeInit") != -1)
{
return CallLocalFunction("Chocolate_OnGameModeInit", "");
}
return 1;
}
#if defined _ALS_OnGameModeInit
#undef OnGameModeInit
#else
#define _ALS_OnGameModeInit
#endif
#define OnGameModeInit Chocolate_OnGameModeInit
forward Chocolate_OnGameModeInit();
GameMode
pawn Код:
#include <ChocolateInclude>
public OnGameModeInit()
{
//script
return 1;
}
?
Re: Using callbacks in a include -
dice7 - 29.11.2009
The simplest way is
pawn Код:
// streamer.h
stock StartStreaming()
{
//stuff to init
}
pawn Код:
#include <streamer>
public OnGameModeInit()
{
StartStreaming();
return 1;
}
Re: Using callbacks in a include -
Remi-X - 29.11.2009
Quote:
Originally Posted by dice7
The simplest way is
...
|
No, that isn't what I wanted. That's exactly what I DIDN'T want. I think that's irritating after almost 20 includes with little scripts, which I'm making.
Don't ask why I'm using 20 includes, because I'll answer it already for you: Than are all my scripts easier to edit and read. I'm getting confused if I'm using a lot of lines with a lot of little functions, so this is much and much easier for me.