mores3 Posted January 14, 2017 Author Share Posted January 14, 2017 I've tried do this and understand it I don't know how to do this I only need have this stupid counter ... sorry I'm bit angry Guys don't be ruthless Please, just write it for me ( counter ) - main script works perfectly Link to comment
LoPollo Posted January 14, 2017 Share Posted January 14, 2017 I lost the thread, so can you post the code you have now? Link to comment
mores3 Posted January 14, 2017 Author Share Posted January 14, 2017 this ( mean nothing ) local sX,sY = guiGetScreenSize() local counter = 15 local r,g,b = 0,255,0 function drawCounterSHI() dxDrawText("Your vehicle will change in: "..counter,0,sY*0.8,sX,sY,tocolor (r,g,b,255),2,"default","center","top",false,false,false) end function startEverything() addEventHandler("onClientRender",root,drawCounterSHI) setTimer(function() counter = counter - 1 if counter < 1 then counter = 15 r,g,b = 0,255,0 end end,1000,0) end addEvent("onCounterStart",true) addEventHandler("onCounterStart",getRootElement(),startEverything) it dont disappear when map is loading/changing and when new map is loaded it have start again Link to comment
LoPollo Posted January 14, 2017 Share Posted January 14, 2017 ok here's an incomplete UNTESTED example of how i think it can be done* I have no idea on how you want to manage onCounterStart... so i leave this to you unchanged When you die the text disappear When you spawn the text appear When the race state changes, you can make the client text appear/disappear** * I have wrote this in a hurry, i didn't check any syntax error, but i tried to be as clear as possible and i hope you understand the logic. ** ToDo: you must change the values of the table in makeClientKnowMapChange to make the triggers work. I have no idea of the correct values, experiment this yourself, since now i can't test. --client local sX,sY = guiGetScreenSize() local counter = 15 local r,g,b = 0,255,0 local counterTimer local isTextShowing --alternative to todo function "isEventHandled" addEvent( "onServerStopTextRequest", true ) addEvent( "onServerStartTextRequest", true ) function drawCounterSHI() dxDrawText( "Your vehicle will change in: "..counter, 0, sY*0.8, sX,sY, tocolor(r,g,b,255), 2, "default", "center", "top", false, false, false ) end function startEverything() startText() --start the timer and make the text visible end addEvent( "onCounterStart", true) addEventHandler( "onCounterStart", root, startEverything ) function stopText() --stop the timer, it's useless now if isTimer( counterTimer ) then killTimer(counterTimer) end --make the text not visible if isTextShowing then removeEventHandler( "onClientRender", root, drawCounterSHI ) isTextShowing = false end end addEventHandler( "onClientPlayerWasted", localPlayer, stopText ) addEventHandler( "onServerStopTextRequest", resourceRoot, stopText ) function startText() if isTimer( counterTimer ) then killTimer( counterTimer ) end --set the counter to 15s counter = 15 --start the timer again counterTimer = setTimer( function() counter = counter - 1 if counter < 1 then counter = 15 r,g,b = 0,255,0 end end, 1000, 0 ) --make the text visible if not isTextShowing then addEventHandler( "onClientRender", root, drawCounterSHI ) isTextShowing = true end end addEventHandler( "onClientPlayerSpawn", localPlayer, startText ) addEventHandler( "onServerStartTextRequest", resourceRoot, startText ) --server function makeClientKnowMapChange( newState, oldState ) local states = { ["undefined"] = nil, ["NoMap"] = nil, ["LoadingMap"] = nil, ["PreGridCountdown"] = nil, ["GridCountdown"] = nil, ["Running"] = nil, ["MidMapVote"] = nil, ["SomeoneWon"] = nil, ["TimesUp"] = nil, ["EveryoneFinished"] = nil, ["PostFinish"] = nil, ["NextMapSelect"] = nil, ["NextMapVote"] = nil, ["ResourceStopping"] = nil, } if states[newState] == true then triggerClientEvent( root, "onServerStartTextRequest", resourceRoot ) elseif states[newState] == false then triggerClientEvent( root, "onServerStopTextRequest", resourceRoot ) end --ignore nil values end addEventHandler( "onRaceStateChanging", root, makeClientKnowMapChange ) Link to comment
mores3 Posted January 15, 2017 Author Share Posted January 15, 2017 (edited) Hello BIG THANK YOU LoPollo LoPollo I've used your client script without any corrections and it work as I need **Only thing is to start it only after counting down ( it is cosmetic correction ) <-- I need help only with this I don't know ( spawn player = spawn after counting down or when player is visible before counting down ) BTW watch my video I think it show what I mean (inscriptions) and Please watch to the end Again big THANK YOU, You are very nice and helpful person Huge positive for LoPollo Edited January 15, 2017 by mores3 small mistake Link to comment
LoPollo Posted January 15, 2017 Share Posted January 15, 2017 That's because players get spawned before the match starts i guess... So if there's a state that define when the match is ongoing and when not i should use it, so i must pass the states on the client. Again, this is untested. I made state handling clientside, so client now knows what state is currently active. To fix the issue you said i made the startText return and not perform any further action if the current state is not true. So when you spawn but the match is not ongoing the text won't be drawn. Again, all the states table is filled with nils*, cause i have no exact idea of when each state becomes active ( i do not play race ), so edit it if it's needed. When that state becomes the current state: nil -> no action true -> the text will be shown (call startText) false -> the text will be hidden (call stopText) * i set Running as true because this is the state i think means the match is ongoing --client local sX,sY = guiGetScreenSize() local counter = 15 local r,g,b = 0,255,0 local counterTimer local isTextShowing --alternative to todo function "isEventHandled" --set the states to nil to not perform any action when that state becomes the current state, true to show text, false to hide text local states = { ["undefined"] = nil, ["NoMap"] = nil, ["LoadingMap"] = nil, ["PreGridCountdown"] = nil, ["GridCountdown"] = nil, ["Running"] = true, ["MidMapVote"] = nil, ["SomeoneWon"] = nil, ["TimesUp"] = nil, ["EveryoneFinished"] = nil, ["PostFinish"] = nil, ["NextMapSelect"] = nil, ["NextMapVote"] = nil, ["ResourceStopping"] = nil, } addEvent( "onServerRaceStateChangingNotice", true ) function drawCounterSHI() dxDrawText( "Your vehicle will change in: "..counter, 0, sY*0.8, sX,sY, tocolor(r,g,b,255), 2, "default", "center", "top", false, false, false ) end function startEverything() startText() --start the timer and make the text visible end addEvent( "onCounterStart", true) addEventHandler( "onCounterStart", root, startEverything ) function stopText() --stop the timer, it's useless now if isTimer( counterTimer ) then killTimer(counterTimer) end --make the text not visible if isTextShowing then removeEventHandler( "onClientRender", root, drawCounterSHI ) isTextShowing = false end end addEventHandler( "onClientPlayerWasted", localPlayer, stopText ) function startText() if states.currentState ~= "Running" then return end --i guess that is the state that means the match is ongoing if isTimer( counterTimer ) then killTimer( counterTimer ) end --set the counter to 15s counter = 15 --start the timer again counterTimer = setTimer( function() counter = counter - 1 if counter < 1 then counter = 15 r,g,b = 0,255,0 end end, 1000, 0 ) --make the text visible if not isTextShowing then addEventHandler( "onClientRender", root, drawCounterSHI ) isTextShowing = true end end addEventHandler( "onClientPlayerSpawn", localPlayer, startText ) function raceStateChangeHandler( newState, oldState ) states.currentState = newState if states[newState] == true then startText() elseif states[newState] == false then stopText() end end addEventHandler( "onServerRaceStateChangingNotice", resourceRoot, raceStateChangeHandler ) --server function makeClientKnowMapChange( newState, oldState ) triggerClientEvent( root, "onServerRaceStateChangingNotice", resourceRoot, newState, oldState ) end addEventHandler( "onRaceStateChanging", root, makeClientKnowMapChange ) Link to comment
mores3 Posted January 15, 2017 Author Share Posted January 15, 2017 Thank You Everything works perfectly !!! You are the best MAN I close the topic 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