Jump to content

SDK

Members
  • Posts

    635
  • Joined

  • Last visited

Everything posted by SDK

  1. The error is right, where is the table movingGates? Is it needed for something? Your script could work if you remove the if-then-else or create the table. I notice you mix serverside and clientside code in this. When clicking the button you should do a triggerServerEvent to move the gate serverside (unless you want it clientside). playSoundFrontEnd doesnt need hitElement when it's clientside.
  2. Hm, I'm messing up. <team name="policeSP"> local team_policeSP= getTeamFromName("policeSP")
  3. ah, you used "name" in the map file. That's why getElementByID didnt work and returned false => error at getElementsByType in my script/getElementChild in your script. Change
  4. Try it this way, not tested: function joinHandler(equipa) -- first find the team elements local team_policeSP= getElementByID("policeSP") local team_immigrantsSP= getElementByID("immigrantsSP") -- put all children from the teams that are from type 'spawnpoint' in tables local spawns_policeSP= getElementsByType ( 'spawnpoint', team_policeSP) local spawns_immigrantsSP = getElementsByType ( 'spawnpoint', team_immigrantsSP ) -- select a random element from the table local nr = math.random ( #spawns_policeSP ) local spawnPointPolice = spawns_policeSP [ nr ] -- repeat nr = math.random ( #spawns_immigrantsSP ) local spawnPointImmigrants = spawns_immigrantsSP [ nr ] The key is getElementsByType, you can choose the type ( ='spawnpoint') and the parent element ( = team ), it will return all children in a table
  5. Use a timer and fixVehicle(ewvehcile)
  6. Nice map csena . @benox, looks like they're moving objects, no damage/kill script.
  7. You can use teams: https://wiki.multitheftauto.com/wiki/Element/Team <map mod="deathmatch" version="1.0"> <team name="Grove" red="0" green="255" blue="0"> <spawnpoint posX="2495.1257324219" posY="-1686.6124267578" posZ="13.513834953308" rot="3.4530944824219"/> <spawnpoint posX="2519.9204101563" posY="-1678.9359130859" posZ="14.879755020142" rot="91.500610351563"/> </team> </map>
  8. SDK

    When i finish my map...

    You can upload it to MTA's community center and hope some server owners are interested in your map, or you can go to the websites from some server and look for their map upload system.
  9. SDK

    Help me pls

    Castillo, he is a troll. Ignore him.
  10. Try checking it with a timer after 50 ms (or longer)
  11. Example from: https://wiki.multitheftauto.com/wiki/GiveWeapon function giveWeaponsOnSpawn ( theSpawnpont, theTeam ) giveWeapon ( source, 31, 200 ) -- Gives the M4 weapon with 200 ammo end addEventHandler ( "onPlayerSpawn", getRootElement(), giveWeaponsOnSpawn )
  12. Use getElementByID: https://wiki.multitheftauto.com/wiki/GetElementByID
  13. Use this rounding function: https://wiki.multitheftauto.com/wiki/Math.round function math.round(number, decimals, method) decimals = decimals or 0 local factor = 10 ^ decimals if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor else return tonumber(("%."..decimals.."f"):format(number)) end end
  14. Yes, it's probably because the player AND the vehicle hit the marker. Also, your marker script would keep working, even if other players would hit it. Fix: add a global boolvariable hasMarkerBeenHit=false and check if the marker already has been entered. If not: output, move and hasMarkerBeenHit=true.
  15. I see three ways of doing that: 1) Like told above, create an object that can move, use attachElements on it, and shoot it away. Easy for large distances, but you need to rely on the moveable object. Like this resourcefor example: it uses the flowerpot vehicle to create airbombs 2) Use moveObject with some kind of easing type (maybe InBounce or OutBounce are what you need). Harder and you would need to find the correct type for it. 3) A math function and use setElementPosition in combination with a timer or onClientRender. You'll need to know some math for this ^^.
  16. Well, your addEventHandler for onMarkerHit points to the wrong function, "stop" instead of "markerhit'
  17. SDK

    Problems

    If there's an error in your script, but you don't know where, use outputChatBox or outputDebugString to know where it stops. So add some texts like 'Player clicked CHANGE button' , 'client sending event to server', 'server received event from client with name: your_name', etc ... You can even add the values from your variables so you know where they might get 'lost'. This is one way to debug broken scripts, more examples and explanation: https://wiki.multitheftauto.com/wiki/Deb ... s_executed
  18. The source for onPlayerMarkerHit is a player, you need the first argument passed for the marker. You most likely don't need the cancelEvent, and there is only one lua file (and it's serverside). local tankZinkDing = createObject( 5804, 372.684, -2393.951, -3.099, 359.467, 0, 0 ) local huntermarker1 = createMarker( 376.870, -2241.505, 44.539, "corona", 2, 0, 255, 0 ) local huntermarker2 = createMarker( 372.126, -2480.029, 45.837, "corona", 2, 0, 255, 0 ) function tankVerdrinkt (marker, dimension) if ( marker == huntermarker1 or marker == huntermarker2) then outputChatBox ( "OMFG THE TANK IS SINKING, so the cars won. GZ. Now kill eachother with the hunter! : D", getRootElement(), 255, 0, 0, true ) moveObject ( tankZinkDing, 10000, 372.684, -2393.951, -8.0999 ) end end addEventHandler( "onPlayerMarkerHit", getRootElement(), tankVerdrinkt ) or you can do it easier like this: local tankZinkDing = createObject( 5804, 372.684, -2393.951, -3.099, 359.467, 0, 0 ) local huntermarker1 = createMarker( 376.870, -2241.505, 44.539, "corona", 2, 0, 255, 0 ) local huntermarker2 = createMarker( 372.126, -2480.029, 45.837, "corona", 2, 0, 255, 0 ) function tankVerdrinkt () outputChatBox ( "OMFG THE TANK IS SINKING, so the cars won. GZ. Now kill eachother with the hunter! : D", getRootElement(), 255, 0, 0, true ) moveObject ( tankZinkDing, 10000, 372.684, -2393.951, -8.0999 ) end addEventHandler( "onPlayerMarkerHit", huntermarker1, tankVerdrinkt ) addEventHandler( "onPlayerMarkerHit", huntermarker2, tankVerdrinkt ) Is this for a DM/DD map? Because this is using the onPlayerMarkerHit event, and I'm not sure if it works when players are in a vehicle.
  19. SDK

    moving objects

    https://community.multitheftauto.com/index.php?p= ... ls&id=1224 This tool made by aibo will help. It generates a lua file.
  20. Nope, no getAccountPassword and that's probably for obvious security reasons. All you need to do with a password is to check if it's correct, and you can do that with getAccoun() and logIn().
  21. Actually, the purpose of this forum is: you have a problem with scripting, we offer guidance on how to fix the problem and how to learn from your mistakes. Not: fix my script plz.
  22. Wrong, you did *0.5. It's ^0.5. => http://mathbin.net/63264 http://en.wikipedia.org/wiki/Pythagorea ... te_systems
  23. Not very usefull, but I think another option is to beg for oxygen functions: http://bugs.mtasa.com/view.php?id=5350
  24. Create the table like in my code, it will now work like this: staffskins[1] will return 211 staffskins[2] will return 217 #staffskins will return the amount of elements inside the table = 2 math.random(a) returns a random number ranging from 1 to a staffskins = { 211, 217 } function staffadd ( thePlayer ) local randomTableKey = math.random(#staffskins) setElementModel(thePlayer, staffskins[randomTableKey ] )
  25. Like karlis said, that's hard to answer. Some scripts can be made with or without maths and have the same effect. You will probably need them most if you want to calculate something complex with angles and vectors (eg. positions, rotations, velocity and gravity vectors) but it can also be usefull in GUI's.
×
×
  • Create New...