RaceUnit Posted February 19, 2013 Share Posted February 19, 2013 Hello, I have an race server, it shows in the corner: the map, nextmap and spectators, but if i set a nextmap it will stay on "Random". This is my code: -----------------Spectators local player = getLocalPlayer() local root = getRootElement () local Spectators = {} setElementData ( player, "Spectator", "" ) local scrX, scrY = guiGetScreenSize() repair=true ------------------ function start () setTimer ( checkTarget, 1000, 0 ) end addEventHandler ( "onClientResourceStart", getResourceRootElement(), start ) ------------------ function checkTarget ( ) local target = getCameraTarget () local car = getPedOccupiedVehicle ( player ) if not ( car ) then car = "noCar" end if ( target ) then setElementData ( player, "Spectator", target ) else setElementData ( player, "Spectator", "" ) end Spectators = {} for i,v in ipairs( getElementsByType ( "player" ) ) do if ( v ~= player ) then local vTarget = getElementData ( v, "Spectator" ) if ( vTarget == car ) then table.insert(Spectators,v) end end end end ------------------ g_Root = getRootElement() g_ResRoot = getResourceRootElement(getThisResource()) g_Me = getLocalPlayer() g_ArmedVehicleIDs = table.create({ 425, 447, 520, 430, 464, 432 }, true) g_WaterCraftIDs = table.create({ 539, 460, 417, 447, 472, 473, 493, 595, 484, 430, 453, 452, 446, 454 }, true) g_ModelForPickupType = { nitro = 2221, repair = 2222, vehiclechange = 2223 } g_HunterID = 425 g_NextMap = "Random" g_Checkpoints = {} g_Pickups = {} g_VisiblePickups = {} g_Objects = {} function setNextMap ( mapname ) g_NextMap = mapname end addEvent ( "setNextMap", true ) addEventHandler ( "setNextMap", getRootElement(), setNextMap ) function math.round(number, decimals, method) decimals = decimals or 0 local factor = 10 ^ decimals if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor else return tonumber(("%."..decimals.."f"):format(number)) end end function setNextNil ( dis ) g_NextMap = "Random" end addEvent ( "setNextNil", true ) addEventHandler ( "setNextNil", getRootElement(), setNextNil ) function hudSet () local screenWidth, screenHeight = guiGetScreenSize() dxDrawColorText ('Next: ' .. g_NextMap, 2+1, screenHeight - dxGetFontHeight(1, 'bankgothic')/2+1, 100+1, 100+1, tocolor ( 0, 0, 0, 255 ), 0.6, 'bankgothic', 0.6, 'left') dxDrawColorText ('#FF9900Next: #FFFFFF' .. g_NextMap, 2, screenHeight - dxGetFontHeight(1, 'bankgothic')/2, 100, 100, tocolor ( 255, 255, 255, 255 ), 0.6, 'bankgothic', 0.6, 'left') if (g_MapInfo) then dxDrawColorText ('Map: ' .. g_MapInfo.name, 2+1, screenHeight - dxGetFontHeight(2, 'bankgothic')/2+1, 100+1, 100+1, tocolor ( 0, 0, 0, 255 ), 0.6, 'bankgothic', 0.6, 'left') dxDrawColorText ('#FF9900Map: #FFFFFF' .. g_MapInfo.name, 2, screenHeight - dxGetFontHeight(2, 'bankgothic')/2, 100, 100, tocolor ( 255, 255, 255, 255 ), 0.6, 'bankgothic', 0.6, 'left') else dxDrawColorText ('Map: N/A', 2+1, screenHeight - dxGetFontHeight(2, 'bankgothic')/2.1, 100, 100, tocolor ( 0, 0, 0, 255 ), 0.6, 'bankgothic', 0.6, 'left') dxDrawColorText ('#FF9900Map: #FFFFFFRandom', 2, screenHeight - dxGetFontHeight(2, 'bankgothic')/2+1, 100+1, 100+1, tocolor ( 255, 255, 255, 255 ), 0.6, 'bankgothic', 0.6, 'left') end dxDrawColorText ('Spectators: ' .. #Spectators, 2+1, screenHeight - dxGetFontHeight(3, 'bankgothic')/2+1, 100+1, 100+1, tocolor ( 0, 0, 0, 255 ), 0.6, 'bankgothic', 0.6, 'left') dxDrawColorText ('#FF9900Spectators: #FFFFFF' .. #Spectators, 2, screenHeight - dxGetFontHeight(3, 'bankgothic')/2, 100, 100, tocolor ( 255, 255, 255, 255 ), 0.6, 'bankgothic', 0.6, 'left') end Con someone help my? Regards, RaceUnit. Link to comment
Fury Posted February 19, 2013 Share Posted February 19, 2013 function setNextMap ( mapname ) g_NextMap = mapname end addEvent ( "setNextMap", true ) addEventHandler ( "setNextMap", getRootElement(), setNextMap ) post server-side code which trigger "setNextMap" event. client-side is looking normal. Link to comment
RaceUnit Posted February 20, 2013 Author Share Posted February 20, 2013 I doesn't have any trigger, can you help my with that? Link to comment
Castillo Posted February 20, 2013 Share Posted February 20, 2013 So, you made a client side event and don't have a server side script to trigger it, that's weird. 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