Jump to content

arezu

Members
  • Posts

    446
  • Joined

  • Last visited

Everything posted by arezu

  1. are you sure you are not the ped, that you are trying to change control state for? i didn't make the exact same as you wanted it, but almost and it works: local ped = nil local destX, destY, destZ = 0, 0, 0 local STOP_DIST = 0.2 showCursor(true, true) -- when player presses with mouse, linked to the gta world, so we get world position addEventHandler("onClientClick", getRootElement(), function(button, state, absX, absY, worldX, worldY, worldZ, element) if(not ped or button ~= "left" or state ~= "up")then return end outputDebugString("PED: camera rotation changed.") destX, destY, destZ = worldX, worldY, worldZ local x, y, z = getElementPosition(ped) local rot = -math.deg(math.atan2(x-destX, y-destY)) - 180 setPedCameraRotation(ped, rot) setPedRotation(ped, rot) addEventHandler("onClientRender", getRootElement(), movePed) end) function movePed() -- make ped go forward all the time until he is close enough to the destinated position setPedControlState(ped, "forwards", true) local x, y, z = getElementPosition(ped) -- use 2d distance, because you will need a more advanced AI for 3D local dist = getDistanceBetweenPoints2D(destX, destY, x, y) if(dist <= STOP_DIST)then removeEventHandler("onClientRender", getRootElement(), movePed) setPedControlState(ped, "forwards", false) end end bindKey("F3", "up", function() local x, y, z = getElementPosition(getLocalPlayer()) ped = createPed(7, x, y + 10, z) end)
  2. player = getPlayerFromName(player) executeCommandHandler("warp", source, player)
  3. since you are using setPedCameraRotation, then you can use setPedControlState to make ped go to destination something like this... (didn't test) local destX, destY, destZ = 0, 0, 0 local STOP_DIST = 0.2 -- when player presses with mouse, linked to the gta world, so we get world position addEventHandler("onClientClick", getRootElement(), function(button, state, absX, absY, worldX, worldY, worldZ, element) if(button ~= "left" or state ~= "down")then return end destX, destY, destZ = worldX, worldY, worldZ addEventHandler("onClientRender", getRootElement(), movePed) end) function movePed() -- make ped go forward all the time until he is close enough to the destinated position setPedControlState(singleData, "forwards", true) local x, y, z = getElementPosition(singleData) -- use 2d distance, because you will need a more advanced AI for 3D local dist = getDistanceBetweenPoints2D(destX, destY, x, y) if(dist <= STOP_DIST)then removeEventHandler("onClientRender", getRootElement(), movePed) end end
  4. nah, i just wrote something wrong. I tried this and it works: function getTransformedPosition(element, distX, distY, distZ) local matrix = getElementMatrix(element) local offX = distX * matrix[1][1] + distY * matrix[2][1] + distZ * matrix[3][1] + 1 * matrix[4][1] local offY = distX * matrix[1][2] + distY * matrix[2][2] + distZ * matrix[3][2] + 1 * matrix[4][2] local offZ = distX * matrix[1][3] + distY * matrix[2][3] + distZ * matrix[3][3] + 1 * matrix[4][3] -- returns the position related to position, and rotation of the element return offX, offY, offZ end replace it with the function u have. i wrote it fast so i used multiplication where u needed to use addition
  5. i used getKeyState for each frame instead, because bind key only executes once if you hold it down. local rotSpeed = 5 addEventHandler("onClientPreRender", getRootElement(), function() local rot = getPedRotation(singleData) -- if you pressed on 'a' button if(getKeyState("a"))then rot = rot - rotSpeed end if(getKeyState("d"))then rot = rot + rotSpeed end local px, py, pz = getElementPosition(singleData) -- arguments: element, distanceX, distanceY, distanceZ local dx, dy, dz = getTransformedPosition(singleData, 0, -20, 1) setCameraMatrix(dx, dy, dz, px, py, pz) setPedRotation(singleData, rot) -- if you want to make the player walk towards the way he is facing, then its needed. setPedCameraRotation(singleData, rot) end) function getTransformedPosition(element, distX, distY, distZ) local matrix = getElementMatrix(element) local offX = distX * matrix[1][1] + distY * matrix[2][1] * distZ * matrix[3][1] + 1 * matrix[4][1] local offY = distX * matrix[1][2] + distY * matrix[2][2] * distZ * matrix[3][2] + 1 * matrix[4][2] local offZ = distX * matrix[1][3] + distY * matrix[2][3] * distZ * matrix[3][3] + 1 * matrix[4][3] -- returns the position related to position, and rotation of the element return offX, offY, offZ end
  6. do you mean that when you press a or d, then camera and ped should rotate, and camera should be stuck behind the player?
  7. if you are using window 7, you can get back old files(saves when computer shutsdown). You can look it up on google or youtube. I did it when i lost my script for map once because the editor deleted my script files...
  8. you can alternatively use the script on community which lets you send files located on server to the player, and use playSound even thought the file has not fully downloaded. I made my own download functions and made the same thing for my server(~pS - pure skillz)
  9. arezu

    Teams

    use autoteams resource from community
  10. you can do getElementsByType("sound") and check when the number of sound elements changes, or use onClientElementDestroy example code (the onClientSoundPlay is not working 100%, but you didn't really want it soo.. dont mind it) addEventHandler("onClientElementDestroy", getRootElement(), function() if(getElementType(source) == "sound")then outputChatBox("Sound stopped: "..tostring(source)) end end) --[[ local sounds = getElementsByType("sound") addEventHandler("onClientRender", getRootElement(), function() local s = getElementsByType("sound") if(#s > #sounds)then triggerEvent("onClientSoundPlay", getLocalPlayer(), s[#s]) end if(#s < #sounds)then for i = 1, #sounds do local theSound = searchTable(s, sounds[i]) if not theSound then triggerEvent("onClientSoundStop", getLocalPlayer(), sounds[i]) break end end end if(#s ~= #sounds)then sounds = s end end) addEvent("onClientSoundPlay", true) addEventHandler("onClientSoundPlay", getRootElement(), function(theSound) outputChatBox("Sound started playing: "..tostring(theSound)) end) addEvent("onClientSoundStop", true) addEventHandler("onClientSoundStop", getRootElement(), function(theSound) outputChatBox("Sound stopped playing: "..tostring(theSound)) end) function searchTable(tab, var) for k, v in pairs(tab) do if(v == var)then return v end end return false end --]] i commented out script in case you want to add onClientSoundPlay (you only need the onClientElementDestroy for what you asked)
  11. im testing it right now, i'll be back when im done
  12. wow.. that sounds cool. ETA? lol depends on how much school work i have and how much more i want to add to the toolbox
  13. you also forgot two dots after ratio on line 94
  14. Im making a "toolbox" with the ability to record your path and then play and pause it so you can see where you need to put landing, but for the moment, you can put a carshade where you think you will land and then test few times and see more exactly where to put it.
  15. Ehm... onPlayerJoin has no parameters, and source is the player. function showText() -- source is the player end addEventHandler("onPlayerJoin", getRootElement(), showTest)
  16. You can have more objects by making a script that destroys and recreates objects when you are too far from them and cant see them.
  17. ehm, why do you want gui to always be active? you can use onClientKey with mouse_wheel_up and down without gui, and mouse_wheel_up and mouse_wheel_down should be strings, like: addEventHandler( "onClientKey", getRootElement(), function(button, press) if (button == "mouse_wheel_up") then triggerServerEvent ( "pushSpeed", getLocalPlayer()) elseif (button == "mouse_wheel_down") then triggerServerEvent ( "pullSpeed", getLocalPlayer()) end end ) and send localPlayer instead of root. Btw, why do you have server sided script? all that can be done client sided
  18. spawnPlayer does work and it automaticly puts player into vehicle for race gamemode, however race has auto spectator script that handels camera, so you need to disable spectating, and do so that players cant spectate a player that has already died and has respawned. Search for isValidPlayer in race resource and you will find that players cant be spectated if their element data race.finished and race.spectating is true. To disable spectating, search for Spectate.stop, i wont tell you more. (you dont actually need to edit race to make it work) players and that has already died and has respawned will have strange elementAlpha so you need to handle alpha when vehicle changes (or just onClientRender).
  19. what do you call this? setPlayerTeam(source, .. the line is not finished. Use /debugscript 3 next time
  20. try this: local team = getPlayerTeam(source) local teamName = tostring(getTeamName(team)) local player = getElementsByType("player") for i = 1, #player do local playerTeamName = tostring(getTeamName(getPlayerTeam(player[i]))) if(playerTeamName == teamName)then outputChatBox(RGBToHex(getTeamColor(team)).."(TEAM) "..tagcolor.."["..tag.."] #FFFFFF"..name..": "..textcolor..text, player[i], 255,255,255, true) end end
  21. what do you mean by it didn't work? do you see the text but not in color, or do you not see it at all? also use /debugscript 3
  22. second argument is an element, and you are using a string. Try removing getTeamName and only use getPlayerTeam(source) (dont know if it will work because i have never tried to outputChatBox to other than 1 player and all players)
  23. you dont need to create a new vehicle, remove that line and change warp ped to: warpPedIntoVehicle(source, veh)
  24. I tested it, but it didn't work so i edited it a bit. Download the latest version from the same link.
×
×
  • Create New...