Scooby Posted December 13, 2011 Posted December 13, 2011 just store the players money from getPlayerMoney in a variable every 1 second with a timer, then use this variable in your function in onClientRender, that way, it will show however much the player has on his hud every frame without calling the function every frame. something like this: local root = getRootElement() local cash function updateCashVar() cash = getPlayerMoney() end function scriptStarted() setTimer(updateCashVar,1000,0) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), scriptStarted) function drawSpectators() local textX = x - spectatorSettings.xOffset local textY = spectatorSettings.yOffset dxDrawText("MIRANDO: "..tostring(#spectators), textX - 0.2, textY - 0.2, x, y, tocolor(0, 0, 0, 255), 0.4, "bankgothic") drawColor("#00FF00MIRANDO: #ffffff"..tonumber(#spectators), textX, textY, x, y, tocolor(83, 134, 139), 0.4, "bankgothic") dxDrawText("FPS: "..tostring(getElementData(getLocalPlayer(), "fps")), textX - 0.2, textY + 15 - 0.2, x, y, tocolor(0, 0, 0, 255), 0.4, "bankgothic") drawColor("#00FF00FPS: #ffffff"..tostring(getElementData(getLocalPlayer(), "fps")), textX, textY + 15, x, y, tocolor(15, 192, 252, 255), 0.4, "bankgothic") dxDrawText("$: "..tostring(cash), textX - 0.2, textY + 15 + 15 - 0.2, x, y, tocolor(0, 0, 0, 255), 0.4, "bankgothic") drawColor("#00FF00$: #ffffff"..tostring(cash), textX, textY + 15 + 15, x, y, tocolor(15, 192, 252, 255), 0.4, "bankgothic") end addEventHandler("onClientRender",root,drawSpectators) sorry but i dont have time to test it. [UVA]Scooby Founder Of UVA - Ultimate Vice Assassins http://www.uvaclan.com/
12p Posted December 13, 2011 Posted December 13, 2011 Nope, you are not. Remember: when LUA tags are used, every highlighted text is a function. You must click them triggerClientEvent
SnoopCat Posted December 14, 2011 Author Posted December 14, 2011 just store the players money from getPlayerMoney in a variable every 1 second with a timer, then use this variable in your function in onClientRender, that way, it will show however much the player has on his hud every frame without calling the function every frame.something like this: local root = getRootElement() local cash function updateCashVar() cash = getPlayerMoney() end function scriptStarted() setTimer(updateCashVar,1000,0) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), scriptStarted) function drawSpectators() local textX = x - spectatorSettings.xOffset local textY = spectatorSettings.yOffset dxDrawText("MIRANDO: "..tostring(#spectators), textX - 0.2, textY - 0.2, x, y, tocolor(0, 0, 0, 255), 0.4, "bankgothic") drawColor("#00FF00MIRANDO: #ffffff"..tonumber(#spectators), textX, textY, x, y, tocolor(83, 134, 139), 0.4, "bankgothic") dxDrawText("FPS: "..tostring(getElementData(getLocalPlayer(), "fps")), textX - 0.2, textY + 15 - 0.2, x, y, tocolor(0, 0, 0, 255), 0.4, "bankgothic") drawColor("#00FF00FPS: #ffffff"..tostring(getElementData(getLocalPlayer(), "fps")), textX, textY + 15, x, y, tocolor(15, 192, 252, 255), 0.4, "bankgothic") dxDrawText("$: "..tostring(cash), textX - 0.2, textY + 15 + 15 - 0.2, x, y, tocolor(0, 0, 0, 255), 0.4, "bankgothic") drawColor("#00FF00$: #ffffff"..tostring(cash), textX, textY + 15 + 15, x, y, tocolor(15, 192, 252, 255), 0.4, "bankgothic") end addEventHandler("onClientRender",root,drawSpectators) sorry but i dont have time to test it. i will gonna test it VISIT TSW RACING SERVER http://tswracing.net/
SnoopCat Posted December 14, 2011 Author Posted December 14, 2011 srry for double but that code isnt working i did this Client: local x, y = guiGetScreenSize () local localPlayer = getLocalPlayer() local spectatorSettings = { count = 7, -- how many player names to show, before showing "and x more" charLimit = 19, -- max limit of characters in player name xOffset = 115, -- how far to the left this should be yOffset = (y / 2)-200, -- how far down the screen this should be ~ currently it is almost half way down alwaysShow = true -- whether to show anything if there aren't any players spectating you } local spectators = {} addEvent('addSpectator', true) addEvent('removeSpectator', true) addEventHandler('onClientResourceStart', root, function() triggerServerEvent('addClient', localPlayer) end ) addEventHandler('addSpectator', root, function(spectator) table.insert(spectators, spectator) end ) addEventHandler('removeSpectator', root, function(spectator) for i, val in ipairs(spectators) do if (val == spectator) then table.remove(spectators, i) end end end ) function elementCheck (elem) if elem then if isElement (elem) then if (getElementType (elem) == 'player') then return true end end end return false end function drawColor(str, ax, ay, bx, by, color, scale, font, alignX, alignY) if alignX then if alignX == "center" then local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) ax = ax + (bx-ax)/2 - w/2 elseif alignX == "right" then local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) ax = bx - w end end if alignY then if alignY == "center" then local h = dxGetFontHeight(scale, font) ay = ay + (by-ay)/2 - h/2 elseif alignY == "bottom" then local h = dxGetFontHeight(scale, font) ay = by - h end end local pat = "(.-)#(%x%x%x%x%x%x)" local s, e, cap, col = str:find(pat, 1) local last = 1 while s do if cap == "" and col then color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end if s ~= 1 or cap ~= "" then local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) ax = ax + w color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end last = e + 1 s, e, cap, col = str:find(pat, last) end if last <= #str then cap = str:sub(last) local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) end end local root = getRootElement() local cash function updateCashVar() cash = getPlayerMoney() end function scriptStarted() setTimer(updateCashVar,1000,0) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), scriptStarted) function drawSpectators() local textX = x - spectatorSettings.xOffset local textY = spectatorSettings.yOffset dxDrawText("MIRANDO: "..tostring(#spectators), textX - 0.2, textY - 0.2, x, y, tocolor(0, 0, 0, 255), 0.4, "bankgothic") drawColor("#00FF00MIRANDO: #ffffff"..tonumber(#spectators), textX, textY, x, y, tocolor(83, 134, 139), 0.4, "bankgothic") dxDrawText("FPS: "..tostring(getElementData(getLocalPlayer(), "fps")), textX - 0.2, textY + 15 - 0.2, x, y, tocolor(0, 0, 0, 255), 0.4, "bankgothic") drawColor("#00FF00FPS: #ffffff"..tostring(getElementData(getLocalPlayer(), "fps")), textX, textY + 15, x, y, tocolor(15, 192, 252, 255), 0.4, "bankgothic") dxDrawText("$: "..tostring(cash), textX - 0.2, textY + 15 + 15 - 0.2, x, y, tocolor(0, 0, 0, 255), 0.4, "bankgothic") drawColor("#00FF00$: #ffffff"..tostring(cash), textX, textY + 15 + 15, x, y, tocolor(15, 192, 252, 255), 0.4, "bankgothic") end addEventHandler("onClientRender",root,drawSpectators) -- Set up variables and settings local x, y = guiGetScreenSize () local localPlayer = getLocalPlayer() local dxDraw = {} local dxDrawOutline = {} local spectatorSettings = { xOffset = (x/6.3), yOffset = y - (y/1.4)} local showSpectators = true function changeSpectatorsEnabled() showSpectators = not showSpectators end local spectators = {} addEvent('addSpectator', true) addEvent('removeSpectator', true) addEventHandler('onClientResourceStart', root, function() triggerServerEvent ('addClient', localPlayer) end) addEventHandler('addSpectator', root, function(spectator) table.insert(spectators, spectator) end) addEventHandler('removeSpectator', root, function(spectator) for i, val in ipairs(spectators) do if (val == spectator) then table.remove(spectators, i) end end end) function elementCheck (elem) if elem then if isElement (elem) then if (getElementType (elem) == 'player') then return true end end end return false end -------------------------------------------------------- function drawSpectators() if showSpectators == true then local textX = x - spectatorSettings.xOffset local textY = spectatorSettings.yOffset scale = getScale(x) dxDrawText("",textX - 1, textY + 1, x, y, tocolor(255,0,0), scale, 'bankgothic') dxDrawText("",textX, textY, x, y, tocolor(255,0,0), scale, 'bankgothic') if not (isPlayerDead(localPlayer)) then if (#spectators > 0) then for i, v in ipairs(spectators) do if elementCheck (v) then local name = getPlayerName(v) if (i) then dxDrawOutline[i] = dxDrawText (" "..string.gsub(name,"#%x%x%x%x%x%x",""), textX - 1, (textY + scale) + (dxGetFontHeight(scale,'bankgothic') * i) + 1.5, x, y, tocolor(0,0,0, 255), scale, 'bankgothic') dxDraw[i] = dxDrawColorText (" "..name, textX, (textY + scale) + (dxGetFontHeight(scale,'bankgothic') * i), x, y, tocolor(255, 255, 255, 255), scale, 'bankgothic') end else table.remove (spectators, k) end end else dxDrawOutline[1] = dxDrawText ("", textX - 1, (textY + scale) + dxGetFontHeight(scale,'bankgothic') + 1.5, x, y, tocolor(0,0,0, 255), scale, 'bankgothic') dxDraw[1] = dxDrawColorText ("", textX, (textY + scale) + dxGetFontHeight(scale,'bankgothic'), x, y, tocolor(255, 255, 255, 255), scale, 'bankgothic') end end end end addEventHandler('onClientRender', root, drawSpectators) function dxDrawColorText(str, ax, ay, bx, by, color, scale, font) local pat = "(.-)#(%x%x%x%x%x%x)" local s, e, cap, col = str:find(pat, 1) local last = 1 while s do if cap == "" and col then color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end if s ~= 1 or cap ~= "" then local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) ax = ax + w color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end last = e + 1 s, e, cap, col = str:find(pat, last) end if last <= #str then cap = str:sub(last) local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) end end function getScale(w) local scale = (w*0.5)/1000 return scale end VISIT TSW RACING SERVER http://tswracing.net/
SnoopCat Posted December 15, 2011 Author Posted December 15, 2011 no help? VISIT TSW RACING SERVER http://tswracing.net/
HunT Posted December 15, 2011 Posted December 15, 2011 But getPlayerMoney is for "default" GTA cash. I dont know the race starter but sure u need getElementData or getAccountData. Made the script server side for get money with event onPlayerSpawn and trig client for dx or GUI element. @Huntone_
SnoopCat Posted December 16, 2011 Author Posted December 16, 2011 But getPlayerMoney is for "default" GTA cash. I dont know the race starter but sure u need getElementData or getAccountData.Made the script server side for get money with event onPlayerSpawn and trig client for dx or GUI element. my sistem uses normal cash sistem cuz when i add money from the panel it gets on the money panel... VISIT TSW RACING SERVER http://tswracing.net/
SnoopCat Posted December 17, 2011 Author Posted December 17, 2011 hello i have another problem. i need to move 2 objects when hitting a marker, this is what i did. gMe7 = getLocalPlayer() function waterino1() WTF = createMarker( 5942.1000976563,1276.4000244141,8.8000001907349, "corona", 1, 17, 255, 0, 0) asd1 = createObject (14548, 5942.7001953125 , 1316.6999511719 , 16.200000762939 , 7.2493896484375 , 359.24401855469 , 180.09539794922) WTF2 = createMarker( 5942.1000976563,1276.4000244141,8.8000001907349, "corona", 1, 17, 255, 0, 0) asd2 = createObject (14553, 5943.2001953125 , 11319 , 15.89999961853 , 7.2493896484375 , 359.24401855469 , 180.09539794922) end function MarkerHit ( hitPlayer, matchingDimension ) vehicle = getPedOccupiedVehicle ( hitPlayer ) if hitPlayer ~= gMe7 then return end if source == WTF then moveObject(asd1, 100000, 5906.5 , 3386.6000976563 , 16.200000762939) setTimer(asd1,20000) else if source == WTF2 then moveObject(asd2, 100000, 5906 , 3388.8999023438 , 15.89999961853) setTimer(asd2,20000) end end addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), waterino1 ) addEventHandler ( "onClientMarkerHit", getRootElement(), MarkerHit ) VISIT TSW RACING SERVER http://tswracing.net/
BinSlayer1 Posted December 17, 2011 Posted December 17, 2011 line 16 , use elseif instead of else if (because you only have 1 end for the whole if and if u want to make 2 ifs then u need 2 ends) lines 15, 19 are bugged because that is NOT the correct syntax of setTimer https://wiki.multitheftauto.com/wiki/SetTimer
SnoopCat Posted December 17, 2011 Author Posted December 17, 2011 nat working VISIT TSW RACING SERVER http://tswracing.net/
SnoopCat Posted December 17, 2011 Author Posted December 17, 2011 its not working whit your help VISIT TSW RACING SERVER http://tswracing.net/
Xeno Posted December 17, 2011 Posted December 17, 2011 what doesnt work? They dont move? setTimer(moveObject, 20000,1, asd2,100000, 5906.5 , 3386.6000976563 , 16.200000762939) Try that^
SnoopCat Posted December 18, 2011 Author Posted December 18, 2011 i already fixed , thx!!! VISIT TSW RACING SERVER http://tswracing.net/
SnoopCat Posted January 9, 2012 Author Posted January 9, 2012 new Problem: i was trying to create a hunter alert sistem that when someone reach the hunter it says on the screen for 5 secs "Hunter Reached" this is what i do but isnt working Server side: function someoneReachedHunter(number, sort, model) if sort == "vehiclechange" and model == 425 then dxDrawText("HUNTER ENCONTRADO!",226.0,637.0,625.0,671.0,"bankgothic","left","top",false,false,false) setTimer ( someoneReachedHunter, 5000, 1 ) end end addEvent("onPlayerPickUpRacePickup",true) addEventHandler("onPlayerPickUpRacePickup",getRootElement(),someoneReachedHunter) end meta.xml "Hunter_Alert" author="SnoopCat" type="script" version="1.1" /> VISIT TSW RACING SERVER http://tswracing.net/
Cadu12 Posted January 9, 2012 Posted January 9, 2012 https://wiki.multitheftauto.com/wiki/DxDrawText Client-only function Ingame nick: Cadu12
FatalTerror Posted January 9, 2012 Posted January 9, 2012 new Problem:i was trying to create a hunter alert sistem that when someone reach the hunter it says on the screen for 5 secs "Hunter Reached" this is what i do but isnt working Server side: function someoneReachedHunter(number, sort, model) if sort == "vehiclechange" and model == 425 then dxDrawText("HUNTER ENCONTRADO!",226.0,637.0,625.0,671.0,"bankgothic","left","top",false,false,false) setTimer ( someoneReachedHunter, 5000, 1 ) end end addEvent("onPlayerPickUpRacePickup",true) addEventHandler("onPlayerPickUpRacePickup",getRootElement(),someoneReachedHunter) end meta.xml "Hunter_Alert" author="SnoopCat" type="script" version="1.1" /> WTF ? Why it's on server side?! dxDrawTexte Client-only function Edit: Hm dude... if in the map have multiple hunter pickup I think it will create multiple dxDrawText Paid developer. Twitter: @willia_am - http://www.williamdasilva.fr
SnoopCat Posted January 9, 2012 Author Posted January 9, 2012 can someone help me to fix it? VISIT TSW RACING SERVER http://tswracing.net/
FatalTerror Posted January 9, 2012 Posted January 9, 2012 (edited) Like this ? (not tested) Client-side: addEvent("onPlayerPickUpRacePickup",true) addEventHandler("onPlayerPickUpRacePickup",getRootElement(), function(number, sort, model) if sort == "vehiclechange" and model == 425 then local thedx = dxDrawText("HUNTER ENCONTRADO!",226.0,637.0,625.0,671.0,"bankgothic","left","top",false,false,false) setTimer(closeTheHunterAlert, 5000, 1) addEventHandler("onClientRender", getRootElement(), showTheHunterAlert) end end) function showTheHunterAlert() dxDrawText("HUNTER ENCONTRADO !",226.0,637.0,625.0,671.0,"bankgothic","left","top",false,false,false) end function closeTheHunterAlert() removeEventHandler("onClientRender", getRootElement(), showTheHunterAlert) end Edited January 9, 2012 by Guest Paid developer. Twitter: @willia_am - http://www.williamdasilva.fr
SnoopCat Posted January 9, 2012 Author Posted January 9, 2012 soo like this? Server side: function someoneReachedHunter(number, sort, model) if sort == "vehiclechange" and model == 425 then dxDrawText("HUNTER ENCONTRADO!",226.0,637.0,625.0,671.0,"bankgothic","left","top",false,false,false) triggerClientEvent ( thePlayer, "text", getRootElement() ) setTimer ( someoneReachedHunter, 5000, 1 ) end end addEvent("onPlayerPickUpRacePickup",true) addEventHandler("onPlayerPickUpRacePickup",getRootElement(),someoneReachedHunter) end Client function text dxDrawText("HUNTER ENCONTRADO!",226.0,637.0,625.0,671.0,"bankgothic","left","top",false,false,false) meta.xml "Hunter_Alert" author="SnoopCat" type="script" version="1.1" /> is thta correct? VISIT TSW RACING SERVER http://tswracing.net/
Kenix Posted January 9, 2012 Posted January 9, 2012 no,dxDrawText is client side function. https://wiki.multitheftauto.com/wiki/Scr ... troduction http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
SnoopCat Posted January 9, 2012 Author Posted January 9, 2012 Like this ? (not tested)Client-side: addEvent("onPlayerPickUpRacePickup",true) addEventHandler("onPlayerPickUpRacePickup",getRootElement(), function(number, sort, model) if sort == "vehiclechange" and model == 425 then local thedx = dxDrawText("HUNTER ENCONTRADO!",226.0,637.0,625.0,671.0,"bankgothic","left","top",false,false,false) setTimer(closeTheHunterAlert, 5000, 1) addEventHandler("onClientRender", getRootElement(), showTheHunterAlert) end end) function showTheHunterAlert() dxDrawText("HUNTER ENCONTRADO !",226.0,637.0,625.0,671.0,"bankgothic","left","top",false,false,false) end function closeTheHunterAlert() removeEventHandler("onClientRender", getRootElement(), showTheHunterAlert) end not working VISIT TSW RACING SERVER http://tswracing.net/
Castillo Posted January 9, 2012 Posted January 9, 2012 -- client side: function drawText() dxDrawText("HUNTER ENCONTRADO!",226.0,637.0,625.0,671.0,tocolor (255,0,0,255),1.3,"bankgothic","left","top",false) end addEvent("onHunterReached",true) addEventHandler("onHunterReached",root, function () addEventHandler("onClientRender",root,drawText) setTimer(function () removeEventHandler("onClientRender",root,drawText) end, 5000, 1) end) -- server side: addEvent("onPlayerPickUpRacePickup",true) addEventHandler("onPlayerPickUpRacePickup",getRootElement(), function(number, sort, model) if (sort == "vehiclechange" and model == 425) then triggerClientEvent("onHunterReached",getRootElement()) end end) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
SnoopCat Posted January 9, 2012 Author Posted January 9, 2012 solid ur script isnt working , here its the img of the debug VISIT TSW RACING SERVER http://tswracing.net/
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