Bean666 Posted June 27, 2016 Share Posted June 27, 2016 the problem with you is , you don't even know what you're doing , because you're not trying to learn by yourself , this is not a copy paste work , it's pretty boring seeing people not trying stuff by themselves. Link to comment
mores Posted June 27, 2016 Author Share Posted June 27, 2016 tell me one thing.is it clientside or serverside ? Link to comment
Bean666 Posted June 27, 2016 Share Posted June 27, 2016 both. if it's blue it's shared. Link to comment
mores Posted June 27, 2016 Author Share Posted June 27, 2016 damm it whats the name of timer ? ( ) Link to comment
mores Posted June 27, 2016 Author Share Posted June 27, 2016 replace killtimer for reset timer in server ? I'm thinking about the sign ( your vehicle will be change in ) Link to comment
aka Blue Posted June 27, 2016 Share Posted June 27, 2016 If you wanna reset the timer, use resetTimer, yes. And the name of the timer, in this case, vehChangeTimer Link to comment
mores Posted June 27, 2016 Author Share Posted June 27, 2016 but should I put it on client or server for example resettimer(vehchangetimer) end ? Link to comment
mores Posted June 27, 2016 Author Share Posted June 27, 2016 it doesn't work, counter is not restarts Link to comment
aka Blue Posted June 27, 2016 Share Posted June 27, 2016 if isTimer(vehChangeTimer) then resetTimer(vehChangeTimer) end Link to comment
mores Posted June 27, 2016 Author Share Posted June 27, 2016 yea and it doesnt work i've done it I told about sign not main script Link to comment
aka Blue Posted June 27, 2016 Share Posted June 27, 2016 Be pacient, we are not slaves Link to comment
Bean666 Posted June 27, 2016 Share Posted June 27, 2016 try. function startVehicleChanging() if isTimer(vehChangeTimer) then killTimer(vehChangeTimer) end vehChangeTimer = setTimer( function() for _,plr in pairs(getElementsByType("player")) do local veh = getPedOccupiedVehicle(plr) local model = vehicleIDS[math.random(1,#vehicleIDS)] if veh and model and getPedOccupiedVehicleSeat(plr) == 0 then local x,y,z = getElementVelocity(veh) setElementVelocity(veh,x,y,z+0.05) local hp = getElementHealth(veh) setElementModel(veh,model) setElementHealth(veh,hp) end end end ,15000,0) end addEvent("onRaceStateChanging",true) addEventHandler("onRaceStateChanging",root, function (new) if (new == "Running") then startVehicleChanging() triggerClientEvent(source,"onCounterStart",source) end if (new =="LoadingMap") then triggerClientEvent(source,"removeCounter",source) if isTimer(vehChangeTimer) then resetTimer(vehChangeTimer) end if isTimer(vehChangeTimer) then killTimer(vehChangeTimer) end end end ) function startEverything() addEventHandler("onClientRender",root,drawCounterSHI) timer = setTimer(function() counter = counter - 1 if counter < 0 then counter = 15 r,g,b = 0,255,0 end if counter <= 3 then r,g,b = 255,0,0 end end,1000,0) end addEvent("onCounterStart",true) addEventHandler("onCounterStart",getRootElement(),startEverything) addEvent("removeCounter", true) addEventHandler("removeCounter", getRootElement(), function () removeEventHandler("onClientRender", root, draw) if isTimer(timer) then resetTimer(timer) end if isTimer(timer) then killTimer(timer) end end ) Link to comment
mores Posted June 27, 2016 Author Share Posted June 27, 2016 shaman thank for your attemps but it only freeze it during the map loading Link to comment
Bean666 Posted June 27, 2016 Share Posted June 27, 2016 shaman thank for your attemps but it only freeze it during the map loading that's why it's "LoadingMap", i can't help you if you don't know anything, i can also barely understand what you mean. check what you need here and change it with it: undefined NoMap LoadingMap PreGridCountdown GridCountdown Running MidMapVote SomeoneWon TimesUp EveryoneFinished PostFinish NextMapSelect NextMapVote ResourceStopping Link to comment
Bean666 Posted June 27, 2016 Share Posted June 27, 2016 shaman thank for your attemps but it only freeze it during the map loading that's why it's "LoadingMap", i can't help you if you don't know anything, i can also barely understand what you mean. anyways if possible can u show me a video of whats wrong so i can understand what you mean. check what you need here and change it with it: undefined NoMap LoadingMap PreGridCountdown GridCountdown Running MidMapVote SomeoneWon TimesUp EveryoneFinished PostFinish NextMapSelect NextMapVote ResourceStopping Link to comment
mores Posted June 27, 2016 Author Share Posted June 27, 2016 (edited) look when news map is start after 3.2.1.go the counter should start again like main script on every map Look ( your vehicle will be change ) when new map starts it start work again 15.14.13..... on every map Edited June 28, 2016 by Guest Link to comment
aka Blue Posted June 27, 2016 Share Posted June 27, 2016 setElementModel to change the model of the vehicle. If you dont test by yourself, you never gonna learn. Link to comment
Tails Posted June 28, 2016 Share Posted June 28, 2016 Replace everything with this. The timer doesn't always match up perfectly with the server, though. Probably getTimerDetails or making everything client-side would be better so the timer would match up correctly. It's the best I can do for you for now. And, mores. Instead of begging constantly for every little change, why not put that effort in trying to fix it on your own? I was hesistant about replying again to this thread but this is the final thing I will post here unless you actually try and show some code (that indicates you've put some time and thought into) of your own. Good luck Some great learning material: https://wiki.multitheftauto.com/wiki/Main_Page https://en.wikibooks.org/wiki/Lua_Programming http://lua-users.org/wiki/TutorialDirectory http://luatut.com/crash_course.html Client: -->> -- This piece of code probably won't make a lot of sense to you. It replaces the original dxDrawText function to make it scale and fit on every resolution, so you don't have to worry about it. local osW, osH = 1024,768 -- Original screen width and height, do not change it unless you're trying to position dxDrawText's on your own screen then change this to your own resolution. local csW, csH = guiGetScreenSize() -- Client/player screen width and height local DrawText = dxDrawText function dxDrawText(...) arg[2], arg[3], arg[4], arg[5], arg[7] = arg[2]/osW*csW, arg[3]/osH*csH, arg[4]/osW*csW, arg[5]/osH*csH, (arg[7] or 1)/osW*csW return DrawText(unpack(arg)) end --<< local isTimerVisible = false function displayCounter() dxDrawText("Your vehicle will change in: "..count, 237 + 1, 644 + 1, 811 + 1, 685 + 1, tocolor(0, 0, 0, 255), 1.60, "default", "center", "center", false, false, true, false, false) -- background (shadow) dxDrawText("Your vehicle will change in: "..count, 237, 644, 811, 685, tocolor(255, 162, 0, 255), 1.60, "default", "center", "center", false, false, true, false, false) -- foreground end function showCounter(Time) if Time then count = Time counting = setTimer(function() count = count - 1 end,1000,count) if not isTimerVisible then addEventHandler("onClientRender",root,displayCounter) isTimerVisible = true end else if isTimer(counting) then killTimer(counting) end removeEventHandler("onClientRender",root,displayCounter) isTimerVisible = false end end addEvent("showCounter",true) addEventHandler("showCounter",resourceRoot,showCounter) Server: local Time = 15 -- Change this to your preferred time in seconds function onRoundStart(state) if state == "Running" then changeVeh() changeTimer = setTimer(changeVeh,Time*1000,0) elseif state == "PostFinish" or state == "TimesUp" or state == "EveryoneFinished" or state == "SomeoneWon" or state == "ResourceStopping" or state == "NoMap" or state == "LoadingMap" then if isTimer(changeTimer) then killTimer(changeTimer) end triggerClientEvent("showCounter",resourceRoot,false) end end addEvent("onRaceStateChanging",true) addEventHandler("onRaceStateChanging",root,onRoundStart) function onRacerWasted() outputChatBox(getPlayerName(source).." died.") triggerClientEvent(source,"showCounter",resourceRoot,false) end addEvent("onPlayerRaceWasted",true) addEventHandler("onPlayerRaceWasted",root,onRacerWasted) function changeVeh() for _,plr in ipairs(getElementsByType("player")) do if not isPedDead(plr) then triggerClientEvent(plr,"showCounter",resourceRoot,Time) local veh = getPedOccupiedVehicle(plr) local model = vehicleIDS[math.random(1,#vehicleIDS)] if veh and model and getPedOccupiedVehicleSeat(plr) == 0 then local x,y,z = getElementVelocity(veh) setElementVelocity(veh,x,y,z+0.05) local hp = getElementHealth(veh) setElementModel(veh,model) setElementHealth(veh,hp) end end end end Link to comment
mores Posted June 28, 2016 Author Share Posted June 28, 2016 THANK YOU ALL for your help I close the topic Link to comment
mores2 Posted August 11, 2016 Share Posted August 11, 2016 Hi Guys again ! I want to tell you something. I've forgotten my password to "mores" so I 've creted this account. I know I know I closed this topic but after my holiday I thought I want to create this script and I promise I will try to do this with your help,( not only you like before) Can you give me secound chance ? I promise I will try Link to comment
mores2 Posted August 12, 2016 Share Posted August 12, 2016 Can you tell me what function should I use ? Becouse now the counter is not compatible with script and not restart after map loading Can you help ? Link to comment
Recommended Posts