Maps from external file -
DLR - 25.04.2014
Hello all. I use external files for pretty much everything. In my game mode I simply include the pwn files. However, when it came to doing all of my mapping, it gave me this error.
pawn Код:
./includes/maps_exterior.pwn(4) : error 021: symbol already defined: "CreateDynamicObject"
./includes/maps_exterior.pwn(574) : error 010: invalid function or declaration
./includes/maps_exterior.pwn(574) : error 021: symbol already defined: "RemoveBuilding"
./includes/maps_exterior.pwn(574) : error 010: invalid function or declaration
./includes/maps_exterior.pwn(574) : fatal error 107: too many error messages on one line
My game mode has this line to include the script.
pawn Код:
#include "./includes/maps_exterior.pwn"
Should I put the Include RemoveBuilding part in the external file or in the main game mode?
Re: Maps from external file -
biker122 - 25.04.2014
Why don't you put RemoveBuildingForPlayer in the gamemode?
Under OnPlayerConnect(playerid)
Re: Maps from external file -
Vince - 25.04.2014
Despite being in a different file, maps must still appear in the right callback. But since you can include files anywhere, you should just move your include line inside OnGameModeInit. The RemoveBuilding lines, however, should appear in OnPlayerConnect (like said above) and thus should either be moved there, or to a different file (which is then include in OnPlayerConnect).
Re: Maps from external file -
CutX - 25.04.2014
do itlike this,
in your external file, put all your createDynamicObject's in a public.. let's call it 'Objects'
then again, create another public called 'RemoveObj' in your external file and put all the RemoveBuilding's inside.
now just save that file and include it as always ontop of your script.
What we do now is just make use of the function 'CallLocalFunction'
to call these two public functions we've created.
call the one for objects in OnGamemodeInit and the other one for remove in OnPlayerConnect. easy as that
would look like this:
external file
pawn Код:
forward Objects();
public Objects()
{
CreateDynamicObject(//...
//and so on
return 1;//you could also use the return value to check if the map was loaded successfully or not
}
forward RemoveObj(playerid);
public RemoveObj(playerid)
{
RemoveBuildingForPlayer(playerid,//...
//and so on
return 1;
}
Gamemode
pawn Код:
//include it at the top as always
public OnGamemodeInit()
{
//now we just call our function
CallLocalFunction("Objects","");//no params here
return 1;
}
public OnPlayerConnect(playerid)
{
//jsut calling it again
CallLocalFunction("RemoveObj","d",playerid);//we also "deliver" the playerid to that function
return 1;
}
side note: we use public cuz we have to make it "public" so that it can be accessed from outside.
stock won't work, you can't call it using CallLocalFunction
Re: Maps from external file -
Vince - 25.04.2014
Don't see why it would need to be public, or why CallLocalFunction should be used for that matter. It is INCLUDED after all, it's not a separate script. Call it like any other normal function.
Re: Maps from external file -
DLR - 27.04.2014
Thanks for the help guys. I decided to convert it into a filterscript, which seemed to work much easier. All I needed to do was include the RemoveBuilding inc, and the Streamer inc.