Tomas
Members-
Posts
2,530 -
Joined
-
Last visited
Everything posted by Tomas
-
Well, we haven't access to the resource, how could we know it?
-
¿En cuál cierto punto?
-
[Solucionado] No reconoce el setTimer, pero si el resto
Tomas replied to UserToDelete's topic in Scripting
El timer probablemente está funcionando, quizás lo que falla es el loop. Cuando usas tablas que no están indexadas numéricamente o no están ordenadas, debes usar pairs() Aquí tienes un ejemplo de lo que pasa: Tabla usada: t = { [1] = 'eggs'; [2] = 'cereal'; [3] = 'pancakes'; [5] = 'waffles'; -- I skipped 4 for a reason. myfavorite = 'bacon'; myleastfavorite = 'toast'; } Prueba con pairs() e ipairs(). Pairs 1 eggs Pairs 2 cereal Pairs 3 pancakes Pairs 5 waffles Pairs myfavorite bacon Pairs myleastfavorite toast Ipairs 1 eggs Ipairs 2 cereal Ipairs 3 pancakes Función utilizada: for i,v in pairs(t) do print ("Pairs", i,v) end for i,v in ipairs(t) do print ("Ipairs", i,v) end Una mejor explicación: http://www.computercraft.info/forums2/i ... __p__41709 -
Realmente no va tanto en resumir, sino que sea ejecutado de la forma más eficiente posible, que le tome los mínimos recursos posibles al compilador de Lua en compilar ('leer') el script.
-
exports.DB2:pobierzWyniki("SELECT * FROM ACCS WHERE acc=? AND password=?", usernamel, passwordl) This is returning nil.
-
Estás usando una variable global en server-side, la cuál será destruida al reiniciar el resource.. addEventHandler("onPlayerLogin", root, function ( _, c) if not getAccountData(c, "firstLogin") then .......... setAccountData(c, "firstLogin", true) end end )
-
if not fileExists ("saving.db") then fileCreate ("saving.db"); outputChatBox("Base de datos creada"); end local db = dbConnect("sqlite", "saving.db") ; dbExec(db, "CREATE TABLE IF NOT EXISTS `elements`(`elemType` TEXT, `id` INT, `x` INT, `y` INT, `z` INT, `rotX` INT, `rotY` INT, `rotZ` INT)") addEventHandler("onResourceStop", resourceRoot, function ( ) for index, value in ipairs ( getElementsByType ( "vehicle", resourceRoot ) ) do local x, y, z = getElementPosition(value) local rx, ry, rz = getElementRotation(value) dbExec( db, "INSERT INTO elements VALUES (?,?,?,?,?,?,?,?)", "vehicle", getElementModel(value), x, y, z, rx, ry, rz ) end for index, value in ipairs ( getElementsByType ( "object", resourceRoot ) ) do local x, y, z = getElementPosition(value) local rx, ry, rz = getElementRotation(value) dbExec( db, "INSERT INTO elements VALUES (?,?,?,?,?,?,?,?)", "object", getElementModel(value), x, y, z, rx, ry, rz ) end end ) addEventHandler("onResourceStart", resourceRoot, function ( ) query = dbQuery( db, "SELECT * FROM elements" ) result = dbPoll( query, -1 ) if result then for _, row in ipairs ( result ) do if row['elemType'] == "vehicle" then model, x, y, z, rx, ry, rz = row['id'], row['x'], row['y'], row['z'], row['rx'], row['ry'], row['rz'] createVehicle(model, x, y, z, rx, ry, rz) elseif row['elemType'] == "object" then id, x, y, z, rx, ry, rz = row['id'], row['x'], row['y'], row['z'], row['rx'], row['ry'], row['rz'] createObject(id, x, y, z, rx, ry, rz) end end end dbExec( db, "DELETE FROM `elements`"); end )
-
Pensé que te referías a un comando en el juego para eliminar los vehículos.. ID = 476 for index, value in ipairs ( getElementsByType ("vehicle") ) do if getElementModel(value) == ID then destroyElement(value) end end
-
addCommandHandler("removeFromID", function ( player, _, id ) temp = 0 for _, vehicles in ipairs ( getElementsByType ( "vehicle" ) ) do if getElementModel ( vehicles ) == tonumber ( id ) then destroyElement ( vehicles ) temp = temp + 1 end outputChatBox("Se han borrado: " .. tostring ( temp ) .. " " .. getVehicleNameFromModel ( tonumber ( id ) ) .. temp > 1 and "s" or "", player, 0, 255, 0) end end end )
-
Para reemplazar la textura puedes usar shaders, reemplazar el modelo sólo para un vehículo del mismo ID no es posible.
-
function getPlayers() playersInRun = {} for index, players in ipairs ( getElementsByType("player") ) do if getElementData(players, "RUN") then table.insert(playersInRun, players) end end end setTimer(getPlayers, 2500, 0) guiSetText(GUIEditor.label[8], 'ONLINE PLAYERS IN RUN: '.. #playersInRun)
-
¿A qué te refieres con 'rayas' ?
-
local join local quitInfo local nick addEventHandler("onClientPlayerChangeNick", root, function (old, new) nick = old .. ";" .. new addEventHandler("onClientRender", root, nickRender) setTimer(removeEventHandler, 2500, 1, "onClientRender", root, nickRender) end ) addEventHandler("onClientPlayerJoin", root, function () join = getPlayerName(source) addEventHandler("onClientRender", root, joinRender) setTimer(removeEventHandler, 2500, 1, "onClientRender", root, joinRender) end ) addEventHandler("onClientPlayerQuit", root, function (reason) quitInfo = getPlayerName(source) .. ";" .. reason addEventHandler("onClientRender", root, quitRender) setTimer(removeEventHandler, 2500, 1, "onClientRender", root, quitRender) end ) function nickRender () table = split(nick, ";") old, new = table[1], table[2] dxDrawText("* "..old.." is now known as "..new, 38, 507, 230, 522, tocolor(255, 255, 255, 255), 1.00, "sans", "left", "top", false, false, false, false, false) dxDrawImage(0, 497, 28, 25, "join.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) end function joinRender () dxDrawText("* "..join:gsub("#%x%x%x%x%x%x","").." has joined the game ", 38, 507, 230, 522, tocolor(255, 255, 255, 255), 1.00, "sans", "left", "top", false, false, false, false, false) dxDrawImage(0, 497, 28, 25, "join.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) end function quitRender() table = split(quitInfo, ";") qName, qReason = table[1], table[2] dxDrawText("* "..quit:gsub("#%x%x%x%x%x%x","").." #006400 has left the game [#FFFFFF" .. reason .. "#006400]", 38, 507, 230, 522, tocolor(255, 255, 255, 255), 1.00, "sans", "left", "top", false, false, false, false, false) dxDrawImage(0, 497, 28, 25, "join.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) end
-
addEventHandler("onClientPlayerJoin", root, function() addEventHandler("onClientRender", root, function () dxDrawText("* "..getPlayerName(source):gsub("#%x%x%x%x%x%x","").."has joined the game", 38, 507, 230, 522, tocolor(255, 255, 255, 255), 1.00, "sans", "left", "top", false, false, false, false, false) dxDrawImage(0, 497, 28, 25, "join.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) end end) addEventHandler("onClientPlayerChangeNick", root, function(old, new) old = old:gsub("#%x%x%x%x%x%x","") new = new:gsub("#%x%x%x%x%x%x","") if old ~= new then addEventHandler("onClientRender", root , function ( ) dxDrawText("* "..old.."is now known as"..new, 38, 507, 230, 522, tocolor(255, 255, 255, 255), 1.00, "sans", "left", "top", false, false, false, false, false) dxDrawImage(0, 497, 28, 25, "join.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) end end end) addEventHandler("onClientPlayerQuit", root, function(reason) addEventHandler("onClientRender", root, function ( ) dxDrawText("*"..getPlayerName(source):gsub("#%x%x%x%x%x%x","").."#006400 has left the game [#FFFFFF" .. reason .. "#006400]", 38, 507, 230, 522, tocolor(255, 255, 255, 255), 1.00, "sans", "left", "top", false, false, false, false, false) dxDrawImage(0, 497, 28, 25, "join.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) end end)
-
1. Edita el script. 2. http//luac.multitheftauto.com
-
Realmente no lo baneas, sólo no lo spawneas cuando entra al servidor. Es fácil de hacer.
-
Me puedes darme un ejemplo? no entiendo bien los exports T_T Agrega en el meta <export function="getPlayerGroup" type="server" /> Y en el script cambia 'getPlayerGroup' por 'exports.RESOURCENAME:getPlayerGroup'
-
Server-side: function showCountry () setElementData(source, "country", exports.admin:getPlayerCountry(source) ) end addEventHandler("onPlayerJoin", g_Root, showCountry) Client-side: if not cCountry then cCountry = getElementData(localPlayer, "country" ) end dxDrawImage(sX-toptimes.size[1]+(toptimes.size[1]*0.93)-10,(sY/2)-(toptimes.size[2])+(200/8)+((i-1)*20)+3,16,11,":admin/client/images/flags/".. cCountry ..".png",tocolor(255,255,255,255))
-
attachElements( getCamera(), localPlayer, 0.2,-2,0.8, 0,0,0 )
-
_redirectPlayer = redirectPlayer function redirectPlayer(thePlayer, commandName,targetPlayer, serverIP, serverPort) if targetPlayer and serverIP and serverPort then local target = findPlayerByName(targetPlayer) if (not isElement(target)) then outputChatBox("This player does no longer exist!", thePlayer, 255, 0, 0) return end _redirectPlayer(target,serverIP,tonumber(serverPort)) else outputChatBox("something missing please try again!",thePlayer,255,0,0,true) end end addCommandHandler("rd",redirectPlayer) function findPlayerByName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end