Erlkonig Posted April 13, 2021 Share Posted April 13, 2021 damn, gimme a time, I have to turn on my PC then, also the player should be called like "client" Link to comment
FiGo Posted April 13, 2021 Author Share Posted April 13, 2021 nvm i fixed that error but still doesn't work Link to comment
Erlkonig Posted April 13, 2021 Share Posted April 13, 2021 -- client addEventHandler( "onClientKey", root, function(button,press) if button == "1" and press then triggerServerEvent("changeVehicleMode", localPlayer, "sportmod") elseif button == "2" and press then triggerServerEvent("changeVehicleMode", localPlayer, "business") end end ) -- server function setVehicleVelocity(mode) local veh = getPedOccupiedVehicle(client) if (not veh) or getPedOccupiedVehicleSeat((client) ~= 0 ) then return end if (mode == "sportmod") then setVehicleHandling(veh, "maxVelocity", 320) setVehicleHandling(veh, "engineAcceleration", 20) setVehicleHandling(veh, "driveType", "awd") setVehicleHandling(veh, "handlingFlags", 0x1008000) outputChatBox("Sport Mod Enabled", client, 255, 255, 0, true) elseif (mode == "business") then setVehicleHandling(veh, "maxVelocity", 180) setVehicleHandling(veh, "engineAcceleration", 20) setVehicleHandling(veh, "driveType", "awd") setVehicleHandling(veh, "handlingFlags", 0x1008000) outputChatBox("Business Mod Enabled", client, 255, 255, 0, true) end end addEvent("changeVehicleMode", true) addEventHandler("changeVehicleMode", root, setVehicleVelocity) Have a good night Link to comment
FiGo Posted April 13, 2021 Author Share Posted April 13, 2021 ty bro for helping me it worked good if i want to add a weapon to my car what can i use Link to comment
Erlkonig Posted April 14, 2021 Share Posted April 14, 2021 8 hours ago, FiGo said: ty bro for helping me it worked good if i want to add a weapon to my car what can i use Do you want just to attach the weapon object? Link to comment
Erlkonig Posted April 14, 2021 Share Posted April 14, 2021 2 hours ago, FiGo said: Yes https://wiki.multitheftauto.com/wiki/AttachElements Link to comment
FiGo Posted April 14, 2021 Author Share Posted April 14, 2021 timer = {} function incHp(veh) timer[veh] = setTimer(setElementHealth(veh), 10, 10, veh, getElementHealth(veh)+5) end addEventHandler("onVehicleEnter", root, incHp) function stopincHP(veh) if(isTimer(timer[veh] ))then killTimer(timer[veh]) end end addEventHandler("onPlayerVehicleExit", root, stopincHP) what's wrong with that function Link to comment
Erlkonig Posted April 14, 2021 Share Posted April 14, 2021 timer = {} function incHp(veh) timer[veh] = setTimer(setElementHealth(veh), 10, 10, veh, getElementHealth(veh)+5) end addEventHandler("onVehicleEnter", root, incHp) function stopincHP(veh) if(isTimer(timer[veh] ))then killTimer(timer[veh]) end end addEventHandler("onPlayerVehicleExit", root, stopincHP) I just put it in the "code". 1) You're using "onVehicleEnter" which returned as 1st "thePed", not vehicle. You need "onPlayerVehicleEnter". 2) About setTimer. You have to reference a function or create a function inside. What exactly do you want to do? Link to comment
FiGo Posted April 14, 2021 Author Share Posted April 14, 2021 i want to make in the timer that when a specified car is hit it auto fix by 5 % health until it reaches the 100 % Link to comment
Erlkonig Posted April 14, 2021 Share Posted April 14, 2021 2 minutes ago, FiGo said: i want to make in the timer that when a specified car is hit it auto fix by 5 % health until it reaches the 100 % As I understand you correctly? You want to fix the vehicle when the vehicle cloose to broke. You can use that in client-side and vehicles will never break. addEventHandler("onClientVehicleDamage", getRootElement(), function() cancelEvent() end) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now