25.04.2014, 16:37
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
Gamemode
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
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;
}
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;
}
stock won't work, you can't call it using CallLocalFunction