Can I create my own include file for my custom map?
#1

Hello, I am new to SA-MP scripting and I am thinking about having a go at creating my own Free roam game mode. My first focus, will be the map (spawning ramps, and other objects around). I could write all of the code inside the "OnPlayerConnectInit()" method, but the problem is- my code will not look neat and therefore, will not be very readable.

So the question is, can I move all of the code for spawning objects in an include file, then include it into my gamemode file and then, on "OnPlayerConncetInit()" method, call the function (which is in the include) that will spawn all of the objects? Also, would it actually be a better thing to do, rather than writing all of the code inside "OnPlayerConnectInit()"?

Thank you for taking your time, and I am looking froward to your responses.
Reply
#2

It sure is possible, but not really the most efficient way I think...

- You could just create a custom function in your gamemode, place this at the bottom of the script so it's in the way and call that function at OnPlayerConnect.

pawn Код:
public OnPlayerConnect(playerid)
{
    CreatePlayerObjects(playerid);
    return 1;
}

CreatePlayerObjects(playerid)
{
    CreatePlayerObject(playerid, ......);
    CreatePlayerObject(playerid, ......);
    CreatePlayerObject(playerid, ......);
    CreatePlayerObject(playerid, ......);
    return 1;
}
You could also put your object inside a filterscript, so you can edit and reload the objects without restarting the server.
Reply
#3

Quote:
Originally Posted by Schneider
Посмотреть сообщение
It sure is possible, but not really the most efficient way I think...

- You could just create a custom function in your gamemode, place this at the bottom of the script so it's in the way and call that function at OnPlayerConnect.

pawn Код:
public OnPlayerConnect(playerid)
{
    CreatePlayerObjects(playerid);
    return 1;
}

CreatePlayerObjects(playerid)
{
    CreatePlayerObject(playerid, ......);
    CreatePlayerObject(playerid, ......);
    CreatePlayerObject(playerid, ......);
    CreatePlayerObject(playerid, ......);
    return 1;
}
You could also put your object inside a filterscript, so you can edit and reload the objects without restarting the server.
Thank you, I'l keep that in mind.
Reply
#4

You're welcome. I use the same method when I have a lot Textdraws in my gamemode, just put them at the bottom of the script in a custom function so I don't have scroll through it everytime.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)