Genetikk Posted December 2, 2015 Share Posted December 2, 2015 Hello, I started with my own project and it is a Shooter Server for the beginning. I am a Newbie in Scripting and till today I had luck, scripting the important scripts for the server. Now I have got Problems with scripting the Spawnprotection for Vehicles (Gamemode = Race). I really have got problems with the setTimer function and I hope you can help me, writing the Script, so people might just shoot, after 5 seconds of the Map is over. Here's the Shooter Script (Clientside): cLP = getLocalPlayer() screenWidth, screenHeight = guiGetScreenSize() function cRStest() setTimer(resourcesCheck, 10000, 1) end addEventHandler("onClientResourceStart", getRootElement(), cRStest) function resourcesCheck() if check=="done" then return else setRadioChannel(0) setTimer(cbinds, 1000, 1) textToggle=0 check="done" end end function cRS() if check=="done" then return else setRadioChannel(0) setTimer(cbinds, 3333, 1) textToggle=0 check="done" end end addEventHandler("onClientPlayerSpawn", getLocalPlayer(), cRS) function cbinds() local keys1 = getBoundKeys("vehicle_fire") local keys2 = getBoundKeys("vehicle_secondary_fire") if keys1 then for keyName, state in pairs(keys1) do bindKey(keyName, "down", cdoshoot) end end if keys2 then for keyName, state in pairs(keys2) do bindKey(keyName, "down", cdoshoot) end end if (not keys1) and (not keys2) then bindKey("F", "down", cdoshoot) bindKey("lctrl", "down", cdoshoot) bindKey("rctrl", "down", cdoshoot) end theVehicle = getPedOccupiedVehicle(cLP) allowShoots() end function allowShoots() bindTrigger = 1 end function cdoshoot() if bindTrigger == 1 then if not isPedDead(cLP) then bindTrigger = 0 local x,y,z = getElementPosition(theVehicle) local rX,rY,rZ = getElementRotation(theVehicle) local x = x+4*math.cos(math.rad(rZ+90)) local y = y+4*math.sin(math.rad(rZ+90)) createProjectile(theVehicle, 19, x, y, z, 1.0, nil) setTimer(allowShoots, 3000, 1) end end end Alternative: Scripting the setVehicleDamageProof after 5 Seconds time of the Map is over. My Try: function activategodmode(startedMap, source) local mapRoot = getResourceRootElement(startedMap) local thePlayer = getVehicleOccupants(source) if(thePlayer) then vehicles = getElementsByType ( "vehicle" ) for vehicleKey, vehicleValue in ipairs(vehicles) do setVehicleDamageProof (vehicleValue, true) end end end addEventHandler("onGamemodeMapStart", getRootElement(), activategodmode) setTimer(function () removeEventHandler ( "onGamemodeMapStart", root, activategodmode ) end, 5000, 1) 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