Mapping in include
#1

Hi,

How can i set my mapping in include plz ?
It will allow me to reduce my gamemode and add easily mapping (just drag and drop in .inc ).

Thx
Reply
#2

What have you tried?
Reply
#3

Insert my mapping (CreateObject and RemoveBuildingForPlayer) directly in mapping.inc
And does not work ;/
Reply
#4

well,you can simply put all you objects in a seperate file.
But that'll be a .pwn one, not an include

if that's done, you simply load it in your gamemode using #include

but not like
#include <a_samp>

lets say the file with your map inside is called mymap.pwn (you don't need to compile it)
now make sure that 'mymap.pwn' is in the same folder as your gamemode's .amx
then we'regoing to include it like this:

#include "mymap.pwn"

if you create a new folder in gamemodes, you woull do this:

#include "some_folder/mymap.pwn"


simple as that.
You can split up your whole script - not jsut the maps.
Doing this is a good thing, you'll have a real structure at the end
cuz every single part of your script is in a seperate file.
The main task of the gamemode at the end will only be -> loading all the other files and working with them.
Most ppls think fixing an error in a system like this will take forever. but it's not, if you know your script well
and where all the parts are.

Don't fear it! try something new, split up your whole gamemode in hindrets of seperate files
Reply
#5

Oh, nice thanks
I will do that

EDIT :
pawn Код:
Symbol already defined: "CreateObject"
Reply
#6

Quote:
Originally Posted by FosterK
Посмотреть сообщение
Oh, nice thanks
I will do that

EDIT :
pawn Код:
Symbol already defined: "CreateObject"
okey, here's an example of mine


So here is the main Gamemode file:
pawn Код:
#include <a_samp>
#include <YSI\y_commands>
#include "maps/test.pwn"

forward load();

main(){}

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

YCMD:lol(playerid,params[],help)
{
    SetPlayerPos(playerid,0,0,3);
    return 1;
}

YCMD:ob(playerid,params[],help)
{
    CallLocalFunction("load","","");
    return 1;
}
there we have all we need for this small test.
we need
'a_samp' -> for the CreateObject and CallLocalFunction function as well as the OnGMInit public
#include "maps/test.pwn" -> that's the file our map is inside
#include <YSI\y_commands> -> that's just for debugging, loading the object and teleporting to where it is
forward load(); -> inside the map file, we store our objects in a public (making it public to all the other scripts, like the main gm) called "load" so we have to forward it.
main(){} -> just cuz every main gm need's this, same as in C.
CallLocalFunction("load","",""); -> and this is the part where we load all of the stuff which is in the public load inside the other file


so now let me show you the test.pwn where our map is stored:

pawn Код:
public load()
{
    CreateObject(1080,1,1,1,1,1,1);
    return 1;
}
well, that's pretty much self explaining...
really, that's all there is to it you don't have to add any more includes to this file or other stuff
this file simply is just 1 public, a member of the main GM.
Building a structure like this where all the different systems are seperated, that's real programming.
you gotta buildup a structure, seriously thinking about what stuff you put where and which stuff you should seperatefrom other stuff and link it all together so that at the end every single file, out of, lets say 100 files are connected with eachother. communicating using callocalfunctuion. passing down variables to other script files is possible too.

so now when we compile the main gm, it will also compile all the stuff in our seperate files, like the map file test.pwn
The compiler adds all that stuff on top of the script even before the actual compilation.


sorry, i should've explained it like this from the beginning
Reply
#7

Oh nice, thanks !
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)