XetaQuake Posted February 10, 2008 Share Posted February 10, 2008 hi, i am currenty making a vvveerryy litle gamemode, only to learn but the spawnpoint dont work, here is all my stuff: meta.xml <meta> <info author="XetaQuake" description="to learn" version="1.0" type="gamemode" /> <map src="spawnpoints.map"/> </meta> and my spawnpoints.map <map mod="deathmatch" version="1.0"> --Spawn weapons <weapon model="7" ammo="1"/> <weapon model="22" ammo="500"/> <weapon model="26" ammo="16"/> <weapon model="29" ammo="60"/> <weapon model="18" ammo="3"/> --Spawn skins <skin model="105"/> <skin model="106"/> <skin model="107"/> --spawnpoints <spawnpoint id="spawnpoint1" posX="2035.1265869141" posY="1524.2818603516" posZ="10.8203125" rot="0" /> <spawnpoint id="spawnpoint2" posX="2106.6000976563" posY="1403.9052734375" posZ="11.1328125" rot="0" /> <spawnpoint id="spawnpoint3" posX="2234.18359375" posY="1291.4482421875" posZ="10.8203125" rot="0" /> <spawnpoint id="spawnpoint4" posX="1975.0267333984" posY="1620.3448486328" posZ="12.88099861145" rot="0" /> --vehicles <vehicle model="419" posX="2509.6936035156" posY="-1668.8011474609" posZ="13.232522964478" rotX="358.50704956055" rotY="3.806396484375" rotZ="180.99597167969" /> <vehicle model="422" posX="2467.1323242188" posY="-1654.2012939453" posZ="13.385867118835" rotX="358.72198486328" rotY="354.78051757813" rotZ="94.365417480469" /> --pickups <pickup type="health" amount="100" posX="2302.6721191406" posY="-1449.0643310547" posZ="23.99250793457" /> <pickup type="health" amount="100" posX="1704.2354736328" posY="-1135.3688964844" posZ="24.085935592651" /> <pickup type="health" amount="100" posX="1911.2296142578" posY="-1776.4091796875" posZ="13.3828125" /> <pickup type="health" amount="100" posX="1408.5766601563" posY="-1419.2780761719" posZ="14.203125" /> </map> the spawnpoints dont work, i dont spawn! ONLY the vehicles works! but, and this is my second problem: all vehicles are black?! can someone help me on this two problems? Link to comment
Cazomino05 Posted February 10, 2008 Share Posted February 10, 2008 Black vehicles is just a bug where vehicles.conf isnt loaded before gamemode aparently its fixed in dp3 Link to comment
szlend Posted February 10, 2008 Share Posted February 10, 2008 Uhm you wont spawn just by making a map. You'll have to code a script that reads data from your map file ... Here's a nice example: <map> <spawnpoint id="spawnpoint1" posX="1959.5487060547" posY="-1714.4613037109" posZ="877.25219726563" rot="63.350006103516" model="0"/> <pickup id="Armor 1" posX="1911.083984375" posY="-1658.8798828125" posZ="885.40216064453" type="armor" health="50" respawn="60000"/> <flag posX="1959.5487060547" posY="-1714.4613037109" posZ="877.25219726563" team="blue" /> ... </map> local flagElements = getElementsByType ( "flag" ) -- loop through them for key, value in pairs(flagElements) do -- get our info local posX = getElementData ( value, "posX" ) local posY = getElementData ( value, "posY" ) local posZ = getElementData ( value, "posZ" ) local team = getElementData ( value, "team" ) -- create an object according to the flag position createObject ( 1337, posX, posY, posZ ) -- output the team that we created a base for outputChatBox ( "Base for team " .. team .. " created" ) end Link to comment
XetaQuake Posted February 10, 2008 Author Share Posted February 10, 2008 it that correct? local spawn = getElementsByType ( "spawnpoint" ) -- loop through them for key, value in pairs(spawn) do -- get our info local posX = getElementData ( value, "posX" ) local posY = getElementData ( value, "posY" ) local posZ = getElementData ( value, "posZ" ) -- create an object according to the flag position playerSpawn ( posX, posY, posZ ) end i dont have time to test it, so i have make it in my brain Link to comment
eAi Posted February 10, 2008 Share Posted February 10, 2008 Try it? It kinda depends what playerSpawn is, the rest you've copied and pasted... Link to comment
XetaQuake Posted February 10, 2008 Author Share Posted February 10, 2008 i dont was @ home, and i have post it that other members can already post stuff so no i have tried it, and - it dont work debugscript 3: 11: attempt to call global 'spawnPlayer' (a nil value) than i have seen that this is a server side script, so i have write it as server-side in the meta.xml and now it dont work again and the debugscript says noting. but i think this is because i have no addEventHandler, right? so i have write a addEventHandler: addEventHandler( "onClientResourceStart", getRootElement(), key ) and this dont work again, someone a idea? Link to comment
Jumba' Posted February 10, 2008 Share Posted February 10, 2008 what the heck is playerSpawn? the function spawnPlayer? try local spawn = getElementsByType ( "spawnpoint" ) -- loop through them for key, value in pairs(spawn) do -- get our info local posX = getElementData ( value, "posX" ) local posY = getElementData ( value, "posY" ) local posZ = getElementData ( value, "posZ" ) -- create an object according to the flag position spawnPlayer ( posX, posY, posZ ) end Link to comment
XetaQuake Posted February 10, 2008 Author Share Posted February 10, 2008 thanks for help but noting change btw: ah yes spawnPlayer Link to comment
Jumba' Posted February 10, 2008 Share Posted February 10, 2008 oh, hmph. btw, just a note, comments in XML aren't -- but You should fix those check in cdm.lua, maybe you can find some usefull stuff there. Link to comment
XetaQuake Posted February 11, 2008 Author Share Posted February 11, 2008 i have already looking in some lua scripts, but the problem is that the most gamemodes have teams or i dont can find the spawnpoint code stuff Link to comment
XetaQuake Posted February 12, 2008 Author Share Posted February 12, 2008 can nobody look what is wrong? pleas, in other lua scripts i cant it find or dont use Link to comment
szlend Posted February 12, 2008 Share Posted February 12, 2008 Frist, this code should execute when a player joins a server like this: http://development.mtasa.com/index.php? ... PlayerJoin And second, You need to specify a player element when calling the spawnPlayer function. Like: spawnPlayer ( source, posX, posY, posZ ) Link to comment
driver2 Posted February 12, 2008 Share Posted February 12, 2008 You probably wanna spawn every player at one of the spawnpoints randomly? -- This function spawn the given player at one of the spawnpoints function spawn(player) local spawnpoints = getElementsByType("spawnpoint") -- retrieve a table with all spawnpoints if (#spawnpoints == 0) then return false end -- if there are no spawnpoints, stop executing -- get a random number between 1 and the number of items in the table 'spawnpoints' local rand = math.random(1,#spawnpoints) -- retrieve the coordinates from the selected spawnpoint local posX = getElementData ( spawnpoints[rand], "posX" ) local posY = getElementData ( spawnpoints[rand], "posY" ) local posZ = getElementData ( spawnpoints[rand], "posZ" ) -- spawn the player spawnPlayer(player, posX, posY, posZ) end -- With just this function, nothing will happen at all. We still need to add event handlers that perform the desired action when the script is loaded as well as when a new player joins the game. function resourceStarted() for k,v in ipairs(getElementsByType("player")) do -- loop through all players currently on the server spawn(v) -- and spawn each one of them using the function we made before end end -- bind the handler to the root of THIS resource, meaning it will be triggered when THIS resource is started, else it would be triggered as soon as any other resource is started as well, as long as it runs addEventHandler("onResourceStart", getRootElement(getThisResource)), resourceStarted) function playerJoined() spawn(source) -- spawn the player who joined, in this event it is 'source' end addEventHandler("onPlayerJoin", getRootElement(), playerJoined) I haven't tested it, so it may still contain errors. Documentation pages you might wanna read to understand this: http://development.mtasa.com/index.php? ... entsByType http://development.mtasa.com/index.php? ... pawnPlayer http://development.mtasa.com/index.php? ... entHandler http://www.lua.org/manual/5.1/manual.ht ... ath.random Link to comment
XetaQuake Posted February 12, 2008 Author Share Posted February 12, 2008 thank you thank you thank you thank you!! this works sooo good and thanks for the links!! By the way: i think you have write a mistake on this script (or who write this) here the "fix": addEventHandler("onResourceStart", getRootElement(getThisResource)[b][color=#FF0000])[/color][/b], resourceStarted) change to addEventHandler("onResourceStart", getRootElement(getThisResource), resourceStarted) thanks for help! it works and i am so happy! Link to comment
XetaQuake Posted February 15, 2008 Author Share Posted February 15, 2008 so i have a next problem i have a place with a marker, and when i go in it, i want to get money, but i dont get the money (the marker are to see ) here is my code: function Place(name) if name ~= getThisResource() then return else local marker = createMarker ( -1025.5623779297, 457.65173339844, 14, "cylinder", 4, 0, 100, 200, 250 ) end end function Money( player ) givePlayerMoney( source, 10000 ) end Col = createColSphere ( -1025.5623779297, 457.65173339844, 14, 4 ) addEventHandler ( "onColShapeHit", Col, Money ) addEventHandler ( "onResourceStart", getRootElement(), Place) Link to comment
Ace_Gambit Posted February 15, 2008 Share Posted February 15, 2008 so i have a next problem i have a place with a marker, and when i go in it, i want to get money, but i dont get the money (the marker are to see ) here is my code: function Place(name) if name ~= getThisResource() then return else local marker = createMarker ( -1025.5623779297, 457.65173339844, 14, "cylinder", 4, 0, 100, 200, 250 ) end end function Money( player ) givePlayerMoney( source, 10000 ) end Col = createColSphere ( -1025.5623779297, 457.65173339844, 14, 4 ) addEventHandler ( "onColShapeHit", Col, Money ) addEventHandler ( "onResourceStart", getRootElement(), Place) The parameters passed by onColShapeHit are hitElement and matchingDimension. So my best guess is that would want to give money to hitElement instead. function Money( hitElement, matchingDimension) givePlayerMoney( hitElement, 10000 ) end Link to comment
mabako Posted February 15, 2008 Share Posted February 15, 2008 function Money( player ) givePlayerMoney( source, 10000 ) end why aren'T you giving the money to the player, but to the ColShape? Link to comment
XetaQuake Posted February 15, 2008 Author Share Posted February 15, 2008 thanks mabako and Ace_Gambit it works now i dont have knew the hitElement, matchingDimension stuff now i try to make this in a timer, so when i go in the marker, i want to get 1000 Money every 1 second so i have trying this already: function Place(name) if name ~= getThisResource() then return else local marker = createMarker ( -1025.5623779297, 457.65173339844, 14, "cylinder", 4, 0, 100, 200, 250 ) end end setTimer(Money, 1000, 1, getRootElement) function Money( hitElement, matchingDimension) givePlayerMoney( hitElement, 10 ) end Col = createColSphere ( -1025.5623779297, 457.65173339844, 14, 4 ) addEventHandler ( "onColShapeHit", Col, Money ) addEventHandler ( "onResourceStart", getRootElement(), Place) but it dont work, so i have try simple differents: setTimer(Money, 1000, 1, source) or function Timer( hitElement, matchingDimension) setTimer(Money, 1000, 1, source) end or function Timer( hitElement, matchingDimension) setTimer(Money, 1000, 1, hitElement) end but all this dont work, what make i wrong? Link to comment
Mr.Hankey Posted February 15, 2008 Share Posted February 15, 2008 you have to use: function Money( hitElement, matchingDimension) givePlayerMoney( hitElement, 10 ) timer = setTimer (Money, 1000, 0, hitElement) -- if you set the second Value (number of repetitions) to 0 the timer will loop through the function every second for ever until you kill the timer with the killTimer function end function money_stop () killTimer (timer) end addEventHandler ("onColShapeLeave", Col, money_stop) im not really sure if it works because i just hadn't enough time to test it but i hope so =) Link to comment
XetaQuake Posted February 15, 2008 Author Share Posted February 15, 2008 hi hankey, lol thanks for help but this is the ULTIMADE Server killer this was so funy: first, i go in the marker and yea, all working pretty, but then: 0 - 10 - 20 - 40 - 80 - 160 - 320 .... then the game run with 10 FPS, noting work and the server console spamm 10.00000 errors in 0.5 seconds here the spamm error: Bad 'element' pointer @ 'givePlayerMoney'(1) - Line: 8 //EDIT: i have forgotten to say that when i go out of the marker, i get money again and again Link to comment
XetaQuake Posted February 15, 2008 Author Share Posted February 15, 2008 nobody a idea to fix this server killer? ^^ Link to comment
50p Posted February 16, 2008 Share Posted February 16, 2008 Use http://development.mtasa.com/index.php? ... rMarkerHit instead. Link to comment
XetaQuake Posted February 16, 2008 Author Share Posted February 16, 2008 (edited) but the problem is by givePlayerMoney on the script here is the complete script at this time to help me easier: function Place(name) if name ~= getThisResource() then return else local marker = createMarker ( -1025.5623779297, 457.65173339844, 14, "cylinder", 4, 0, 100, 200, 250 ) end end function Money( hitElement, matchingDimension) givePlayerMoney( hitElement, 10 ) timer = setTimer (Money, 1000, 0, hitElement) -- if you set the second Value (number of repetitions) to 0 the timer will loop through the function every second for ever until you kill the timer with the killTimer function end function money_stop () killTimer (timer) end Col = createColSphere ( -1025.5623779297, 457.65173339844, 14, 4 ) addEventHandler ( "onColShapeHit", Col, Money ) addEventHandler ( "onColShapeLeave", Col, money_stop) addEventHandler ( "onResourceStart", getRootElement(), Place) my problem: first, i go in the marker and yea, all working pretty, but then: 0 - 10 - 20 - 40 - 80 - 160 - 320 ....then the game run with 10 FPS, noting work and the server console spamm 10.00000 errors in 0.5 seconds here the spamm error: Bad 'element' pointer @ 'givePlayerMoney'(1) - Line: 8 //EDIT: i have forgotten to say that when i go out of the marker, i get money again and again Edited February 16, 2008 by Guest Link to comment
50p Posted February 16, 2008 Share Posted February 16, 2008 Call giveMoney using timer. eg. timer = setTimer( giveMoney, 1000, 0, hitElement, 10 ). You shouldn't get errors using that. Link to comment
XetaQuake Posted February 16, 2008 Author Share Posted February 16, 2008 (edited) good idea! so i have this code: function Place(name) if name ~= getThisResource() then return else local marker = createMarker ( -1025.5623779297, 457.65173339844, 14, "cylinder", 4, 0, 100, 200, 250 ) end end function Money( hitElement, matchingDimension) timer = setTimer( giveMoney, 1000, 0, hitElement, 10 ) end function money_stop () killTimer (timer) end Col = createColSphere ( -1025.5623779297, 457.65173339844, 14, 4 ) addEventHandler ( "onColShapeHit", Col, Money ) addEventHandler ( "onColShapeLeave", Col, money_stop) addEventHandler ( "onResourceStart", getRootElement(), Place) now the script respond when i go in and out of the marker - with two warnings WARNING: money.lua: Bad argument @ 'setTimer' - Line: 8 WARNING: money.lua: Bad argument @ 'killTimer' - Line: 11 and i get no money Edited February 16, 2008 by Guest 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