Jump to content

Rotti

Members
  • Posts

    61
  • Joined

  • Last visited

Everything posted by Rotti

  1. I just found this function for c# on the internet. I translated it to lua function calculateDifferenceBetweenAngles(firstAngle, secondAngle) difference = secondAngle - firstAngle; while (difference < -180) do difference = difference + 360 end while (difference > 180) do difference = difference - 360 end return difference end It works.
  2. I dont want the object to look towards the waypoint. I want it to move to the waypoint and to slowly rotate to the rotation of the waypoint so that rx = rxx, ry = ryy, rz = rzz I don't know how sin cos and rad could help me here...
  3. Hello, I have a problem with moveObject. The method only uses relative rotation. I have made a xml file with waypoints and these waypoints have the x, y, z coordinates and the absolute rotation. So now i have to calculate the relative rotation between my object and the waypoint. I came up with this idea: rx, ry, rz = rotation of the waypoint rxx, ryy, rzz = rotation of the object relative rotation = rx - rxx, ry - ryy, rz - rzz This is no code its just the math. But the problem is that if the Y rotation of the waypoint is 359° and the Y rotation of the object is 0° it won't roll one degree to the left. Instead it will roll 359 degrees to the right which looks awful. Can someone help me please?
  4. No everything is on 100%
  5. Hello, I have enabled the voice chat on my MTA 1.4 server to try it out. But there is one problem: I can hear my friend but my friend can't hear me. We are both in the same channel, we are both not muted and we are both in the Admin ACL group. Do you know what causes this problem?
  6. Rotti

    Police /tie

    Thanks it worked! yes i'Ve defined the team variables
  7. Rotti

    Police /tie

    thats the problem. There must be some other ways
  8. Rotti

    Police /tie

    so that his key to exit the car is unbound? But maybe he has changed the key in the settings that he exits the car with O and not with enter or e
  9. Rotti

    Police /tie

    Hello, I'm scripting my police fraction at the moment. I wanted to make a /tie command so that the police can shakle the player on the back seat, so that he can't get out of the car. I've tried it with this code: function fesseln(player) outputChatBox("Gefangener im Auto gefesselt",player, 255, 255, 0) local playerTeam = getPlayerTeam ( player ) if (playerTeam == Polizei or playerTeam == FBI or PlayerTeam == Army) then if isPedInVehicle(player) == true then vehicle = getPedOccupiedVehicle(player) if ( policeVehicles[getElementModel ( vehicle )] ) then gefangener = getVehicleOccupant(vehicle, 2) setElementFrozen(gefangener, true) end end end end addCommandHandler("tie", fesseln) Thats where the police Vehicles are defined: policeVehicles = { [598]=true, [596]=true, [597]=true, [599]=true } But the player can exit the car! Can someone help me to fix it?
  10. Thank you for your help it worked but if i reconnect i can't lock the vehicle again... So if the vehicle is unlocked, i reconnect and try to lock it it doesn't locks I hope that you understand it
  11. so simply setElementData(Perennial, "owner", player) ???
  12. Ok can you explain how to get the userdata? ive nver worked with user data
  13. Can you say exactly what the error is? I have already fixed the in the setElementData
  14. do you mean this text with img src and so on? thats only on this website not in the script and i can't delete it...
  15. I have already posted the code at the top
  16. Its still the same problem. The vehicle doesn't locks when i press L. And i think it has to be something with the Owner, because the Vehicle locks if i take out this part: if getElementData(nearbyVehicle, "owner") == getPlayerName(player) setVehicleLocked(nearbyVehicle, true) end
  17. I've found one mistake: at setElementData in the buy script the but it didn't help so far... But I've corrected it
  18. Hello, I want to make a script that can set an owner for a vehicle and only the owner can lock or unlock his car. Here is what happens when someone buys a car: function Perennial_buy () local Perennial = createVehicle(404, -2600, 2268, -- s8) --> setElementData(Perennial, "save", "save")--for the save script takePlayerMoney(source, 2000) --take money setTimer(warpPedIntoVehicle, 50, 1, source, Perennial)--warp player in vehicle setElementData(Faggio, "owner", getPlayerName(source))--set the owner outputServerLog("[AUTOHÄNDLER] "..getPlayerName(source).." kaufte einen Perennial")--server log end I don't know what that text in line 2 is but it is not in the script just in the forum and i can't delete it... and thats the script for the lock function lockcar(player) posX, posY, posZ = getElementPosition(player) local lockSphere = createColSphere( posX, posY, posZ, 20 ) local locker = getPlayerName( player ) local nearbyVehicles = getElementsWithinColShape( lockSphere, "vehicle" ) destroyElement( lockSphere ) for index, nearbyVehicle in ipairs( nearbyVehicles ) do if getElementData(nearbyVehicle, "owner") == getPlayerName(source) then setVehicleLocked(nearbyVehicle, true) end end end function binds() bindKey(source, "L", "down", lockcar) end addEventHandler("onPlayerLogin", getRootElement(), binds) But it doesn't locks the car! I think it has to be something with the owner script because an outputChatBox before the "for" works! please help
  19. Rotti

    PlaySound3D

    not everybody hears the sound #Edit ok we are very close to solve the problem. I have changed your code a bit: Partybus = createVehicle ( 437, -2755, 958, 54.3, 0, 0, 0, "Party" ) Partylaser1 = createObject( 18102, -2755, 958, 56.3) Speaker1 = createObject( 1840, -2755, 958, 57.3) Speaker2 = createObject( 1840, -2755, 958, 57.3) Speaker3 = createObject( 1840, -2755, 958, 57.3) Speaker4 = createObject( 1840, -2755, 958, 57.3) attachElements(Speaker1, Partybus, -1, 4, 2) attachElements(Speaker2, Partybus, 1, 4, 2, 0, 0, 180) attachElements(Speaker3, Partybus, -1, -4, 2) attachElements(Speaker4, Partybus, 1, -4, 2, 0, 0, 180) attachElements(Partylaser1, Partybus, 1, 3.5, 0.7, 40, 0, 90) addEventHandler ( 'onVehicleEnter', Partybus, function (thePlayer) triggerClientEvent ( 'startsound', root ) end ) addEventHandler( 'onClientResourceStart', resourceRoot, function() song = playSound3D("Diskoparty.mp3", -2758, 968, 54, true) setSoundVolume ( song, 100 ) setSoundMinDistance ( song, 100 ) outputChatBox(":D") end ) addEvent ( 'startsound', true ) addEventHandler ( 'startsound', root, function ( ) if not ( isElement ( sound ) ) then pl = getLocalPlayer() auto = getPedOccupiedVehicle(pl) attachElements(song, auto) end end ) But only the players who have entered the vehicle can hear the sound.
  20. Rotti

    PlaySound3D

    ---------------- ----Partybus---- ---------------- Partybus = createVehicle ( 437, -2755, 958, 54.3, 0, 0, 0, "Party" ) Partylaser1 = createObject( 18102, -2755, 958, 56.3) Speaker1 = createObject( 1840, -2755, 958, 57.3) Speaker2 = createObject( 1840, -2755, 958, 57.3) Speaker3 = createObject( 1840, -2755, 958, 57.3) Speaker4 = createObject( 1840, -2755, 958, 57.3) attachElements(Speaker1, Partybus, -1, 4, 2) attachElements(Speaker2, Partybus, 1, 4, 2, 0, 0, 180) attachElements(Speaker3, Partybus, -1, -4, 2) attachElements(Speaker4, Partybus, 1, -4, 2, 0, 0, 180) attachElements(Partylaser1, Partybus, 1, 3.5, 0.7, 40, 0, 90) There is no function
  21. Rotti

    PlaySound3D

    But... thats not what i want sorry, I want the sound to be everytime attached on the vehicle which was created serverside. The vehicle is defined as "Partybus". As i said maybe it will work with setElementPosition and getElementPosition Ok i think you can help me better now
  22. Rotti

    PlaySound3D

    I want to do the same as #Pai_[N] said: attach the sound to the vehicle with attechElements
  23. Rotti

    PlaySound3D

    But how? the sound is clientside and the vehicle serverside
  24. Rotti

    PlaySound3D

    Ok I just wanted to do it this way, because i'm using it with a vehicle: --Serverside function movesong() x,y,z = getElementPosition(Partybus) triggerClientEvent("song", getRootElement(),x,y,z) end setTimer(movesong, 50, 0) --Clientside function move(posX,posY,posZ) setElementPosition(song, posX,posY,posZ) end addEventHandler("song", root, move) addEvent("song",true) But that didn't work...
×
×
  • Create New...