-
Posts
1,090 -
Joined
-
Last visited
Everything posted by Xwad
-
ERROR: Attempt to perform arithmetic on local 'rotZ' (a nil value)
-
I downloaded this custom rocket script: https://community.multitheftauto.com/in ... ls&id=3742 my problem is that the rocket projectile is not shooting to the direction where the locals player camera look at. my code starts at line 58. client gLPlayer = getLocalPlayer() addEvent("onClientPlayerFireRocket", false) function fireRocketByRotation(startX, startY, startZ, rotX, rotZ, velocity) local nrotX = -rotX local nrotZ = -(rotZ + 180) local velZ = velocity * math.sin(math.rad(rotX)) local a = velocity * math.cos(math.rad(rotX)) local velX = a * math.sin(math.rad(-rotZ)) local velY = a * math.cos(math.rad(-rotZ)) createProjectile(gLPlayer, 19, startX, startY, startZ, 1.0, nil, nrotX, 0, nrotZ, velX / 50, velY / 50, velZ / 50) triggerEvent("onClientPlayerFireRocket", gLPlayer) end function fireRocketByTargetPosition(startX, startY, startZ, targetX, targetY, targetZ, velocity) local rotZ = getRotationZ(startX, startY, targetX, targetY) local rotX = getRotationX(startX, startY, startZ, targetX, targetY, targetZ) fireRocketByRotation(startX, startY, startZ, rotX, rotZ, velocity) end function getRotationZ(startX, startY, endX, endY) -- Dommed-Space-Marine local height = endX - startX local line = endY - startY local t = -math.deg(math.atan2(height, line)) if t < 0 then t = t + 360 end return t end function getRotationX(startX, startY, startZ, endX, endY, endZ) -- Dommed-Space-Marine local line = ((endX - startX) ^ 2 + (endY - startY) ^ 2) ^ 0.5 local height = endZ - startZ local t = math.deg(math.atan2(height, line)) --[[ if t < 0 then t = t + 360 end --]] return t end function rocket() local x,y,z = getElementPosition(localPlayer) <--- THIS IS WORKING local rx,_,rz = getPedCameraRotation(localPlayer) <--- THIS IS NOT WORKING fireRocketByRotation(x,y,z,rx,rz 50) <--- THIS IS NOT WORKING end end bindKey("mouse1", "down", rocket)
-
update: New Bunker model (again) New screenshots! New video!
-
Thanks.
-
Pls someone reupload!
-
this map model is more than 512,512,512. How is it working then??! https://community.multitheftauto.com/in ... s&id=13136
-
I thought its working but it isnt:( So this script makes possible when a player starts pressing W in a vehicle (id:480) then a sound will be attached to the players vehicle! now i got a really strange bug.. the bug is: player 1 starts pressing W (in the vehicle 480) and after that, player 2 also starts pressing W (in the vehicle 480). When player 1 stops pressing W then the sound will not stop in his vehicle, it will only stop on players 2 vehicle!! And the same happens on the contrary!!! Please help! I am trying to fix that bug sice 3 hours!! Here is the code: Thanks in advance! CLIENT function start_sound(player) local vehicle = getPedOccupiedVehicle(player) local x,y,z = getElementPosition(vehicle) if not isElement(sound_move) then local sound_move = playSound3D("files/tank_move.wav",x,y,z, true) setSoundMaxDistance( sound_move, 40 ) setSoundVolume(sound_move, 0.5) attachElements ( sound_move, vehicle, 0,0,0 ) setElementData(localPlayer, "sound_move", sound_move) end end end addEvent("start_sound",true) addEventHandler("start_sound", getRootElement(), start_sound) function stop_sound() local sound_move = getElementData(localPlayer, "sound_move") if isElement(sound_move) then stopSound(sound_move) outputChatBox("sound_move stopped",200,0,0) end end addEvent("stop_sound",true) addEventHandler("stop_sound", getRootElement(), stop_sound) function stop_client() triggerServerEvent("stop_sound", root, localPlayer) end function bindTheKeys (thePlayer, seat) local vehicle = getPedOccupiedVehicle(localPlayer) local id = getElementModel ( vehicle ) if id == 480 then bindKey ("w", "up", stop_client) bindKey ("mouse1", "down", projectile) end end addEventHandler("onClientVehicleEnter", getRootElement(), bindTheKeys) SERVER function start_sound(keyPresser) triggerClientEvent(root, "start_sound", root, keyPresser) end function bindTheKeys (thePlayer, seat, jacked) if (getElementModel (source) == 480) then bindKey (thePlayer, "w", "down", start_sound) end end addEventHandler ("onVehicleEnter", getRootElement(), bindTheKeys) function stop_sound () triggerClientEvent("stop_sound", getRootElement()) end addEvent( "stop_sound", true ) addEventHandler( "stop_sound", resourceRoot, stop_sound )
-
Yeah its working now! Thx again!!
-
i already tried that. But i think the problem is becaouse the playSound3D does not have local. is this possible? Maybe i have to use setElementData?
-
I have a new problem!! i added a sound stop function to the script. The problem with it is that the sound stop function is executing for all players:/ so when a player stops pressing w then the sound will stop on all players vehicle:/ I hope you can help me:/ server function start_sound(keyPresser) triggerClientEvent(root, "start_sound", root, keyPresser) end function stop_sound(keyPresser) triggerClientEvent(root, "stop_sound", root, keyPresser) end function bindTheKeys (thePlayer, seat, jacked) if (getElementModel (source) == 480) then bindKey (thePlayer, "w", "down", start_sound) bindKey (thePlayer, "w", "up", stop_sound) end end addEventHandler ("onVehicleEnter", getRootElement(), bindTheKeys) client function start_sound(player) local vehicle = getPedOccupiedVehicle(player) local x,y,z = getElementPosition(vehicle) if not isElement(sound_track) then sound_start = playSound3D("files/start.wav",x,y,z, false) setSoundMaxDistance( sound_start, 40 ) attachElements ( sound_start, vehicle, 0,0,0 ) sound_track = playSound3D("files/tracks.wav",x,y,z, true) setSoundMaxDistance( sound_track, 40 ) setSoundVolume(sound_track, 0.5) attachElements ( sound_track, vehicle, 0,0,0 ) if not isElement(sound_move) then sound_move = playSound3D("files/tank_move.wav",x,y,z, true) setSoundMaxDistance( sound_move, 40 ) setSoundVolume(sound_move, 0.5) attachElements ( sound_move, vehicle, 0,0,0 ) setTimer ( function () addEventHandler("onClientRender", root, stop_sound2) end, 50, 1 ) end end end addEvent("start_sound",true) addEventHandler("start_sound", getRootElement(), start_sound) function stop_sound(player) local vehicle = getPedOccupiedVehicle(player) if isElement(sound_move) then stopSound(sound_move) outputChatBox("sound_move stopped",200,0,0) end end addEvent("stop_sound",true) addEventHandler("stop_sound", getRootElement(), stop_sound) function stop_sound2() if isPedInVehicle ( localPlayer ) then local vehicle = getPedOccupiedVehicle(localPlayer) local vx,vy,vz = getElementVelocity(vehicle) local id = getElementModel ( vehicle ) if id == 480 then if vx+vy+vz == 0 then if isElement(sound_track) then outputChatBox("sound_track stopped",200,0,0) stopSound(sound_track) removeEventHandler("onClientRender", root, stop_sound2) end end end end end
-
yeah its working now! Thanks guys:)
-
still not working:// Maybe i have to bind the key in client side and trigger to server and after then trigger again to client?
-
like this? function start_sound() outputChatBox("triggerClientEvent") for _, player in ipairs(getElementsByType("player")) do triggerClientEvent(player, "start_sound", player) end end
-
only the local player can hear it ( the player in the vehicle) , other players cant hear the sound.. Thanks in advance! server function start_sound() outputChatBox("triggerClientEvent") triggerClientEvent(getRootElement(), "start_sound", getRootElement()) end function bindTheKeys (thePlayer, seat, jacked) if (getElementModel (source) == 480) then bindKey (thePlayer, "w", "down", start_sound) outputChatBox("onVehicleEnter") end end addEventHandler ("onVehicleEnter", getRootElement(), bindTheKeys) client function start_sound() local vehicle = getPedOccupiedVehicle(localPlayer) local x,y,z = getElementPosition(vehicle) if not isElement(sound_track) then sound_start = playSound3D("files/start.wav",x,y,z, false) setSoundMaxDistance( sound_start, 40 ) setSoundVolume(sound_start, 0.-- s8) --> attachElements ( sound_start, vehicle, 0,0,0 ) sound_track = playSound3D("files/tracks.wav",x,y,z, true) setSoundMaxDistance( sound_track, 40 ) setSoundVolume(sound_track, 0.5) attachElements ( sound_track, vehicle, 0,0,0 ) if not isElement(sound_move) then sound_move = playSound3D("files/tank_move.wav",x,y,z, true) setSoundMaxDistance( sound_move, 40 ) setSoundVolume(sound_move, 0.5) attachElements ( sound_move, vehicle, 0,0,0 ) setTimer ( function () addEventHandler("onClientRender", root, stop_sound2) end, 50, 1 ) end end end addEvent("start_sound",true) addEventHandler("start_sound", getRootElement(), start_sound)
-
I had no time to continue. Now i am working on the map again. i think i will release it in this month. The main problem is still with the exported models col. Its not working correctly.
-
And i use setPedStat to set the level. Os that not possible?
-
Why? If the player has std level then his weapon will have 20 ammo in the mag and if the player has pro level then he will have 30 ammo in mag
-
and if i use different skill levels? poor, std, pro??!
-
Is it possible to set the maximum clip ammo of a default weapon, without setWeaponPoroperty? Just becaouse im working on a custom weapon script and i added different skins for 1 weapon. So i want to make that if a player has skin id 20 then his mp5 weapon maximum clip ammo will be 20. But if the player has skin id 30 then his weapon maximum clip ammo will be 40. Is this possible somehow? I saw a function on wiki called: getPedAmmoInClip. Is there a same function with set? Thanks !
-
this is not working too:/ pls help! client --SNIPER function custom_sniper() local id = getElementModel ( source ) if id == 23 then local PedWeapon = getPedWeapon(localPlayer) if (PedWeapon == 34) then sniper = createObject(1853,-1317,-167,14.14) exports.bone_attach:attachElementToBone(sniper,localPlayer,12,0,0,0,0,-90,0) outputChatBox("sniper create", 255, 255, 0) end end if id == 23 then local PedWeapon = getPedWeapon(localPlayer) if not (PedWeapon == 34) then destroyElement(sniper) outputChatBox("sniper destroyed", 255, 0, 0) end end end addEvent( "client", true ) addEventHandler( "client", root, custom_sniper ) server function server () triggerClientEvent ( root, "client", source) end addEvent( "server", true ) addEventHandler( "server", resourceRoot, server )
-
So i have to use triggerServerEvent right?
