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