Jump to content

JuniorMelo

Members
  • Posts

    120
  • Joined

  • Last visited

Everything posted by JuniorMelo

  1. -- --------------------------------------------------------------------------- -- Script location --------------------------------------------------------------------------- function isServer() return triggerClientEvent ~= nil end function isClient() return triggerServerEvent ~= nil end function getScriptLocation() return isServer() and "Server" or "Client" end --------------------------------------------------------------------------- -- Math extentions --------------------------------------------------------------------------- function math.lerp(from,to,alpha) return from + (to-from) * alpha end function math.clamp(low,value,high) return math.max(low,math.min(value,high)) end function math.wrap(low,value,high) while value > high do value = value - (high-low) end while value < low do value = value + (high-low) end return value end function math.wrapdifference(low,value,other,high) return math.wrap(low,value-other,high)+other end -- curve is { {x1, y1}, {x2, y2}, {x3, y3} ... } function math.evalCurve( curve, input ) -- First value if input[1][1] then return curve[1][2] end -- Interp value for idx=2,#curve do if input[idx][1] then local x1 = curve[idx-1][1] local y1 = curve[idx-1][2] local x2 = curve[idx][1] local y2 = curve[idx][2] -- Find pos between input points local alpha = (input - x1)/(x2 - x1); -- Map to output points return math.lerp(y1,y2,alpha) end end -- Last value return curve[#curve][2] end --------------------------------------------------------------------------- --------------------------------------------------------------------------- -- Misc functions --------------------------------------------------------------------------- function getSecondCount() return getTickCount() * 0.001 end -- remove color coding from string function removeColorCoding ( name ) return not type(name)=='string' and string.gsub ( name, '#%x%x%x%x%x%x', '' ) or name end -- getPlayerName with color coding removed _getPlayerName = getPlayerName function getPlayerName ( player ) return removeColorCoding (_getPlayerName ( player )) end --------------------------------------------------------------------------- --------------------------------------------------------------------------- -- Camera functions --------------------------------------------------------------------------- function getCameraRot() local px, py, pz, lx, ly, lz = getCameraMatrix() local rotz = math.atan2 ( ( lx - px ), ( ly - py ) ) local rotx = math.atan2 ( lz - pz, getDistanceBetweenPoints2D ( lx, ly, px, py ) ) return math.deg(rotx), 180, -math.deg(rotz) end --------------------------------------------------------------------------- --------------------------------------------------------------------------- -- TimerManager --------------------------------------------------------------------------- TimerManager = {} TimerManager.list = {} -- Create a timer with tags function TimerManager.createTimerFor( ... ) -- Make a dictionary of tags for easy lookup local tagMap = {} for _,arg in ipairs({ ... }) do tagMap[tostring(arg)] = 1 end local timer = Timer:create(true) table.insert( TimerManager.list, { timer=timer, tagMap=tagMap } ) outputDebug( "TIMERS", getScriptLocation() .. " create - number of timers:" .. tostring(#TimerManager.list) ) return timer end -- Timer must have all the tags specified function TimerManager.hasTimerFor( ... ) local timers = TimerManager.getTimersByTags(...) return #timers > 0 end -- Timers must have all the tags specified function TimerManager.destroyTimersFor( ... ) local timers = TimerManager.getTimersByTags(...) for _,timer in ipairs(timers) do timer:destroy() end end -- Remove specific timer from the list function TimerManager.removeTimer( timer ) for _,item in ipairs(TimerManager.list) do if item.timer == timer then table.removevalue(TimerManager.list, item) outputDebug( "TIMERS", getScriptLocation() .. " remove - number of timers:" .. tostring(#TimerManager.list) ) end end end -- Get all timers which contains all matching tags function TimerManager.getTimersByTags( ... ) -- Get list of tags to find local findtags = {} for _,arg in ipairs({ ... }) do table.insert( findtags, tostring(arg) ) end -- Check each timer local timers = {} for i,item in ipairs(TimerManager.list) do local bFound = true for _,tag in ipairs(findtags) do if item.tagMap[tag] ~= 1 then bFound = false break end end if bFound then table.insert( timers, item.timer ) end end return timers end if isServer() then addEventHandler ( "onElementDestroy", root, function() TimerManager.destroyTimersFor( source ) end ) end if isClient() then addEventHandler ( "onClientElementDestroy", root, function() TimerManager.destroyTimersFor( source ) end ) end --------------------------------------------------------------------------- -- Timer - Wraps a standard timer --------------------------------------------------------------------------- Timer = {} Timer.__index = Timer Timer.instances = {} -- Create a Timer instance function Timer:create(autodestroy) local id = #Timer.instances + 1 Timer.instances[id] = setmetatable( { id = id, timer = nil, -- Actual timer autodestroy = autodestroy, }, self ) return Timer.instances[id] end -- Destroy a Timer instance function Timer:destroy() self:killTimer() TimerManager.removeTimer(self) Timer.instances[self.id] = nil self.id = 0 end -- Check if timer is valid function Timer:isActive() return self.timer ~= nil end -- killTimer function Timer:killTimer() if self.timer then killTimer( self.timer ) self.timer = nil end end -- setTimer function Timer:setTimer( theFunction, timeInterval, timesToExecute, ... ) self:killTimer() self.fn = theFunction self.count = timesToExecute self.dodestroy = false self.args = { ... } if timeInterval < 50 then timeInterval = 50 end self.timer = setTimer( function() self:handleFunctionCall() end, timeInterval, timesToExecute ) end function Timer:handleFunctionCall() -- Delete reference to timer if there are no more repeats if self.count > 0 then self.count = self.count - 1 if self.count == 0 then self.timer = nil self.dodestroy = self.autodestroy end end self.fn(unpack(self.args)) if self.dodestroy then self:destroy() end end ---------------------------------------------------------------------------
  2. line 83 return removeColorCoding (_getPlayerName ( player ))
  3. Always happens When the player dies (this bug) function getSecondCount() return getTickCount() * 0.001 end -- remove color coding from string function removeColorCoding ( name ) return not type(name)=='string' and string.gsub ( name, '#%x%x%x%x%x%x', '' ) or name end -- getPlayerName with color coding removed _getPlayerName = getPlayerName function getPlayerName ( player ) return removeColorCoding (_getPlayerName ( player )) end Can you help me
  4. this and the problem local x, y = guiGetScreenSize () fx = 30 fy = 251 not working
  5. Thanks helped me a lot But I have another problem, Also with the resolution ============Panel Test============ resolution (800 x 600 x 16) resolution (1280 x 720 x 32) function onClick () local x, y = guiGetScreenSize () tx = 30 ty = 251 edit_Login = guiCreateEdit(tx,ty,280, 35,"",false ) guiSetFont(edit_Login,"default-bold-small") edit_password = guiCreateEdit(tx,ty+80,280,35,"",false ) guiSetFont(edit_password,"default-bold-small") guiEditSetMaxLength ( edit_Login,25) guiEditSetMaxLength ( edit_password,25) guiEditSetMasked ( edit_password, true ) end addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()), onClick ) function Win() local x, y = guiGetScreenSize () sx = x sy = y + 400 tx = 20 ty = 200 dxDrawRectangle ( tx, 200, 300, 25, tocolor ( 0, 255, 0, 255 ) ) dxDrawRectangle ( tx, ty, 300, 350, tocolor ( 0, 0, 0, 155 ) ) dxDrawText ( "Nick", 20+10, sy*0.2+20, sx, sy, tocolor ( 255, 255, 255, 255 ), 1.5, "default-bold") dxDrawText ( "Password", 20+10, sy*0.2+100, sx, sy, tocolor ( 255, 255, 255, 255 ), 1.5, "default-bold") end addEventHandler ("onClientRender", getRootElement(), Win ) can help
  6. Hello I have a problem in this script pictures resolution (800 x 600 x 16) resolution (1280 x 720 x 32) button changes location function onClickNext () local x, y = guiGetScreenSize () vx = x + 600 vy = y - 610 Nexx = guiCreateButton (vx*0.1-138, vy*0.1, 130, 20, "Next", false ) addEventHandler("onClientGUIClick",Nexx,onLog) guiSetAlpha(Nexx, 0 ) end function Next() local x, y = guiGetScreenSize () tx = x + 600 ty = y - 610 dxDrawRectangle ( tx*0.1-138, ty*0.1, 130, 20, tocolor ( 0, 0, 0, 200 ) ) dxDrawColorText ("Next", tx*0.1-135, ty*0.1, tx, ty, tocolor(255,255,255,255), 1.3, "default-bold", "nil", "nil" ) end
  7. JuniorMelo

    Question

    it is guidxCreateWindow
  8. then sorry I am not very good with this kind of script
  9. thus try ! function Racestart (player) setElementData (player,"gamemode","[gamemodes]/[race]/race", true) end addEvent("start", true) addEventHandler( "start", getRootElement(), Racestart )
  10. Test object = createObject ( 980, 2497.1799316406, 2773.2600097656, 12.630000114441, 0, 0, 90.186767578125 ) markerx = createMarker ( 2495.7800292969,2772.9799804688,10, "cylinder", 2, 0, 0, 0, 255 ) function gateo(thePlayer) if getElementModel( thePlayer ) == 248 then moveObject (object, 2000, 2497.1799316406, 2773.2600097656, 18, 0, 0, 90.186767578125 ) else outputChatBox ( "sorry, you're not a USAS member, You can't enter in this base.", thePlayer, 255, 0, 0 ) end end addEventHandler( "onMarkerHit", markerx, gateo ) function gatec(thePlayer) if getElementModel( thePlayer ) == 248 then moveObject (object, 1000, 2497.1799316406, 2773.2600097656, 12.630000114441, 0, 0, 90.186767578125 ) end end addEventHandler( "onMarkerLeave", markerx, gatec )
  11. JuniorMelo

    Help script

    try this no tested addEventHandler( "onPlayerPickUpRacePickup", getRootElement(), function(kill, sort, model) if sort == "vehiclechange" then if model == 425 then setTimer(killPed, 60000, 1, getRootElement() ) outputChatBox( getPlayerName( source ).." #FFFFFFPegou Hunter", getRootElement(), 255, 255, 255, true ) end end end )
  12. no I'm trying to put to be able to type the command /give when is within the marker ( local marker = createMarker )
  13. Hello I have a problem in this script that I'm trying to put the command when the player is within the marker marker = createMarker ( 2786.16235, 1222.62122, 09.85634, "cylinder", 1.5, 255, 255, 255, 200 ) function weapon ( player ) giveWeapon ( player, 24 , 100 ) end addCommandHandler ( "give" , weapon ) addEventHandler ( "onMarkerHit", marker, weapon ) Sorry My english
  14. test addCommandHandler("water", function ( command ) if not isWorldSpecialPropertyEnabled( "hovercars" ) then setWorldSpecialPropertyEnabled( "hovercars", true ) outputChatBox("water car activated ! ", 124, 252, 0 ) else setWorldSpecialPropertyEnabled( "hovercars", false ) outputChatBox("water car disabled !", 124, 252, 0 ) end end )
  15. someArea = createRadarArea ( 2654.64087, 971.73938 , 75 , 100 ,0, 255, 0, 255 ) local r,g,b,a = getRadarAreaColor ( someArea ) car = createVehicle ( 411, 2662.76196, 981.67383, 6.73438, 0, 0, 0, "TEAM" ) setVehicleColor ( car, r,g,b,a )
  16. local r,g,b,a = getRadarAreaColor ( area )
  17. Hello I wanted to know and if possible will leave color of vehicle same color the RadarArea ??? someArea = createRadarArea ( 2654.64087, 971.73938 , 75 , 100 , 0 , 0 , 0 , 255 ) local flag = setRadarAreaColor ( someArea, 255, 85, 85, 170 ) car = createVehicle ( 411, 2662.76196, 981.67383, 6.73438, 0, 0, 0, "TEAM" ) setVehicleColor ( car, 255, 2, 0, 255 ) Sorry My English
  18. Can you help me with this problem (When I go to sell the vehicle it happens) (sorry my english)
×
×
  • Create New...