Y_Masters
#1

Can anybody show me an example of how y_masters, can be used to share data between a filter script and a game mode?
Reply
#2

Anyone know how to use y_masters?
Reply
#3

Actually, I'm kinda confused to use y_master too. My project needs to follow this structure:

[gamemode.pwn -> Contains the functions that can be accessed by filterscript.pwn and anticheat.pwn]
[filterscript.pwn -> Calls the functions on gamemode.pwn]
[anticheat.pwn -> Calls the functions on gamemode.pwn]

Since I'm using CallRemoteFunction, I suppose I'll get some problems calling declared 'public' functions that exists on all these scripts. Will y_master solve this problem?
Reply
#4

Also, my current structure is this:

pawn Код:
[gamemode.pwn]

forward Something();
public Something(); { return 42; }

[filterscript.pwn -> functions.inc]
stock Something() { return CallRemoteFunction("Something", ""); }

[anticheat.pwn -> functions.inc]
stock Something() { return CallRemoteFunction("Something", ""); }
I know that, at this moment, there isn't any problem. Since CallRemoteFunction just call declared public functions, that script above will run perfectly. But I wonder if I start creating these declared public functions, I'll have some problems like, the function getting called 2 times, or the returned value being wrong..
Reply
#5

Quote:
Originally Posted by ******
Посмотреть сообщение
Yes, y_master will solve that problem, by using "SERVER" and "CLIENT" scripts.
I did and I didn't skip around ^_~
But I don't know... Your tutorials are great and everything except there for people around your level I guess,
I just need somebody to show me a working script that shows. How it is used. Tutorials are great and everything but sometimes you need a live example. Just so that I can see it with my own eyes, and think to my self " oh so this is what it does"

I'll read your tutorial again and tell you where I get lost.
Reply
#6

Quote:
Originally Posted by paulommu
Посмотреть сообщение
Also, my current structure is this:

pawn Код:
[gamemode.pwn]

forward Something();
public Something(); { return 42; }

[filterscript.pwn -> functions.inc]
stock Something() { return CallRemoteFunction("Something", ""); }

[anticheat.pwn -> functions.inc]
stock Something() { return CallRemoteFunction("Something", ""); }
I know that, at this moment, there isn't any problem. Since CallRemoteFunction just call declared public functions, that script above will run perfectly. But I wonder if I start creating these declared public functions, I'll have some problems like, the function getting called 2 times, or the returned value being wrong..
I wanna know how to solve it to!
But also something like this can be used, right?

[gamemode.pwn]
stock Something() { return CallRemoteFunction("Something", ""); }


[filterscript.pwn -> functions.inc]
forward Something();
public Something(); { return 42; }
Reply
#7

Quote:
Originally Posted by ******
Посмотреть сообщение
Yes, y_master will solve that problem, by using "SERVER" and "CLIENT" scripts.
OK so my questions are:
https://sampforum.blast.hk/showthread.php?tid=296907
PHP код:
*fs_streamer.pwn
pawn Code
:
#define YSI_IS_SERVER
#include <funcs_streamer>
*fs_users.pwn
pawn Code
:
#define YSI_IS_SERVER
#include <funcs_users> 
You never included the .pwn files. Is this correct?
Or do we have to include it?
PHP код:
gamemode.pwn
pawn Code
:
#define YSI_IS_CLIENT
#include <fs_streamer>
#include <fs_users>
main()
{

Or was this correct (your code):
PHP код:
gamemode.pwn
pawn Code
:
#define YSI_IS_CLIENT
#include <funcs_streamer>
#include <funcs_users>
main()
{

Also a few lines after that,
Here you simply combine two files into one, but the define and the include separate the code am I correct.
This way you could just have one file instead of 8?
PHP код:
funcs_users.inc
This is using 
"MASTER" number 1.
pawn Code
:
#define YSI_IS_CLIENT
#define MASTER 1
#include <YSI\y_master>
static stock
    gsLoggedIn
[MAX_PLAYERS];
foreign bool:IsLoggedIn(playerid);
global 
bool:IsLoggedIn(playerid)
{
    return 
gsLoggedIn[playerid];
}
#define MASTER 2
#include <YSI\y_master>
foreign AddObject(modelFloat:xFloat:yFloat:z);
global 
AddObject(modelFloat:xFloat:yFloat:z)
{
    new
        
objectid /* something */;
    return 
objectid;
}
main()
{

My last question is every time I need to use a function like:
global AddObject()

If it is master number 2, I define the Master number"2"
And include y_master,

And then later on in my [gamemode.pwn] after using AddObject()

If I want to you something that was define as Master number "1"
I do the same thing.

My question here is would I have to define Master number 2 and include y_master again?
If I wish to use AddObject() again?
Reply
#8

Quote:
Originally Posted by ******
Посмотреть сообщение
No, once "AddObject" has been declared, it knows which master to use forever. And the first version with multiple includes is better. You CAN do it all in one file, but that's not generally recommended.
Thank you!

Can anyone tell me if we just include the .inc files or the .pwn files?
In the game mode.

PHP код:
gamemode.pwn
pawn Code
:
#define YSI_IS_CLIENT
#include <fs_streamer>
#include <fs_users>
main()
{

****** has fs_streamer included but that's a typo right?
He has a .pwn file that includes the .inc ...so we only need to include the .pwn file in the gamemode not .inc.

Right?
Reply
#9

Also, so... Let's say I have 3 files with MASTER numbers
6 4 1

I just place them at the top of my gamemode like so?

PHP код:
#define MASTER 1
#include <YSI\y_master>
#define MASTER 6
#include <YSI\y_master>
#define MASTER 4
#include <YSI\y_master>
#include <YSI\y_master>// reset for commands ? 
Reply
#10

That's great!
So I only need the to include the .pwn file in the gamemode, and .inc is included by the .pwn.
I hope others learn from this
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)