jomarisk8er Posted May 27, 2012 Share Posted May 27, 2012 ---server--- function start(thePlayer) for i, vehicle in ipairs(getElementsByType("vehicle")) do setElementFrozen(vehicle, true) setElementFrozen(thePlayer,true) triggerClientEvent("startcountdown",getRootElement()) setTimer(setElementFrozen,10000,1,vehicle,false) setTimer(setElementFrozen,10000,1,thePlayer,false) end end addCommandHandler("countdown",start) ---client--- root = getRootElement() function Countdown (root) guiSetVisible ( imagecount, false ) imagecount = guiCreateStaticImage(305,119,110,190,"images/10.png",false) setTimer ( Countdown9, 1000, 1 ) outputChatBox ( "countdown started", root, 255, 255, 255, true ) end function Countdown9 (root) guiSetVisible ( imagecount, false ) imagecount = guiCreateStaticImage(305,119,110,190,"images/9.png",false) setTimer ( Countdown8, 1000, 1 ) end function Countdown8 (root) guiSetVisible ( imagecount, false ) imagecount = guiCreateStaticImage(305,119,110,190,"images/8.png",false) setTimer ( Countdown7, 1000, 1 ) end function Countdown7 (root) guiSetVisible ( imagecount, false ) imagecount = guiCreateStaticImage(305,119,110,190,"images/7.png",false) setTimer ( Countdown6, 1000, 1 ) end function Countdown6 (root) guiSetVisible ( imagecount, false ) imagecount = guiCreateStaticImage(305,119,110,190,"images/6.png",false) setTimer ( Countdown5, 1000, 1 ) end function Countdown5 (root) guiSetVisible ( imagecount, false ) imagecount = guiCreateStaticImage(305,119,110,190,"images/5.png",false) setTimer ( Countdown4, 1000, 1 ) end function Countdown4 (root) guiSetVisible ( imagecount, false ) imagecount = guiCreateStaticImage(305,119,110,190,"images/4.png",false) setTimer ( Countdown3, 1000, 1 ) end function Countdown3 (root ) guiSetVisible ( imagecount, false ) imagecount = guiCreateStaticImage(305,119,110,190,"images/3.png",false) setTimer ( Countdown2, 1000, 1 ) end function Countdown2 (root) guiSetVisible ( imagecount, false ) imagecount = guiCreateStaticImage(305,119,110,190,"images/2.png",false) setTimer ( Countdown1, 1000, 1 ) end function Countdown1 (root) guiSetVisible ( imagecount, false ) imagecount = guiCreateStaticImage(305,119,110,190,"images/1.png",false) setTimer ( Countdown0, 1000, 1 ) end function Countdown0 (root) guiSetVisible ( imagecount, false ) imagecount = guiCreateStaticImage(305,119,320,81,"images/go.png",false) setTimer ( CountdownEnd, 3000, 1 ) end function CountdownEnd (root) guiSetVisible ( imagecount, false ) end addEvent("startcountdown",true) addEventHandler("startcountdown",getRootElement(), Countdown) how to freeze vehicle that only hit the marker? cause its freezing all the players in the server.. cause i want to make a race script, race participants should hit the marker to participate the race.. pls give me some tips.. Link to comment
Alpha Posted May 27, 2012 Share Posted May 27, 2012 ---server--- function start(thePlayer) for i, vehicle in ipairs(getElementsByType("vehicle")) do setElementFrozen(vehicle, true) setElementFrozen(thePlayer,true) triggerClientEvent("startcountdown",getRootElement()) setTimer(setElementFrozen,10000,1,vehicle,false) setTimer(setElementFrozen,10000,1,thePlayer,false) end end addCommandHandler("countdown",start) In that code, you loop through all vehicles, and you freeze them all. Post your code where you handled the event onMarkerHit. Link to comment
jomarisk8er Posted May 27, 2012 Author Share Posted May 27, 2012 racemarker = createMarker(192,182,13,"cylinder",20,0,255,0,100) function start(hitElement) if (source == racemarker) then for i,vehicle in ipairs(getElementByType("vehicle")) do setElementFrozen(vehicle,true) triggerClientEvent("startcountdown",hitElement) setTimer(setElementFrozen,10000,1,vehicle,false) end end addEventHandler("onMarkerHit",racemarker,start) is that right? Link to comment
Alpha Posted May 27, 2012 Share Posted May 27, 2012 racemarker = createMarker(192,182,13,"cylinder",20,0,255,0,100) function start(hitElement) if not isPedInVehicle(hitElement) then return end local vehicle = getPedOccupiedVehicle(hitElement) setElementFrozen(vehicle,true) triggerClientEvent(hitElement,"startcountdown",hitElement) setTimer(setElementFrozen,10000,1,vehicle,false) end addEventHandler("onMarkerHit",racemarker,start) Link to comment
jomarisk8er Posted May 27, 2012 Author Share Posted May 27, 2012 oh its working, but how can i have a command for to start?, cause i want to set Timer, or Command to start the race.. how? Link to comment
Jaysds1 Posted May 27, 2012 Share Posted May 27, 2012 you could use addCommandHandler("COMMAND",FUNCTION) Link to comment
jomarisk8er Posted May 27, 2012 Author Share Posted May 27, 2012 racemarker = createMarker(-2663.51,610,13.3,"cylinder",20,0,255,0,100) function start(hitElement) if not isPedInVehicle(hitElement) then return end if (source == racemarker) then local vehicle = getPedOccupiedVehicle(hitElement) setElementFrozen(vehicle,true) triggerClientEvent(hitElement,"startcountdown",hitElement) setTimer(setElementFrozen,10000,1,vehicle,false) end end addCommandHandler("cd",start) like this? its not working. Link to comment
Jaysds1 Posted May 27, 2012 Share Posted May 27, 2012 Sorry, try this: racemarker = createMarker(192,182,13,"cylinder",20,0,255,0,100) function start(hitElement,cmd) if(cmd)then if not isPedInVehicle(hitElement) then return end local vehicle = getPedOccupiedVehicle(hitElement) setElementFrozen(vehicle,true) triggerClientEvent(hitElement,"startcountdown",hitElement) setTimer(setElementFrozen,10000,1,vehicle,false) end end addEventHandler("onMarkerHit",racemarker,start) addCommandHandler("cd",start) Link to comment
jomarisk8er Posted May 27, 2012 Author Share Posted May 27, 2012 what should i change, i want to add command or timer for the race.. how? like if you type /racetime it will output how many time is remaining? lol sorry for too much question .. Link to comment
Jaysds1 Posted May 27, 2012 Share Posted May 27, 2012 Sorry, but I'm kinda confused about the other posts above, Can you post your full script for Client-side and Server-side please Link to comment
jomarisk8er Posted May 27, 2012 Author Share Posted May 27, 2012 ---client----- root = getRootElement() function Countdown (root) guiSetVisible ( imagecount, false ) imagecount = guiCreateStaticImage(305,119,110,190,"images/10.png",false) setTimer ( Countdown9, 1000, 1 ) outputChatBox ( "countdown started", root, 255, 255, 255, true ) end function Countdown9 (root) guiSetVisible ( imagecount, false ) imagecount = guiCreateStaticImage(305,119,110,190,"images/9.png",false) setTimer ( Countdown8, 1000, 1 ) end function Countdown8 (root) guiSetVisible ( imagecount, false ) imagecount = guiCreateStaticImage(305,119,110,190,"images/8.png",false) setTimer ( Countdown7, 1000, 1 ) end function Countdown7 (root) guiSetVisible ( imagecount, false ) imagecount = guiCreateStaticImage(305,119,110,190,"images/7.png",false) setTimer ( Countdown6, 1000, 1 ) end function Countdown6 (root) guiSetVisible ( imagecount, false ) imagecount = guiCreateStaticImage(305,119,110,190,"images/6.png",false) setTimer ( Countdown5, 1000, 1 ) end function Countdown5 (root) guiSetVisible ( imagecount, false ) imagecount = guiCreateStaticImage(305,119,110,190,"images/5.png",false) setTimer ( Countdown4, 1000, 1 ) end function Countdown4 (root) guiSetVisible ( imagecount, false ) imagecount = guiCreateStaticImage(305,119,110,190,"images/4.png",false) setTimer ( Countdown3, 1000, 1 ) end function Countdown3 (root ) guiSetVisible ( imagecount, false ) imagecount = guiCreateStaticImage(305,119,110,190,"images/3.png",false) setTimer ( Countdown2, 1000, 1 ) end function Countdown2 (root) guiSetVisible ( imagecount, false ) imagecount = guiCreateStaticImage(305,119,110,190,"images/2.png",false) setTimer ( Countdown1, 1000, 1 ) end function Countdown1 (root) guiSetVisible ( imagecount, false ) imagecount = guiCreateStaticImage(305,119,110,190,"images/1.png",false) setTimer ( Countdown0, 1000, 1 ) end function Countdown0 (root) guiSetVisible ( imagecount, false ) imagecount = guiCreateStaticImage(305,119,320,81,"images/go.png",false) setTimer ( CountdownEnd, 3000, 1 ) end function CountdownEnd (root) guiSetVisible ( imagecount, false ) end addEvent("startcountdown",true) addEventHandler("startcountdown",getRootElement(), Countdown) ----server---- racemarker = createMarker(-2663.51,610,13.3,"cylinder",20,0,255,0,100) function start(hitElement) if not isPedInVehicle(hitElement) then return end if (source == racemarker) then local vehicle = getPedOccupiedVehicle(hitElement) setElementFrozen(vehicle,true) triggerClientEvent(hitElement,"startcountdown",hitElement) setTimer(setElementFrozen,10000,1,vehicle,false) end end addCommandHandler("cd",start) i want to freeze all in the marker when timer starts or do a command Link to comment
Jaysds1 Posted May 27, 2012 Share Posted May 27, 2012 So, you want when the player goes in the marker, freeze them? or when the timer start move them inside the marker? Link to comment
jomarisk8er Posted May 27, 2012 Author Share Posted May 27, 2012 they need to go in the marker so they can participate the racing, all on the markers will freeze and start countdown when the timer starts = /racetime like that Link to comment
Jaysds1 Posted May 27, 2012 Share Posted May 27, 2012 try this: Server: local racemarker = createMarker(-2663.51,610,13.3,"cylinder",20,0,255,0,100) local playersReady = 0 local allPlayes = 0 function start(hitElement) for i,v in ipairs(getElementsByType("player"))do allPlayes = allPlayes + 1 end playersReady = playersReady + 1 if(playersReady == allPlayers)then triggerClientEvent("startcountdown",root) end if not isPedInVehicle(hitElement) then return end local vehicle = getPedOccupiedVehicle(hitElement) setElementFrozen(vehicle,true) setTimer(setElementFrozen,10000,1,vehicle,false) end addEventHandler("onMarkerHit",racemarker,start) Link to comment
jomarisk8er Posted May 27, 2012 Author Share Posted May 27, 2012 how to start racing? Link to comment
Jaysds1 Posted May 27, 2012 Share Posted May 27, 2012 Go into the marker then it checks how many people are on, if there's only one person on then it should automatically start... BTW, are you using the Race Gamemode? Link to comment
jomarisk8er Posted May 27, 2012 Author Share Posted May 27, 2012 how dude, how to start Link to comment
Jaysds1 Posted May 27, 2012 Share Posted May 27, 2012 oh, you want to start a race when the countdown is finish, if you want to use the race gamemode then try this, Server: local racemarker = createMarker(-2663.51,610,13.3,"cylinder",20,0,255,0,100) local playersReady = 0 local allPlayes = 0 function start(hitElement) for i,v in ipairs(getElementsByType("player"))do allPlayes = allPlayes + 1 end playersReady = playersReady + 1 if(playersReady == allPlayers)then triggerClientEvent("startcountdown",root) startResource(getResourceFromName("race")) end if not isPedInVehicle(hitElement) then return end local vehicle = getPedOccupiedVehicle(hitElement) setElementFrozen(vehicle,true) setTimer(setElementFrozen,10000,1,vehicle,false) end addEventHandler("onMarkerHit",racemarker,start) Link to comment
jomarisk8er Posted May 27, 2012 Author Share Posted May 27, 2012 im using RP server, normal, im not doing any modes. i want to trigger it if the timer(not countdown) start, like, bankrobbery, theres a timer to rob right, Link to comment
Jaysds1 Posted May 27, 2012 Share Posted May 27, 2012 ya, but your going to make your own starting race script then... and trust me, that isn't easy... Link to comment
jomarisk8er Posted May 27, 2012 Author Share Posted May 27, 2012 oh thats why im asking.. i cant pass this lol Link to comment
Jaysds1 Posted May 27, 2012 Share Posted May 27, 2012 lol, well, you could put everyone in a table (scripting side) then do your countdown, after that, you could start a map for those players and set the markers visible to the players in the table, and after the players reach the last marker, you could make an event called onRaceFinish... it'll take a long time to finish but it's possible 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