Jump to content

Castillo

Retired Staff
  • Posts

    21,935
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Castillo

  1. No se, talvez me entendio mal y cree que necesita usar timers para que ande mejor .
  2. Indeed, I never seen a bot that could do that too, so it's useless. P.S: You just copy pasted FatalTerror's script.
  3. Mira te digo, una vez mi servidor (SAUR) estaba usando el 50% de la CPU, y eso era porque alguien con poca experiencia en Lua habia creando un script con 4 temporizadores de 50 millisegundos. Busca un recurso llamado "performancebrowser" y fijate aver si hay algun recurso que use mucha CPU, ram.
  4. Castillo

    SQL Lite?

    https://wiki.multitheftauto.com/wiki/Exe ... reateTable SQLITE it's similar to MySQL, but doesn't require a SQL server like MySQL does.
  5. Yes I know, you must fix that by your own.
  6. local Carlbara = createMarker( 117.30000305176, 1885, 17, 'cylinder', 2.5, 255, 255, 255, 150 ) local Carlde5el = createMarker( 86.800003051758, 1771.3000488281, -29.39999961853, 'cylinder', 2.5, 255, 255, 255, 150 ) function Entrer( hitPlayer, matchingDimension ) if (getElementType(hitPlayer) == "vehicle") then local hitPlayer = getVehicleController(hitPlayer) local team = getPlayerTeam(hitPlayer) if (not team) then return end local vehicle = getPedOccupiedVehicle(hitPlayer) if (getTeamName(team) == "Army") then setElementVelocity(vehicle, 0, 0, 0) setElementPosition ( vehicle, 90, 1771.3000488281, -28.39999961853 ) else outputChatBox ( "You cannot enter. You need to be a Army.",hitPlayer ) end end end addEventHandler( "onMarkerHit", Carlbara, Entrer ) function Sortie( hitPlayer, matchingDimension ) if (getElementType(hitPlayer) == "vehicle") then local hitPlayer = getVehicleController(hitPlayer) local team = getPlayerTeam(hitPlayer) if (not team) then return end local vehicle = getPedOccupiedVehicle(hitPlayer) if (not team) then return end if (getTeamName(team) == "Army") then setElementVelocity(vehicle, 0, 0, 0) setElementPosition ( vehicle, 117.69999694824, 1893.4000244141, 18.39999961853 ) end end end addEventHandler( "onMarkerHit", Carlde5el, Sortie )
  7. Castillo

    Help

    Oh c'mon, you didn't even try to make it, you just copied it like I said.
  8. Great, I'll be there for sure !
  9. What exactly doesn't work? any errors shown in debugscript?
  10. Try this: local Carlbara = createMarker( 117.30000305176, 1885, 17, 'cylinder', 2.5, 255, 255, 255, 150 ) local Carlde5el = createMarker( 86.800003051758, 1771.3000488281, -29.39999961853, 'cylinder', 2.5, 255, 255, 255, 150 ) function Entrer( hitPlayer, matchingDimension ) if (getElementType(hitPlayer) ~= "vehicle") then return end local hitPlayer = getVehicleOccupant(hitPlayer) local team = getPlayerTeam(hitPlayer) if (not team) then return end if (getTeamName(team) == "Army") then setElementPosition ( hitPlayer, 90, 1771.3000488281, -28.39999961853 ) else outputChatBox ( "You cannot enter. You need to be a Army.",hitPlayer ) end end addEventHandler( "onMarkerHit", Carlbara, Entrer ) function Sortie( hitPlayer, matchingDimension ) if (getElementType(hitPlayer) ~= "vehicle") then return end local hitPlayer = getVehicleOccupant(hitPlayer) local team = getPlayerTeam(hitPlayer) if (not team) then return end if (getTeamName(team) == "Army") then setElementPosition ( hitPlayer, 117.69999694824, 1893.4000244141, 18.39999961853 ) end end addEventHandler( "onMarkerHit", Carlde5el, Sortie )
  11. Castillo

    Help

    @Al3grab: Are you f**** stu***?? I wanted him to make it, not to get the complete script, now he'll just copy and paste it on a Lua file and say "thanks".
  12. Castillo

    Help

    I won't give you the script himself, but the functions/events you can use. Functions: getPlayerTeam -- To get the player team. getTeamName -- To get the player team name. getPlayerAccount -- To get the player account. setAccountData -- To save the team name in his account. getAccountData -- To get the saved team name in his account. getTeamFromName -- To get a team by it's name. setPlayerTeam -- To set the player team. Events: [url=https://wiki.multitheftauto.com/wiki/OnPlayerQuit]https://wiki.multitheftauto.com/wiki/OnPlayerQuit[/url] [url=https://wiki.multitheftauto.com/wiki/OnPlayerLogin]https://wiki.multitheftauto.com/wiki/OnPlayerLogin[/url] Click on the links and start learning.
  13. addEventHandler("onResourceStart",resourceRoot, function () handler = mysql_connect("127.0.0.1", "****", "******", "n30x") if (handler) then outputDebugString("Successfully connected to the MySQL server.") else outputDebugString("Unable to connect to the MySQL server.",1) end end) function getMySQLConnection() return handler end
  14. Do this, create a main resource, example: "mysql", after that connect to MySQL on resource start and make a function like this: function getMySQLConnection() return handler end And in the meta.xml of this resource add this: function="getMySQLConnection" type="server" /> Then you can just use the handler like this: local handler = exports["mysql"]:getMySQLConnection()
  15. What do you mean? you want vehicles to be able to enter too? doesn't work already?
  16. The script seems to be fine. function resetPlayerScore (thePlayer) local pname = getPlayerName(thePlayer) setElementData(thePlayer,"Score",0) setElementData(thePlayer,"kills",0) setElementData(thePlayer,"deaths",0) setElementData(thePlayer,"dmg",0) setElementData(thePlayer,"Damage",0) setElementData(thePlayer,"level",0) setElementData(thePlayer,"exp",0) outputChatBox(tostring(pname) .." has resetted his score.", getRootElement(), 147, 112, 219, true ) end addCommandHandler("rest", resetPlayerScore)
  17. And you think we don't know that? c'mon, it's just a useless topic .
  18. Castillo

    Nametag

    dxDrawColorText is not a built-on MTA function. g_Root = getRootElement() g_ResRoot = getResourceRootElement(getThisResource()) g_Players = getElementsByType('player') g_Me = getLocalPlayer() nametag = {} local nametags = {} local g_screenX,g_screenY = guiGetScreenSize() local bHideNametags = false local NAMETAG_SCALE = 0.3 --Overall adjustment of the nametag, use this to resize but constrain proportions local NAMETAG_ALPHA_DISTANCE = 50 --Distance to start fading out local NAMETAG_DISTANCE = 120 --Distance until we're gone local NAMETAG_ALPHA = 120 --The overall alpha level of the nametag --The following arent actual pixel measurements, they're just proportional constraints local NAMETAG_TEXT_BAR_SPACE = 2 local NAMETAG_WIDTH = 50 local NAMETAG_HEIGHT = 5 local NAMETAG_TEXTSIZE = 0.3 local NAMETAG_OUTLINE_THICKNESS = 1.2 -- local NAMETAG_ALPHA_DIFF = NAMETAG_DISTANCE - NAMETAG_ALPHA_DISTANCE NAMETAG_SCALE = 1/NAMETAG_SCALE * 800 / g_screenY -- Ensure the name tag doesn't get too big local maxScaleCurve = { {0, 0}, {3, 3}, {13, 5} } -- Ensure the text doesn't get too small/unreadable local textScaleCurve = { {0, 0.8}, {0.8, 1.2}, {99, 99} } -- Make the text a bit brighter and fade more gradually local textAlphaCurve = { {0, 0}, {25, 100}, {120, 190}, {255, 190} } function nametag.create ( player ) nametags[player] = true end function nametag.destroy ( player ) nametags[player] = nil end addEventHandler ( "onClientRender", g_Root, function() -- Hideous quick fix -- for i,player in ipairs(g_Players) do if isElement(player) then if player ~= g_Me then setPlayerNametagShowing ( player, false ) if not nametags[player] then nametag.create ( player ) end end end end if bHideNametags then return end local x,y,z = getCameraMatrix() for player in pairs(nametags) do while true do if not isElement(player) then break end if getElementDimension(player) ~= getElementDimension(g_Me) then break end local px,py,pz = getElementPosition ( player ) if processLineOfSight(x, y, z, px, py, pz, true, false, false, true, false, true) then break end local pdistance = getDistanceBetweenPoints3D ( x,y,z,px,py,pz ) if pdistance <= NAMETAG_DISTANCE then --Get screenposition local sx,sy = getScreenFromWorldPosition ( px, py, pz+0.95, 0.06 ) if not sx or not sy then break end --Calculate our components local scale = 1/(NAMETAG_SCALE * (pdistance / NAMETAG_DISTANCE)) local alpha = ((pdistance - NAMETAG_ALPHA_DISTANCE) / NAMETAG_ALPHA_DIFF) alpha = (alpha < 0) and NAMETAG_ALPHA or NAMETAG_ALPHA-(alpha*NAMETAG_ALPHA) scale = math.evalCurve(maxScaleCurve,scale) local textscale = math.evalCurve(textScaleCurve,scale) local textalpha = math.evalCurve(textAlphaCurve,alpha) local outlineThickness = NAMETAG_OUTLINE_THICKNESS*(scale) --Draw our text local r,g,b = getPlayerNametagColor(player) local offset = (scale) * NAMETAG_TEXT_BAR_SPACE/2 dxDrawColorText ( getPlayerName(player), sx, sy - offset, sx, sy - offset, tocolor(0,0,0,255), textscale*NAMETAG_TEXTSIZE, "pricedown", "center", "bottom", false, false, false ) dxDrawColorText ( getPlayerName(player), sx, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE, "pricedown", "center", "bottom", false, false, false ) local drawX = sx - NAMETAG_WIDTH*scale/2 drawY = sy + offset local width,height = NAMETAG_WIDTH*scale, NAMETAG_HEIGHT*scale dxDrawRectangle ( drawX, drawY, width, height, tocolor(0,0,0,alpha) ) --Next the inner background local health local p local r,g health = getElementHealth ( player ) health = math.max(health, 0)/100 p = -510*(health^2) r,g = math.max(math.min(p + 255*health + 255, 255), 0), math.max(math.min(p + 765*health, 255), 0) if health > 1.0 then health = 1.0 end dxDrawRectangle ( drawX + outlineThickness, drawY + outlineThickness, width - outlineThickness*2, height - outlineThickness*2, tocolor(r,g,0,0.4*alpha) ) --Finally, the actual health dxDrawRectangle ( drawX + outlineThickness, drawY + outlineThickness, health*(width - outlineThickness*2), height - outlineThickness*2, tocolor(r,g,0,alpha) ) end break end end end ) ---------------THE FOLLOWING IS THE MANAGEMENT OF NAMETAGS----------------- addEventHandler('onClientResourceStart', g_ResRoot, function() for i,player in ipairs(getElementsByType"player") do if player ~= g_Me then nametag.create ( player ) end end end ) addEventHandler ( "onClientPlayerJoin", g_Root, function() if source == g_Me then return end setPlayerNametagShowing ( source, false ) nametag.create ( source ) end ) addEventHandler ( "onClientPlayerQuit", g_Root, function() nametag.destroy ( source ) end ) -- Math functions function math.lerp(from,to,alpha) return from + (to-from) * alpha 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 function dxDrawColoredText(str, ax, ay, bx, by, color, scale, font,left,top) left = "left" if not top then top = "top" 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,left,top,true) 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,left,top,true) end end
  19. It's easy, just change the visibleDistance. createBlip ( -1338, -2075, 23, 37, 2, 255, 255, 255, 0, 250 )
  20. Is actually easy to create a MySQL account system, I've done it for one of my gamemodes. I suggest you to use the DB MySQL functions instead of Ryden's, as they're a lot easier to use (at least for me). https://wiki.multitheftauto.com/wiki/DbConnect
  21. local MarkerPolice = createMarker( 1588.4000244141, -1637, 11.39999961853, 'corona', 12.0, 0, 0, 255, 0) local Policegate1 = createObject(980, 1590.1999511719, -1638.4000244141, 15.199999809265, 0, 0, 0) function MarkerHit1 ( hitElement, matchingDimension ) if ( getPlayerTeam(hitElement) and getPlayerTeam(hitElement) == getTeamFromName("Police") ) then moveObject(Policegate1, 2000, 1598.1999511719, -1638.4000244141, 15.199999809265 ) end end function MarkerLeave1( leaveElement, matchingDimension ) if ( getPlayerTeam(leaveElement) and getPlayerTeam(leaveElement) == getTeamFromName("Police") ) then moveObject(Policegate1, 2000, 1590.1999511719, -1638.4000244141, 15.199999809265 ) end end addEventHandler( "onMarkerHit", MarkerPolice, MarkerHit1 ) addEventHandler( "onMarkerLeave", MarkerPolice, MarkerLeave1 )
×
×
  • Create New...