Jump to content

Maurize

Members
  • Posts

    226
  • Joined

  • Last visited

Everything posted by Maurize

  1. However it seems like that any element which is attached to another will lose it's element data on move. (maybe it's because the "element" data remains at the default location)
  2. Thank you very much! The function is exactly what I needed! The positions are now exactly like I want them.
  3. Hello again, I'm trying to spawn the player onto an element. This element has a non-fixed rotation. I'm just wondering if the function getPointFromDistanceRotation isn't enough to do this? Player details can be found here and the ships details are here I'm currently using this snippet (to try) to get the explained result: addCommandHandler("boat", function(player, cmd) local x, y, z = getElementPosition(player) local _, _, r = getElementRotation(player) outputChatBox("player pos: "..x..","..y..","..z..","..r, player) local ship = createShip(x, y, z, r) -- returns model of pirateship local x, y, z = getElementPosition(ship) local _, _, r = getElementRotation(ship) outputChatBox("ship pos: "..x..","..y..","..z..","..r, player) local x, y = getPointFromDistanceRotation(x - 0.1, y - 2.7, 5, r) -- offset included outputChatBox("new player pos: "..x..","..y..","..z..","..r, player) setElementPosition(player, x, y, 43.7) end) What am I'm doing wrong? Do I need to calculate the offset coordinates extra? Greetings, Maurize
  4. Update: The creation of the elements could be useful for finding a solution local ship = createObject(8493, x, y, z) server.ships[id].ship = ship ... local doorEntrance = createObject(3093, x, y, z) attachElements(doorEntrance, ship, -1.2, -30.3, -9.9, 0, 0, 270) ... local action = #server.actions + 1 server.actions[action] = enterBoat setElementData(doorEntrance, "action", action) setElementData(doorEntrance, "parent", id) ... function enterBoat(player, element) local id = getElementData(element, "parent") teleportPlayer(player, true, 3, -4, 1000.6, 90, id) -- simple set position with camera effects end
  5. Hello forums! to the current script: I created a boat (vehicle) and attached a pirateship to it. On the pirateship there are some doors attached. I'm using following function to interact with the objects: addEvent("onPlayerInteraction", true) addEventHandler("onPlayerInteraction", server.root, function() local nearest = getNearest(source, "object", 5) -- is working if (nearest) then outputChatBox("object found", source) local id = getElementData(nearest, "action") if (id) then local action = server.actions[id] action(source, nearest) outputChatBox("object found with id"..id, source) else outputChatBox("object found with no id", source) end else outputChatBox("no object found", source) end end) If the ship is created (and not moved) everything works fine. As soon as the ship is moved the function outputs "no object found". Is this a known bug or am I'm missing something?
  6. Right. This makes sense, Castillo. This means an if-statement where I call data from database is impossible?
  7. Yeah I thought the same but this didn't solved my problem. If I try to outputChatBox the result it gives an error -> Expected string Current function: local db = dbConnect("mysql", "host=localhost;dbname=mtasa", "root", ""); function getData(player, db_table, db_row) dbQuery(function(e) local r = dbPoll(e, 0); return r[1][db_row]; end, db, "SELECT "..db_row.." FROM "..db_table.." WHERE username = '"..getPlayerName(player).."' LIMIT 1"); end I think the async makes problems. If I do the query directly in database it works like charm but not in .lua.
  8. Hey, Solidsnake14. Thanks, this is a useful hint (performance...). Anyway something seems like to fail. Sadly there is no way to print the whole table.
  9. Hello Ladies and Gentleman, I'm tying to create a function which allows me to get fields from my mysql table. What I've done so far: local db = dbConnect("mysql", "host=localhost;dbname=mtasa", "root", ""); function getData(player, db_table, db_row) dbQuery(function(e) local result = dbPoll(e, 0); return result[db_row]; end, db, "SELECT "..db_row.." FROM "..db_table.." WHERE username = '"..getPlayerName(player).."' LIMIT 1"); end This gives an error if I try to outputChatBox the result. Maybe someone can help me up with this.
  10. Hello community, As I watched the movie 'Chappie' I'm wondering how those "roboters" are build. My plan is to control an electrical part from car which moves up and down if power is on. So this is my current plan: -end- actuator(from car ~ 12v) <-- ? (must be programmable via usb port) <-- power unit - for electricity(from computer, later from car battery ~ 80-100ah | both have a power output of 12v) -start- I only need the cut between this components to write the program via usb port (or stick). So any ideas?
  11. Maurize

    quetion

    Lad his question was: --serverside-- addEventHandler( "onResourceStart", resourceRoot, function() for i, v in ipairs( getElementsByType( "player" ) ) do triggerClientEvent( "onPlayerCreateMarker", v ); end end ) --clientside-- addEvent( "onPlayerCreateMarker", true ); addEventHandler( "onPlayerCreateMarker", getLocalPlayer(), local marker = createMarker( x, y, z, "cylinder", 1, 255, 255, 0, 255 ); -- now you can add the rest of functions to marker here end ) This will do the work!
  12. If you want simple refill vehicle health use setElementHealth( vehicle, 1000 ) If you want to increase the vehicle health in maximum use a timer or the onVehicleDamage event. https://wiki.multitheftauto.com/wiki/SetElementHealth https://wiki.multitheftauto.com/wiki/OnVehicleDamage
  13. You have to change FarClipDistance for object. https://wiki.multitheftauto.com/wiki/SetFarClipDistance
  14. I don't really get what you want but if you want to prevent ped from being teleported into the helicopter simply delete the line with warpPedIntoVehicle( ... )
  15. Maurize

    quetion

    for i, v in ipairs( getElementsByType( "player" ) ) do local marker = createMarker( ... ) end nerver tried, maybe works. But if this doesn't work you could trigger for all players from serverside and then create marker clientside.
  16. Hmm, seems like it was the too short timer which made trouble... howevery everything works fine now! Theres only that point, that I spawn the peds all arround los santos but sometimes if I shoot at a ped it doesn't loose health? SOLVED ~
  17. Hello everybody, I'm working on a "working" ped. However if resource is started a ped gets created. I trigger it to client and then execute following functions: local element = getLocalPlayer(); addEvent( "onClientActor", true ); addEventHandler( "onClientActor", element, function( actor ) if ( getElementData( element, "loaded" ) == false ) then setElementData( element, "loaded", true ); addEventHandler( "onClientRender", root, function() local enemy = getTarget( actor ); local _, _, rZ = getElementRotation( actor ); local aX, aY, aZ = getElementPosition( actor ); local tX, tY, tZ = getElementPosition( enemy ); local bX, bY, bZ = getPedBonePosition( enemy, 3 ); local tR = -math.deg( math.atan2( aX - tX, aY - tY ) ) - 180; local fX = aX - math.sin( math.rad ( rZ ) ) * 3; local fY = aY + math.cos( math.rad ( rZ ) ) * 3; if ( getDistanceBetweenPoints3D( aX, aY, aZ, tX, tY, tZ ) > 50 ) then setPedControlState( actor, "aim_weapon", false ); setPedControlState( actor, "fire", false ); setPedControlState( actor, "forwards", true ); setPedControlState( actor, "walk", true ); if ( isLineOfSightClear( aX, aY, aZ, fX, fY, aZ ) ~= true ) then setElementRotation( actor, 0, 0, rZ + 1 ); end else setPedControlState( actor, "forwards", false ); setPedControlState( actor, "aim_weapon", true ); setPedControlState( actor, "fire", true ); setElementRotation( actor, 0, 0, tR ); setPedAimTarget( actor, bX, bY, bZ ); end end ); end end ) function getTarget( ped ) local x, y, z = getElementPosition( ped ); local prevDist; for i, v in ipairs( getElementsByType( "player" ) ) do local dist = getDistanceBetweenPoints3D( x, y, z, getElementPosition( v ) ); if ( dist <= ( prevDist or dist + 1 ) ) then prevDist = dist; target = v; end end return target or false end Everything works fine... But the ped doesn't hit me very well ( very rare that I got hit ). So my question is, where is the trick to make him more accurate? -> setPedStat is max for every weapon. --> Maybe you got some hints what to do better
  18. Falls das auch nicht funktioniert, probiert mal den Kompatibilitätsmodus aus,
  19. Die einen oder anderen Usernamen sagen mir sogar was. Falls das die Herrschaften von VIO sind, grüß mal lieb.
  20. Kostenlos wird sich da kein professioneller Scripter anbieten. Aber es gibt genug Scripter die das gegen etwas "Gage" machen.
  21. Hallo, habe dir dein script etwas überarbeitet Hoffe das problem ist gelöst! addCommandHandler( "starttruck", function( thePlayer ) curriercar = createVehicle( 411, 1200, -1831, 13.4, 0, 0, -90 , "currier" ) -- im wiki nachlesen welche parameter i.o. sind warpPedIntoVehicle( thePlayer, curriercar, 0 ) outputChatBox ( "Fahre zur angegebenen Markierung", thePlayer, 0, 130, 10, false ) currierblip = createBlip ( 1272.56, -1797.66, 13.13, 19, 2, 255, 0, 0, 255, 0, 99999.0, thePlayer ) curriermarker = createMarker ( 1272.56, -1797.66, 13.13, "checkpoint", 4.0, 255, 0, 0, 255, thePlayer ) addEventHandler( "onMarkerHit", curriermarker, finish ) function finish( hitElement ) removeEventHandler( "onMarkerHit", curriermarker, finish ) -- als aller erstes den handler entfernen sonst löst er mehrmals aus! removePedFromVehicle( thePlayer ) destroyElement( hitElement ) setElementPosition( thePlayer, 1213.84, -1822.92, 13.59 ) destroyElement( currierblip ) destroyElement( source ) -- source ist in diesem fall der marker! nur als kleiner tipp! givePlayerMoney( thePlayer, 2000 ) outputChatBox( "Perfekt! Auftrag erfolgreich abgeschlossen. Belohnung sind 2000$", thePlayer, 0, 130, 10, false ) end end )
  22. local mines = { { 1211, -1467.2827, -1287.6701, 99.15, 0, 0, 0 } }; -- all mines over here! addEventHandler( "onResourceStart", resourceRoot, -- if resource started the function starts to work! function() for i, v in ipairs( mines ) do -- loop the table above. you can add more mines if you add more data { { id, x, y, z, rx, ry, rz }, { same here and so on } } local mine = createObject( v[1], v[2], v[3], v[4], v[5], v[6], v[7] ); -- lets create it setElementData( mine, "mine", true ); -- lets set a data to remember it is a mine end setTimer( function() for i, p in ipairs( getElementsByType( "player" ) ) do -- loop through all players and check position pX, pY, pZ = getElementPosition( p ); -- get position for i, o in ipairs( getElementsByType( "object" ) ) do -- loop through all objects and check position if ( getElementData( o, "mine" ) == true ) then -- check if it really a mine and not for example fence oX, oY, oZ = getElementPosition( o ); -- get position if ( getDistanceBetweenPoints3D( pX, pY, pZ, oX, oY, oZ ) < 2 ) then -- now lets see if player is near enough outputChatBox( "Kaboooohm! Mine over here!", p, 255, 0, 0 ); createExplosion( oX, oY, oZ, 6 ); -- more realistic if explosion comes from mine. end end end end end, 1000, 0 ); -- lets check every second if someone is near mine. end ) untested but should work
  23. Maurize

    ammo

    addEventHandler( "onPlayerVehicleEnter", getRootElement(), function( vehicle, seat, jacked ) if ( getElementModel( vehicle ) == 433 ) then if ( getPedWeapon( source ) == 31 ) then --if m4 giveWeapon( source, 31, 200 ); -- give m4 and 200 ammo elseif ( getPedWeapon( source ) == 30 ) then --if ak47 giveWeapon( source, 30, 300 ); -- then give weapon ak47 and 300 ammo elseif ( getPedWeapon( source ) == 35 ) then -- if rpg giveWeapon( source, 35, 2 ); -- then give weapon 35 and 2 ammo -- and so on how you like it. end outputChatBox( "Yeah, Ammo", source, 255, 255, 0 ); end end ) this script is for easy understand ... you can find all weapon ids here -> https://wiki.multitheftauto.com/wiki/Weapons
  24. Maurize

    ammo

    addEventHandler( "onPlayerVehiclenter", getRootElement(), function( vehicle, seat, jacked ) if ( ( getElementModel( vehicle ) == 433 ) and ( getPedWeapon( source, 5 ) == 31 ) ) then outputChatBox( "Yeah, Ammo", source, 255, 255, 0 ); giveWeapon( source, 31, 200 ); end end )
  25. addEvent( "onPlayerTax", true ); addEventHandler( "onPlayerTax", element, function() delay = 3600 - getElementData( element, "time" ); -- value starts from 1 and gets every second +1. Is loaded from database at spawn and saved in ElementData. setTimer( function() outputChatBox( "PAYDAY!" ); delay = 3600; end, delay, 0 ) end ) But what if player time is more than 3600? for example : delay = 3600 - 120120. Is there a math calculation which gets if a full hour is reached?
×
×
  • Create New...