Jump to content

Xwad

Members
  • Posts

    1,089
  • Joined

  • Last visited

Everything posted by Xwad

  1. yeeees, that's what i needed, thanks a lot
  2. No, the rectangles size is not fixed. It can be changed by moving the cursor, just like in strategy games or when you hold mouse 1 on windows desktop and move your mouse. But my problem is not with the rectangle. That is working fine. My problem is with the detecting of vehicles inside the rectangle. But anyway, i tested your script and its also not detecting the elements inside the rectangle best example: this is what im trying to do
  3. Well it is a difficult problem for me and i can't explain it well. Hope you understand my problem. I want to rotate a vehicles Z axis to the closer direction of the target Z. For example: if the vehicles Z is 90˙ and target Z is 180˙ then rotate it in the positive direction (z=z+1) . If the target Z is 20˙ then rotate it in the negativ direction (z=z-1). always in the direction which is closer.
  4. No, what i am trying to do is a rectangle select like in strategy games when you select units. I get the screen position of the element and if its inside the rectangles area then do somethink function selecting() if getKeyState("mouse1") == true then local screenx, screeny, worldx, worldy, worldz = getCursorPosition() local x = screenx*w - px*w local y = screeny*h - py*h dxDrawLinedRectangle( px*w,py*h, x,y, tocolor ( 255,255,255, 255 ), 2, true ) for i, v in ipairs(getElementsByType("vehicle")) do local vx,vy,vz = getElementPosition(v) local sx,sy = getScreenFromWorldPosition ( vx,vy,vz ) local screenx, screeny, worldx, worldy, worldz = getCursorPosition() if sx > screenx*w and sx < px*w or sx < screenx*w and sx > px*w then if sy > screeny*h and sy < py*h or sy < screeny*h and sy > py*h then outputChatBox("ELEMENT SELECTED (ELEMENT IS INSIDE THE RECTANGLE") end end end else setCursorAlpha(255) removeEventHandler("onClientRender", root, selecting) end end function select_event() px, py, worldx, worldy, worldz = getCursorPosition() setCursorAlpha(0) addEventHandler("onClientRender", root, selecting) end bindKey ("mouse1", "down", select_event)
  5. function test() for i, v in ipairs(getElementsByType("vehicle")) do showCursor(true) local vx,vy,vz = getElementPosition(v) local sx,sy = getScreenFromWorldPosition ( vx,vy,vz ) local screenx, screeny, worldx, worldy, worldz = getCursorPosition() if sx > screenx*w and sx < px*w or sx < screenx*w and sx > px*w then -- error with this line outputChatBox("test") end end end bindKey ("mouse2", "down", test) ERROR: attempt to compare number with bolean. Any idea?
  6. Is it possible to use getCursorPosition without making the cursor visible?
  7. Is it possible to get all the guiStaticImages that have the specified color? I created a few guiStaticImages that are using a fully black png image. i was trying to do it this way, but it does not work.. for i, v in ipairs(getElementType("gui-staticimage")) do local color = guiGetProperty(v, "ImageColours") if color == "000000" then outputChatBox("lol") end end
  8. Xwad

    cursor "wall"

    ohh okay thanks!
  9. Xwad

    cursor "wall"

    Is it possible to create a "wall" element that stops the cursor to go through? A good example is the side of the screen (It is not possible to go further when you reach the side of the screen). Thanks in advance!
  10. Hey, good job. I like your work. My answer to your question: I think it would be really cool if you could convert some jungle maps to gtasa
  11. Xwad

    camera FOV

    lol really, thanks
  12. Xwad

    camera FOV

    Is there any way to zoom with the camera (like with the sniper scope)? I want to change the camera FOV for an attached camera. Thanks
  13. It's because of the onClientResourceStart event, but i dont know why its triggering it twice. Thanks function create() triggerServerEvent ( "create_s", resourceRoot) end addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), create) and the server function create_s() outputChatBox("lol") end addEvent("create_s", true) addEventHandler("create_s", resourceRoot, create_s)
  14. Wow exatcly!! Thanks for your help again <3
  15. Hello. As you can see, in my script i attached 2 weapons to a vehicle. I set a bind for shooting one of the gun. My problem is that when i start the function called "fire_gun_c" then both of the weapons will be fired. So my question is how can i only shoot the weapon "gun1" by using getAttachedElements? client function attach() local gun1 = createWeapon(31, 0,0,0) local gun2 = createWeapon(31, 0,0,0) attachElements ( gun1, veh, 0, 1, 0) attachElements ( gun1, veh, 0, -1, 0) end function fire_gun_c(veh) local attachedElements = getAttachedElements(veh) for ElementKey, ElementValue in ipairs ( attachedElements ) do fireWeapon ( ElementValue ) -- it fires both of the guns because it gets all the data with getAttachedElements end end addEvent("fire_gun_c", true) addEventHandler ( "fire_gun_c", resourceRoot, fire_gun_c)
  16. Is it possible to prevent trggerServerEvent and TriggerClientEvent from triggering other resources? Thanks
  17. Xwad

    createWeapon bug

    Still not working. Any idea??
  18. Xwad

    createWeapon bug

    yes but it's perfectly working when i stop the map
  19. Xwad

    createWeapon bug

    Already tried By the way now i realised that the weapon is created but its not shooting somewhy. I did an outputDebugString and it said: Attempt to concatenate local "gun" (a userdata value) my code client function create_gun() if isPedInVehicle (localPlayer) then local veh = getPedOccupiedVehicle(localPlayer) if getElementModel(veh) == id then fire_gun() end end end bindKey("mouse1", "down", create_gun) function fire_gun() if isPedInVehicle (localPlayer) then if getKeyState( "mouse1" ) == true then local veh = getPedOccupiedVehicle(localPlayer) triggerServerEvent ( "update_gun_s", localPlayer, veh ) setTimer ( fire_gun, 180, 1) end end end function update_gun_c(veh) local x,y,z = getElementPosition (veh) local base = createWeapon("sniper", 0,0,0) local gun = createWeapon("sniper", 0,0,0,0,0,0,0) local sound_gun = playSound3D ( "files/gun.wav", x,y,z, false ) setSoundMaxDistance ( sound_gun, 500 ) setSoundVolume(sound_gun, 1) setElementCollisionsEnabled(gun, false) setElementStreamable ( gun, false ) outputChatBox("1",255,255,255) setWeaponProperty ( gun, "fire_rotation", 0, 0, -5 ) setWeaponProperty ( gun, "weapon_range", 10000 ) setWeaponProperty ( gun, "target_range", 10000 ) setWeaponProperty( gun, "damage", 38) attachElements(base,veh,0,0,0,0,0,95) attachElements(gun,base,1.18, 0.24, 0.2, 0, 0, 0) attachElements(sound_gun,gun,0,0,0) fireWeapon(gun) destroyElement(base) destroyElement(gun) end addEvent( "update_gun_c", true ) addEventHandler( "update_gun_c", localPlayer, update_gun_c ) server function update_gun_s(veh) triggerClientEvent ("update_gun_c", getRootElement(), veh) end addEvent("update_gun_s", true) addEventHandler("update_gun_s", root, update_gun_s)
  20. I found a really interesting bug, and i can not fix it. Well, i created a script that creates and fires a custom wepon when a bind is pressed. It's just working fine, but when i use it on the middle of my map, then the createWeapon function is not working without debugscript. The map contains 1200 Elements. When i reduced the maps objects to ca. 300-400 objects then it worked. I really dont understand why is that happening. Is there any way to make createWepon work beside 1200 elements? Thanks
  21. Everythink is just working fine. The problem is that the triggerServerEvent is not triggering to the server. line: 43, 69, 75, 81, 87 CLIENT.LUA function create_weapon(veh) local x,y,z = getElementPosition(veh) local obj = createObject ( 357, x,y,z) attachElements ( obj, veh, 0,0,0,0,0,0 ) setElementData(localPlayer,"obj",obj) local gun1 = createWeapon(30, x,y,z) local gun2 = createWeapon(30, x,y,z) local gun3 = createWeapon(30, x,y,z) local gun4 = createWeapon(30, x,y,z) setElementData(localPlayer,"gun1",gun1) setElementData(localPlayer,"gun2",gun2) setElementData(localPlayer,"gun3",gun3) setElementData(localPlayer,"gun4",gun4) attachElements ( gun1, obj, 1.18, 0.24, 0, 0, -5, 0) attachElements ( gun2, obj, 1.18, -0.55, 0, 0, -5, 0) attachElements ( gun3, obj, 1.18, -0.55, 0.35, 0, -5, 0) attachElements ( gun4, obj, 1.18, 0.24, 0.35, 0, -5, 0) setWeaponState(gun1, "ready") setWeaponState(gun2, "ready") setWeaponState(gun3, "ready") setWeaponState(gun4, "ready") addEventHandler ( "onClientPreRender", root, rotate_object ) end function rotate_object() local veh = getPedOccupiedVehicle ( localPlayer ) local obj = getElementData(localPlayer,"obj") local _,_,rz = getVehicleComponentRotation(veh, "misc_a") local rx,_,_ = getVehicleComponentRotation(veh, "misc_b") triggerServerEvent("rotateWeapon", localPlayer, veh,obj,rx,rz) end fired1 = false fired2 = true fired3 = true fired4 = true function fire() if getKeyState( "mouse1" ) == true then local veh = getPedOccupiedVehicle(localPlayer) if isPedInVehicle(localPlayer) and getElementModel(veh) == 602 then if fired1 == false then local gun1 = getElementData (localPlayer, "gun1") fired1 = true fired2 = false triggerServerEvent ( "fire_server1", localPlayer,veh,gun1) elseif fired2 == false then local gun2 = getElementData (localPlayer, "gun2") fired2 = true fired3 = false triggerServerEvent ( "fire_server2", localPlayer,veh,gun2) elseif fired3 == false then local gun3 = getElementData (localPlayer, "gun3") fired3 = true fired4 = false triggerServerEvent ( "fire_server3", localPlayer,veh,gun3) elseif fired4 == false then local gun4 = getElementData (localPlayer, "gun4") fired4 = true fired1 = false triggerServerEvent ( "fire_server4", localPlayer,veh,gun4) end setTimer ( fire, 200, 1 ) end end end bindKey("mouse1", "down", fire) function fire_client(veh,gun1) outputChatBox("fire_client1",2,1,10) outputChatBox ( "gun1",255,0,100 ) fireWeapon(gun1) fireWeapon(gun1) local x,y,z = getElementPosition(veh) local sound_gun1 = playSound3D("files/shoot.wav",x,y,z, false) setSoundMaxDistance( sound_gun1, 500 ) setSoundVolume(sound_gun1, 1) end addEvent("fire_client", true) addEventHandler("fire_client", root, fire_client) function fire_client2(veh,gun2) outputChatBox("fire_client2",2,1,10) outputChatBox ( "gun2",255,0,100 ) fireWeapon(gun2) fireWeapon(gun2) local x,y,z = getElementPosition(veh) local sound_gun2 = playSound3D("files/shoot.wav",x,y,z, false) setSoundMaxDistance( sound_gun2, 500 ) setSoundVolume(sound_gun2, 1) end addEvent("fire_client2", true) addEventHandler("fire_client2", root, fire_client2) function fire_client3(veh,gun3) outputChatBox("fire_client3",2,1,10) outputChatBox ( "gun3",255,0,100 ) fireWeapon(gun3) fireWeapon(gun3) local x,y,z = getElementPosition(veh) local sound_gun3 = playSound3D("files/shoot.wav",x,y,z, false) setSoundMaxDistance( sound_gun3, 500 ) setSoundVolume(sound_gun3, 1) end addEvent("fire_client3", true) addEventHandler("fire_client3", root, fire_client3) function fire_client4(veh,gun4) outputChatBox("fire_client4",2,1,10) outputChatBox ( "gun4",255,0,100 ) fireWeapon(gun4) fireWeapon(gun4) local x,y,z = getElementPosition(veh) local sound_gun4 = playSound3D("files/shoot.wav",x,y,z, false) setSoundMaxDistance( sound_gun4, 500 ) setSoundVolume(sound_gun4, 1) end addEvent("fire_client4", true) addEventHandler("fire_client4", root, fire_client4) SERVER.LUA function rotateWeapon(veh,obj,rx,rz) rx = (-rx) setElementAttachedOffsets ( obj, 0, 0, 0, 0, rx+7, rz+96) end addEvent("rotateWeapon", true) addEventHandler("rotateWeapon", root, rotateWeapon) function fire_server1(veh,gun1) outputChatBox("fire_server1") triggerClientEvent("fire_client1", getRootElement(), veh,gun1) end addEvent("fire_server1", true) addEventHandler("fire_server1",getRootElement(), fire_server1) function fire_server2(veh,gun1) outputChatBox("fire_server2") triggerClientEvent("fire_client2", getRootElement(), veh,gun2) end addEvent("fire_server2", true) addEventHandler("fire_server2",getRootElement(), fire_server2) function fire_server3(veh,gun1) outputChatBox("fire_server3") triggerClientEvent("fire_client3", getRootElement(), veh,gun3) end addEvent("fire_server3", true) addEventHandler("fire_server3",getRootElement(), fire_server3) function fire_server4(veh,gun1) outputChatBox("fire_server4") triggerClientEvent("fire_client4", getRootElement(), veh,gun4) end addEvent("fire_server4", true) addEventHandler("fire_server4",getRootElement(), fire_server4)
  22. Xwad

    can't store data

    yeah, it can also be like this, but this will not fix the bugs:/
×
×
  • Create New...