Franc[e]sco Posted January 3, 2008 Share Posted January 3, 2008 Ok, i'm making my 1st gamemode, a very simple deathmatch just to learn some LUA, and here's the problem: as i join the server -> /votemode -> simpledm (my gamemode) it says started simple dm, then started bloodybox (the gamemode's map) and then black screen instead of spawn... Here's the source: • simpledm.zip |-- meta.xml <meta> <info author="Franc[e]sco" description="Simple Deathmatch" type="gamemode" /> <script src="server.lua" /> </meta> |-- server.lua -- Simple DM - coded by Franc[e]sco players = getElementsByType ( "player" ) root = getRootElement () function spawnPlayer (thePlayer) local playerSpawnPoint = call (getResourceFromName("spawnmanager"),"getRandomSpawnpoint") call (getResourceFromName("spawnmanager"),"spawnPlayerAtSpawnpoint",thePlayer,playerSpawnPoint) fadeCamera ( source, true ) end function onPlayerJoin () playerName = getClientName(source) outputChatBox("Welcome, " .. playerName .. ", this server is actually running Simple Deathmatch by Franc[e]sco", source) spawnPlayer(source) end addEventHandler("onPlayerJoin", root, onPlayerJoin) function onPlayerDeath () outputChatBox("You died! Please wait 10 seconds to respawn", source) setTimer(spawnPlayer, 10000, 1, source) end addEventHandler("onPlayerWasted", root, onPlayerDeath) • bloodybox.zip |-- meta.xml <meta> <info author="Franc[e]sco" description="A small map for extreme deathmatches" type="map" gamemodes="simpledm" /> <map src="bloodybox.map" /> <script src="script.lua" /> </meta> |-- bloodybox.map <map mod="deathmatch" version="1.0"> <meta> <author>Franc[e]sco</author> <version>0.1</version> <name>Bloody box</name> <description>Crazy deathmatch</description> </meta> <spawnpoint posX="3421.267090" posY="-1546.364136" posZ="39.248020" rot="0" skin="0" interior="0" dimension="0" /> <spawnpoint posX="3407.545898" posY="-1546.580078" posZ="39.186665" rot="0" skin="0" interior="0" dimension="0" /> <spawnpoint posX="3387.096191" posY="-1547.516724" posZ="39.454590" rot="0" skin="0" interior="0" dimension="0" /> <spawnpoint posX="3420.681641" posY="-1510.488159" posZ="39.239620" rot="0" skin="0" interior="0" dimension="0" /> <spawnpoint posX="3404.905029" posY="-1511.002686" posZ="39.237484" rot="0" skin="0" interior="0" dimension="0" /> <spawnpoint posX="3387.964844" posY="-1510.464355" posZ="39.271309" rot="0" skin="0" interior="0" dimension="0" /> <spawnpoint posX="3419.712402" posY="-1502.146362" posZ="22.285946" rot="0" skin="0" interior="0" dimension="0" /> <spawnpoint posX="3405.734131" posY="-1503.052856" posZ="22.277327" rot="0" skin="0" interior="0" dimension="0" /> <spawnpoint posX="3387.575195" posY="-1503.615845" posZ="22.485300" rot="0" skin="286" interior="0" dimension="0" /> <spawnpoint posX="3386.568115" posY="-1546.704590" posZ="22.263044" rot="0" skin="286" interior="0" dimension="0" /> <spawnpoint posX="3399.408203" posY="-1546.596802" posZ="22.269600" rot="0" skin="286" interior="0" dimension="0" /> <spawnpoint posX="3421.499512" posY="-1547.485474" posZ="22.283976" rot="0" skin="286" interior="0" dimension="0" /> <spawnpoint posX="3393.754883" posY="-1505.973511" posZ="31.660557" rot="0" skin="286" interior="0" dimension="0" /> <spawnpoint posX="3400.283936" posY="-1507.614502" posZ="33.657486" rot="0" skin="286" interior="0" dimension="0" /> <spawnpoint posX="3400.341064" posY="-1504.529297" posZ="29.457432" rot="0" skin="286" interior="0" dimension="0" /> <spawnpoint posX="3406.293213" posY="-1507.656006" posZ="35.860611" rot="0" skin="286" interior="0" dimension="0" /> </map> |-- script.lua function mapLoad(name) createObject(3983, 3404.731201, -1526.936523, 23.624731, 0.0000, 0.0000, 0.0000) createObject(3983, 3387.905518, -1527.186768, 32.624733, 0.0000, 90.2409, 0.0000) createObject(3983, 3420.326904, -1521.111694, 32.624733, 0.0000, 90.2409, 182.0965) createObject(3983, 3408.901611, -1503.010376, 32.624733, 0.0000, 91.1003, 272.3375) createObject(3983, 3408.926514, -1547.310669, 32.624733, 0.0000, 91.1003, 90.2409) createObject(3983, 3404.731201, -1526.936523, 51.374733, 0.0000, 180.4820, 0.0000) createObject(3983, 3404.731201, -1542.187012, 40.549725, 0.0000, 0.0000, 0.0000) createObject(3983, 3404.955322, -1541.737305, 36.499649, 0.0000, 180.4820, 0.0000) createObject(3399, 3411.878662, -1503.062012, 24.215816, 0.0000, 0.0000, 188.6717) createObject(3399, 3400.371826, -1504.812500, 28.765804, 0.0000, 0.0000, 188.6717) createObject(3399, 3400.294189, -1507.640747, 32.965858, 0.0000, 0.0000, 0.5587) createObject(969, 3391.658691, -1500.882324, 31.092058, 266.3214, 3.4377, 282.9689) createObject(3399, 3409.544189, -1507.640747, 36.240875, 0.0000, 0.0000, 0.5587) createObject(969, 3414.442871, -1507.829468, 38.517120, 266.3214, 0.0000, 270.0000) createObject(925, 3420.059814, -1540.482178, 22.689754, 0.0000, 0.0000, 0.0000) createObject(925, 3415.954346, -1537.199219, 22.663198, 0.0000, 0.0000, 0.0000) createObject(925, 3406.375977, -1536.315063, 22.663198, 0.0000, 0.0000, 0.0000) createObject(925, 3401.902100, -1534.704834, 22.705301, 0.0000, 0.0000, 0.0000) createObject(925, 3401.406494, -1525.278442, 22.742367, 0.0000, 0.0000, 0.0000) createObject(925, 3403.253418, -1523.866577, 22.720238, 0.0000, 0.0000, 0.0000) createObject(925, 3394.223145, -1514.075562, 22.904266, 0.0000, 0.0000, 0.0000) createObject(944, 3413.396973, -1526.512817, 22.486080, 0.0000, 0.0000, 33.7500) createObject(944, 3405.102539, -1517.788452, 22.535776, 0.0000, 0.0000, 0.0000) createObject(944, 3411.190430, -1512.399536, 22.486080, 0.0000, 0.0000, 22.5000) createObject(931, 3411.395264, -1548.199219, 22.677711, 0.0000, 0.0000, 90.0000) createObject(931, 3411.469238, -1543.873779, 22.663198, 0.0000, 0.0000, 90.0000) createObject(931, 3411.449707, -1545.996338, 22.665375, 0.0000, 0.0000, 90.0000) createObject(931, 3393.603271, -1548.425537, 22.683208, 0.0000, 0.0000, 90.0000) createObject(931, 3393.624268, -1543.861694, 22.694653, 0.0000, 0.0000, 90.0000) createObject(931, 3393.605713, -1546.098633, 22.693037, 0.0000, 0.0000, 90.0000) createObject(931, 3392.800293, -1526.011597, 22.864033, 0.0000, 0.0000, 90.0000) createObject(931, 3390.443359, -1531.249023, 22.881367, 0.0000, 0.0000, 90.0000) createObject(931, 3392.669922, -1527.212036, 22.869278, 0.0000, 0.0000, 90.0000) createObject(1685, 3396.818848, -1501.971680, 22.451813, 0.0000, 0.0000, 0.0000) createObject(1685, 3396.824707, -1502.770630, 22.478695, 0.0000, 0.0000, 0.0000) createObject(1685, 3396.857422, -1502.978760, 22.480766, 0.0000, 0.0000, 0.0000) createObject(1685, 3396.781982, -1503.509644, 22.487837, 0.0000, 0.0000, 0.0000) createObject(1685, 3396.928223, -1503.794189, 22.489529, 0.0000, 0.0000, 0.0000) createObject(1685, 3396.919922, -1504.314209, 22.495720, 0.0000, 0.0000, 0.0000) createObject(1685, 3396.972168, -1509.989990, 39.314728, 0.0000, 0.0000, 0.0000) createObject(1685, 3396.887207, -1510.801270, 39.300499, 0.0000, 0.0000, 0.0000) createObject(1685, 3396.930420, -1512.523071, 39.306656, 0.0000, 0.0000, 0.0000) createObject(1685, 3412.490723, -1509.977539, 39.330223, 0.0000, 0.0000, 0.0000) createObject(1685, 3412.512207, -1511.089355, 39.326435, 0.0000, 0.0000, 0.0000) createObject(1685, 3412.515625, -1512.690552, 39.321869, 0.0000, 0.0000, 0.0000) createObject(1685, 3398.325684, -1547.600708, 39.596134, 0.0000, 0.0000, 0.0000) createObject(1685, 3398.283691, -1546.101807, 39.388889, 0.0000, 0.0000, 0.0000) createObject(1685, 3398.431396, -1544.215088, 39.399426, 0.0000, 0.0000, 0.0000) createObject(1685, 3414.454590, -1546.656494, 39.276287, 0.0000, 0.0000, 0.0000) createObject(1685, 3414.440186, -1548.381226, 39.276287, 0.0000, 0.0000, 0.0000) createObject(1685, 3414.484131, -1544.940674, 39.276287, 0.0000, 0.0000, 0.0000) createObject(2567, 3396.681641, -1533.894531, 40.630146, 0.0000, 0.0000, 33.7500) createObject(2567, 3409.271240, -1534.916748, 40.453888, 0.0000, 0.0000, 348.7500) createObject(2567, 3412.967041, -1522.562744, 40.453888, 0.0000, 0.0000, 11.2500) createObject(2567, 3393.853516, -1520.749268, 40.646645, 0.0000, 0.0000, 0.0000) createObject(944, 3403.388672, -1529.018799, 39.502983, 0.0000, 0.0000, 0.0000) createObject(944, 3390.986084, -1537.586670, 39.653366, 0.0000, 0.0000, 348.7500) createObject(944, 3418.504395, -1525.017090, 39.411076, 0.0000, 0.0000, 348.7500) createObject(944, 3394.825439, -1509.170898, 31.884966, 0.0000, 0.0000, 6.7982) end --//--------------------------------------------------------------------------// addEventHandler("onResourceStart", getRootElement(), mapLoad) sorry for my english. ps: yeah i had to create objects with a lua script because converting the objects from mta race to mta DM was too long so i converted the objects to pawn and then removed the ";" and replaced CreateObject with createObject Link to comment
[email protected] Posted January 3, 2008 Share Posted January 3, 2008 Ok, I haven't taken a really deep look in your script, but it seems that: Here you call the function spawnPlayer(source), where source is the player object defined by the event handler. # function onPlayerJoin () # playerName = getClientName(source) # outputChatBox("Welcome, " .. playerName .. ", this server is actually running Simple Deathmatch by Franc[e]sco", source) # spawnPlayer(source) # end Ok, let's have a look at the spawnPlayer function then.. Previously you called this function with the argument "thePlayer"'s value as "source", Notice that the value of source has been inserted in this function's argument. To get access to this value (namely the player object from the onPlayerJoin function), you have to use thePlayer, because the value is held in this variable within this function. # function spawnPlayer (thePlayer)# local playerSpawnPoint = call (getResourceFromName("spawnmanager"),"getRandomSpawnpoint") # call (getResourceFromName("spawnmanager"),"spawnPlayerAtSpawnpoint",thePlayer,playerSpawnPoint) # fadeCamera ( source, true ) # end # To make a long story short: find in spawnPlayer (thePlayer): fadeCamera( source, true ) replace with: fadeCamera( thePlayer, true ) Link to comment
Franc[e]sco Posted January 3, 2008 Author Share Posted January 3, 2008 I just watched closer the code and fixed many errors: -- Simple DM - coded by Franc[e]sco players = getElementsByType ( "player" ) root = getRootElement () function spawnPlayer (thePlayer) local playerSpawnPoint = call(getResourceFromName("spawnmanager"), "getRandomSpawnpoint") call(getResourceFromName("spawnmanager"), "spawnPlayerAtSpawnpoint", thePlayer, playerSpawnPoint) fadeCamera(thePlayer, true) end function onPlayerJoin () local playerName = getClientName(source) outputChatBox("Welcome, " .. playerName .. ", this server is actually running Simple Deathmatch by Franc[e]sco", source) spawnPlayer(source) end addEventHandler("onPlayerJoin", root, onPlayerJoin) function onPlayerDeath () outputChatBox("You died! Please wait 10 seconds to respawn", source) setTimer(spawnPlayer, 10000, 1, source) end addEventHandler("onPlayerWasted", root, onPlayerDeath) now there's another problem... when i try to connect it says fatal error and when i check the server it says theres a error with the call function Link to comment
[email protected] Posted January 4, 2008 Share Posted January 4, 2008 Might be useful to copy and paste the exact error output from your server Link to comment
ChrML Posted January 4, 2008 Share Posted January 4, 2008 The issue is that you only spawn the players that join the server and those who dies. You don't spawn those that are already in the server when the gamemode starts. Try adding this code: -- Called by the gamemode manager when a map is started inside our gamemode -- Do the spawning on map start because when the gamemode starts there are no spawnpoints to spawn the players on yet. function onMapStartHandler ( startedMap ) -- Get all the player elements and loop through them local playersToSpawn = getElementsByType ("player") for k,player in ipairs ( playersToSpawn ) do -- Call spawnPlayer for every player already in the server when the map starts spawnPlayer( player ) end end addEventHandler ( "onGamemodeMapStart", getRootElement (), onMapStartHandler ) Link to comment
ChrML Posted January 4, 2008 Share Posted January 4, 2008 Oh btw, you can use the tag in the map instead of creating all the objects from script. The map editor will output .map files with objects in them and it's easier and more efficient . For example: <object id="object (12)" posX="-2221.680664" posY="-2361.010010" posZ="35.525673" rotX="0.981748" rotY="0.000000" rotZ="0.000000" model="3406" /> Link to comment
Franc[e]sco Posted January 4, 2008 Author Share Posted January 4, 2008 Oh btw, you can use the tag in the map instead of creating all the objects from script. The map editor will output .map files with objects in them and it's easier and more efficient . For example: <object id="object (12)" posX="-2221.680664" posY="-2361.010010" posZ="35.525673" rotX="0.981748" rotY="0.000000" rotZ="0.000000" model="3406" /> ps: yeah i had to create objects with a lua script because converting the objects from mta race to mta DM was too long so i converted the objects to pawn and then removed the ";" and replaced CreateObject with createObject btw thanks for the code, i was thinking about that too but its not the problem sinche new it says fatal error when i join... it gives an error on the call funtion it says something like "check it exists" maybe if i use a call i should add something in the meta? EDIT: i solved exporting the getRandomPlayerSpawn but i still got the fatal error in the client when i connect and the server says nothing: [11:02:08] CONNECT: Franc[e]sco connected (IP: 127.0.0.1)[11:02:26] JOIN: Franc[e]sco joined the game (IP: 127.0.0.1) [11:02:27] QUIT: Franc[e]sco left the game [Quit] EDIT2: i noticed the spawnPlayer is a MTA DM function so i renamed it to spawnThePlayer but it still gives fatal error EDIT3: i debugged the spawnThePlayer like this: function spawnThePlayer (thePlayer) outputDebugString("spawnThePlayer: spawnThePayer called successfully") local playerSpawnPoint = {} playerSpawnPoint = call(getResourceFromName("spawnmanager"), "getRandomSpawnpoint") if(playerSpawnPoint == true) then outputDebugString("spawnThePlayer: player's spawnpoint stored") else outputDebugString("spawnThePlayer: playerSpawnPoint has errors") end call(getResourceFromName("spawnmanager"), "spawnPlayerAtSpawnpoint", thePlayer, playerSpawnPoint) outputDebugString("spawnThePlayer: player spawned successfully") fadeCamera(thePlayer, true) outputDebugString("spawnThePlayer: camera faded") end and it says playerSpawnPoint has errors Link to comment
ChrML Posted January 5, 2008 Share Posted January 5, 2008 Fatal error shouldn't be related to the script being wrong. Fatal error means that something failed downloading and that we should look into why. Can you past your meta.xml file? Link to comment
BrokenGlass Posted January 5, 2008 Share Posted January 5, 2008 Where do i get the spawnmanager and mapeditor? Link to comment
Franc[e]sco Posted January 5, 2008 Author Share Posted January 5, 2008 NVM, i don't use the spawnsystem anymore, now another problem, check out my other topic viewtopic.php?f=91&t=21041 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now