Jump to content

novo

Members
  • Posts

    325
  • Joined

  • Last visited

Everything posted by novo

  1. Although you've apparently solved it, onClientResourceStart's event is the root element in the resource that started. Which means you can't directly use a resource's element, but it's root (getResourceRootElement).
  2. The only issue I can see within your code is the following: function LobbyManager:DoCreateLobby(player, ...) local boolA = self:AddLobby(Lobby:New(player, ...)); local boolB = self:AddLobby(Lobby:Constructor(player, ...)); if(boolA) then player:ShowMessageBox(player:GetLanguage().messagebox.newgame.sucessTitle, player:GetLanguage().messagebox.newgame.sucessMessage, strings.messagebox.newgame.sucessButton, "sucess", false) end end In case you execute boolA, we've got self:AddLobby(Lobby:New()). Lobby.new returns an array (obj) which will apparently be used for indexing @self.AddLobby (self.lobbys[lobby] = lobby). And in case you execute boolB, you'll be having nil as AddLobby's argument and consequently it will try to index self.lobbys using a nil value.
  3. novo

    MySql Error!

    I recommend you to move your question to a more appropiate section in order to obtain accurate replies. Either way, as that module might be deprecated, make sure to be aware about MTA's built-in mysql functions @dbConnect.
  4. novo

    MySQL query

    I'd rather try doing the following: for k,v in pairs(currentAmount) do outputChatBox(k.." => "..v) end as it might be possible that it's indexed this way: currentAmount["itemAmount"] instead as "querySingle" probably automatically adds "LIMIT 1" to your actual query (as the function's name contains single). Although, it would be way easier if you show us the mentioned function you're calling.
  5. novo

    [Wiki] OOP Basis

    That's perfect, thanks! Let's hope it will be easier for new beginners now
  6. Good morning, I've just created a tutorial which contains the basis for achieving OOP with Lua besides a large section dedicated to metatables' explanation and comprehension. Have a look now! Also, make sure to post either any feedback downbelow or anything that might be necessary to modify. And yeah, definitely in case you contribute!
  7. You're welcome though yeah, lets rather wait for an experienced user.
  8. The sizes might be bugging because you need to go through some sort of scaling between the material's and render target's dimensions. Either way, I don't think doing this whole process with a texture would make it different. Render targets are good enough though I actually can't think about another way apart from material lines. We could rather wait for other scripters experienced on such things, such as Gallardo.
  9. Well now that might be caused due to wrong positioning values or even dimensions (width, height). I recommend you to check Samt2497's HoloScreen's code in order to make sure you're using correct values.
  10. Out from this pointless confrontation that you're having over here, I recommend you to begin with the following piece of code: local scoreboard = {data = {}} function scoreboard:generate () local data = {players = {}, teams = {}) for i,v in ipairs(getElementsByType("team")) do data.teams[v] = {} end for i,v in ipairs(getElementsByType("player")) do local team = getPlayerTeam(v) if not team then table.insert(data.players, v) else table.insert(data.teams[team], v) end end self.data = data end Once held all the necessary data on a table, you will simply need to use dx functions whilst looping over it.
  11. Well, the overall syntax seems to be proper and there shouldn't be any issue. I've taken the last code snippet you've given and I've came upon a single conclusion - postGUI. As it's supposedly being drawn on top of or behind any ingame GUI, the text might be coming out of the drawn material itself - so I'd try by setting its value to false. However, here's the mentioned snippet organized for any further assistance: (with postGUI set to false) function renderToptimes() if not bold then return end local nX,nY,nZ = getWorldFromScreenPosition(startX,hd*y+(h*y/2),0) local nX2,nY2,nZ2 = getWorldFromScreenPosition(startX+(width2*x),hd*y+(h*y/2),0) local eX,eY,eZ = getWorldFromScreenPosition(startX+(width2*x/2),hd*y+h*y,0) dxSetRenderTarget(target) dxSetBlendMode("modulate_add") dxDrawImage(0, 0,width2*x,h*y,"misc/bg.png") --dxDrawImage(fix3+sx2, hd*y+h/2*y,width*x,h*y,"misc/bg.png") --dxDrawRectangle(sx, hd*y,width*x,y*0.03,tocolor(70,70,70,150)) --dxDrawRectangle(sx, hd*y,width*x,h*y,tocolor(0,0,0,180)) local width22 = dxGetTextWidth("Toptimes ", 1*scale,sansb) local width33 = dxGetTextWidth(mapname,1*scale,sansd) dxDrawText("Toptimes ", 0+fix4+((width3*x)/2)-width33/2-width22,0+fixy3,width+fix4,0+y*0.025+fixy3,tocolor(255,255,255,255),1*scale,sansb,"left","center") dxDrawText(mapname, 0+fix4+(width3*x/2)-width33/2,0+fixy3,width+fix4,0+y*0.025+fixy3,tocolor(255,255,255,255),1*scale,sansd,"left","center") --[[dxDrawText("#",fix+sx+x*0.01,fixy+y*0.05+ hd*y+y*0.01,width*x+sx,fixy+y*0.05+hd*y,tocolor(255,255,255,255),1*scale,sansb,"left","center",false,false,false,true,true) dxDrawText("Name",fix+sx+x*0.025,fixy+y*0.05+ hd*y+y*0.01,width*x+sx,fixy+y*0.05+hd*y,tocolor(255,255,255,255),1*scale,sansb,"left","center",false,false,false,true,true) dxDrawText("Time",fix+sx+x*0.145,fixy+y*0.05+ hd*y+y*0.01,width*x+sx,fixy+y*0.05+hd*y,tocolor(255,255,255,255),1*scale,sansb,"left","center",false,false,false,true,true) dxDrawText("Location",fix+sx+x*0.2,fixy+y*0.05+ hd*y+y*0.01,width*x+sx,fixy+y*0.05+hd*y,tocolor(255,255,255,255),1*scale,sansb,"left","center",false,false,false,true,true) dxDrawText("Date",fix+sx+x*0.26,fixy+y*0.05+ hd*y+y*0.01,width*x+sx,fixy+y*0.05+hd*y,tocolor(255,255,255,255),1*scale,sansb,"left","center",false,false,false,true,true) ]] local flagwidth = 15/1280*x local flagheight = 10/720*y local fwidth = dxGetTextWidth("Location", 1*scale,sansb) local base = base or 1 local tablefind = nil for i=base, base+7 do if not defaultTable[i] then defaultTable[i] = {serial="...",name="-- Empty --",time=0,country="ZZ",date=getRealTime().timestamp} end local serial = defaultTable[i].serial or "" local name = defaultTable[i].name or "-- Empty --" local time = defaultTable[i].time or 0 local date = defaultTable[i].date or getRealTime().timestamp local country = defaultTable[i].country or "ZZ" if serial == getPlayerSerial(localPlayer) then --dxDrawRectangle(sx,y*0.04+hd*y+y*0.005 +(y*0.025*(i-base+1)),width*x,y*0.025,tocolor(100,100,100,50)) --dxDrawImage(fix+sx,fixy+y*0.04+hd*y+y*0.005 +(y*0.025*(i-base+1)),width*x,y*0.025,"misc/chosen.png",0,0,0,tocolor(255,255,255,255)) dxDrawRectangle(0+fix4,fixy+0+y*0.045+(y*0.025*(i-base+1)),width-fix5,y*0.025,tocolor(10,10,10,100)) end dxDrawText(i,startX2+space,fixy+y*0.04+ hd*y+y*0.01 + (y*0.025*(i-base+1)),width*x+sx,fixy+y*0.04+hd*y+(y*0.025*(i+1-base+1)),tocolor(255,255,255,255),1*scale,sansd,"left","center",false,false,false,true,true) dxDrawText(defaultTable[i].name,startX2+space+topspace+space,y*0.04+ hd*y+fixy+y*0.01 + (y*0.025*(i-base+1)),width*x+sx,fixy+y*0.04+hd*y+(y*0.025*(i+1-base+1)),tocolor(255,255,255,255),1*scale,sansb,"left","center",false,false,false,true,true) if time then if time == 0 then ms,min,sec = "---","--","--" else time = tostring(defaultTable[i].time) ms = tostring(math.round(tonumber((time/1000 - ("%02d"):format(time/1000))*1000))) min = (((time-ms)/1000)/(60)) diff = (min - math.floor(min))*60 ms = ("%03d"):format(tostring(math.round(ms))) min = ("%02d"):format(tostring(math.round(min))) sec = ("%02d"):format(tostring(math.round(diff))) end dxDrawText(min..":"..sec..":"..ms,startX2+space+topspace+space+namespace+space,fixy+hd*y+y*0.05 + (y*0.025*(i-base+1)),width*x+sx,fixy+y*0.04+hd*y+(y*0.025*(i+1-base+1)),tocolor(255,255,255,255),1*scale,sansd,"left","center",false,false,false,true,true) end --dxDrawText(defaultTable[i].country,sx+x*0.01,y*0.04+ hd*y+y*0.01 + (y*0.025*i),width*x+sx,y*0.04+hd*y+(y*0.025*(i+1)),tocolor(255,255,255,255),0.55,semibold,"left","center",false,false,true,true) if defaultTable[i].country:lower()~="zz" then dxDrawImage(startX2+space+topspace+space+namespace+space+timespace+space+flagwidth/2,fixy+hd*y+y*0.057+(y*0.025*(i-base+1))-flagheight/2,flagwidth,flagheight,"flags/"..defaultTable[i].country:lower()..".png",0,0,0,tocolor(220,220,220,255),true) end local time = getRealTime(defaultTable[i].date) local str = time.monthday or 1 local months = {"Jan","Feb","March","April","May","June","July","Aug","Sep","Oct","Nov","Dec"} local str = str.."."..(time.month+1) local str = str.."."..time.year+1900 dxDrawText(str,startX2+space+topspace+space+namespace+space+timespace+space+flagspace+space,y*0.04+fixy+ hd*y+y*0.01 + (y*0.025*(i-base+1)),width*x+sx,fixy+y*0.04+hd*y+(y*0.025*(i+1-base+1)),tocolor(255,255,255,255),1*scale,sansd,"left","center",false,false,false,true,true) end for a=1, table.size(defaultTable) do if defaultTable[a] then if defaultTable[a].serial == getPlayerSerial(localPlayer) then local a,b = a,9 dxDrawRectangle(0+fix4,0+y*0.085 +(y*0.025*(b)),width-fix5,y*0.025,tocolor(10,10,10,100)) dxDrawText(a,startX2+space,fixy+y*0.04+ hd*y+y*0.01 + (y*0.025*(b)),width*x+sx,fixy+y*0.04+hd*y+(y*0.025*(b+1)),tocolor(255,255,255,255),1*scale,sansd,"left","center",false,false,false,true,true) dxDrawText(defaultTable[a].name,startX2+space+topspace+space,y*0.04+ hd*y+fixy+y*0.01 + (y*0.025*(b)),width*x+sx,fixy+y*0.04+hd*y+(y*0.025*(b+1)),tocolor(255,255,255,255),1*scale,sansb,"left","center",false,false,false,true,true) local time = tostring(defaultTable[a].time) local ms = tostring(math.round(tonumber((time/1000 - ("%02d"):format(time/1000))*1000))) local min = (((time-ms)/1000)/(60)) local diff = (min - math.floor(min))*60 local ms = ("%03d"):format(tostring(math.round(ms))) local min = ("%02d"):format(tostring(math.round(min))) local sec = ("%02d"):format(tostring(math.round(diff))) if tonumber(time) == 0 then dxDrawText("--:--:---",startX2+space+topspace+space+namespace+space,fixy+hd*y+y*0.05 + (y*0.025*(b)),width*x+sx,fixy+y*0.04+hd*y+(y*0.025*(b+1)),tocolor(255,255,255,255),1*scale,sansd,"left","center",false,false,false,true,true) else dxDrawText(min..":"..sec..":"..ms,startX2+space+topspace+space+namespace+space,fixy+hd*y+y*0.05 + (y*0.025*(b)),width*x+sx,fixy+y*0.04+hd*y+(y*0.025*(b+1)),tocolor(255,255,255,255),1*scale,sansd,"left","center",false,false,false,true,true) end local time = getRealTime(defaultTable[a].date) local str = time.monthday or 1 local months = {"Jan","Feb","March","April","May","June","July","Aug","Sep","Oct","Nov","Dec"} local str = str.."."..(time.month+1) local str = str.."."..time.year+1900 dxDrawText(str,startX2+space+topspace+space+namespace+space+timespace+space+flagspace+space,y*0.04+fixy+ hd*y+y*0.01 + (y*0.025*(b)),width*x+sx,fixy+y*0.04+hd*y+(y*0.025*(b+1)),tocolor(255,255,255,255),1*scale,sansd,"left","center",false,false,false,true,true) if defaultTable[a].country:lower()~="zz" then dxDrawImage(startX2+space+topspace+space+namespace+space+timespace+space+flagwidth/2,fixy+hd*y+y*0.057+(y*0.025*(b))-flagheight/2,flagwidth,flagheight,"flags/"..defaultTable[a].country:lower()..".png",0,0,0,tocolor(255,255,255,255),true) end end end end --dxDrawText("Test Text", x*0.4,y*0.5,x,y,tocolor(255,255,255,255),6.1,"clear","left","top",false,false,false,true,true) --dxDrawText("Test Text", x*0.4,y*0.65,x,y,tocolor(255,255,255,255),1,clear,"left","top",false,false,false,true,true) dxSetRenderTarget() dxSetBlendMode("blend") if target then --dxDrawImage(startX, hd*y,width2*x,h*y,target) --dxDrawMaterialLine3D(nX,nY,nZ,nX2,nY2,nZ2,mat,width2*x) dxDrawMaterialLine3D(nX,nY,nZ,nX2,nY2,nZ2,target,width2*x) end end
  12. The message isn't being shown because the if statement rejects the subsequent execution, as it will only be executed in case "not isTimer" returns true and once you set this timer, it will return false. You can do it as I did instead. cooldown = {} function createRamp ( player, command ) local vehicle = getPedOccupiedVehicle ( player ) if vehicle and not isTimer( cooldown[player] ) then local x, y, z = getElementPosition ( player ) local theVehicle = getPedOccupiedVehicle ( player ) local a,b,r = getVehicleRotation ( theVehicle ) x = x - math.sin ( math.rad(r) ) * 18 y = y + math.cos ( math.rad(r) ) * 18 ramp = createObject ( 3080, x, y, z, 0, 0, r ) setTimer(destroyElement, 5000, 1, ramp ) outputChatBox( "Jump set!!", player, 0, 255, 0 ) cooldown[player] = setTimer( function() end, 10000, 1 ) else outputChatBox( "Can't jump right now, wait few seconds then try again.", player, 255, 0, 0 ) end end addCommandHandler ( "r", createRamp ) addCommandHandler ( "j", createRamp )
  13. I don't see any problem within your syntax, though I've organized it slightly better: local safeColFCH = createColCuboid ( -348.83591, 1025.67822, 20.06553, 60, 60, 255 ) local safeZoneRadarFCH = createRadarArea ( -348.83591, 1025.67822, 60, 60, 0, 94, 0, 80) setElementData(safeColFCH, "zombieProof", true) function enterZone (hitPlayer, sameDimension) -- modified second value's name if source == safeColFCH then if not getElementData(source, "zombieProof") then return end -- return in case it's not supposed to kill zombies local skin = getElementModel(hitPlayer) if skin == 13 or skin == 22 or skin == 56 or skin == 67 or skin == 68 or skin == 69 or skin == 75 or skin == 77 or skin == 84 or skin == 92 or skin == 95 or skin == 97 or skin == 105 or skin == 107 or skin == 108 or skin == 126 or skin == 127 or skin == 128 or skin == 152 or skin == 162 or skin == 167 or skin == 188 or skin == 195 or skin == 206 or skin == 209 or skin == 212 or skin == 213 or skin == 229 or skin == 230 or skin == 258 or skin == 264 or skin == 274 or skin == 277 then killPed(hitPlayer) end end end addEventHandler("onColShapeHit", root, enterZone) About that weird issue you were experiencing when those zombies were only dying once these jumped might be caused by a height difference between the floor and the colshape itself. In order to adjust its altitude on a proper value, you could use showcol.
  14. novo

    XML

    Te he dejado una solución por aquí.
  15. novo

    XML

    Well, I suppose you've changed the meta.xml file you're trying to read since the first post - so I'll rather give you a working example based on a sample meta file. <meta> <file src="song.mp3" /> <script src="client.lua" type="client" /> <info gamemodes="race" type="map" name="Example" /> <map src="example.map" dimension="0" /> <settings> <setting name="#respawn" value='[ "none" ]' /> </settings> </meta> local meta = xmlLoadFile(":"..resource.."/meta.xml") local nodes = xmlNodeGetChildren(meta) local files = {} local _settings = {} for i,v in ipairs(nodes) do local attributes = xmlNodeGetAttributes(v) local type = xmlNodeGetName(v) if type == "file" then table.insert(files, attributes.src) -- song.mp3 / any file elseif type == "settings" then local settings = xmlNodeGetChildren(v) -- As settings in this case contains sub-nodes, we retrieve and loop over them for i,v in ipairs(settings) do local attributes = xmlNodeGetAttributes(v) if attributes.name == "#respawn" then table.insert(_settings, {attributes.name, attributes.value}) -- #respawn, [ "none" ] / any node's attributes inside "settings" end end end end
  16. novo

    XML

    Yo empezaría por comprobar qué tipo de elemento es "m" (getElementType) y en todo caso, no veo que xmlLoadFile devuelva algún error pero, en caso de que no los tenga (más vale no descartar ningún fallo), es necesario que el resource tenga permisos.
  17. novo

    string question

    You've got several options: (two given down below) local example = "example_string124" local parts = split(example, "_") -- This splits the above string into: example and string124 and creates a table that contains both new strings for i,v in ipairs(parts) do print(v) end -- local cut = example:sub(1, 5) -- This cuts the string until the 5th letter print(cut) -- examp
  18. Hmm well I'm actually not understanding what you want to accomplish, though in case you want to save the uploaded images in a resource I suppose you want that the resource itself recognizes/loads these images; what would require you to modify its meta file (reference).
  19. novo

    Wiki Isssue

    Well, what that root example does is basically destroying any created element that has "root" as its parent. And in case you want to remove the entire world: (wiki's example) for i=550,20000 do removeWorldModel(i,10000,0,0,0) end setOcclusionsEnabled(false) -- Also disable occlusions when removing certain models setWaterLevel(-5000) -- Also hide the default water as it will be full of holes
  20. novo

    Weird Problem

    I see you're using a single variable for retrieving the inputted map name, which means only the first introduced argument when running the command will be held. (arg1, arg2, ...: Each word after command name in the original command is passed here in a seperate variable. If there is no value for an argument, its variable will contain nil. You can deal with a variable number of arguments using the vararg expression, as shown in Server Example 2 below.) In order to avoid this and to retrieve all the inputted arguments you could do the following: function maps () local mapsList = {} for i, map in ipairs (exports.mapmanager:getMapsCompatibleWithGamemode(exports.mapmanager:getRunningGamemode())) do if get(getResourceName(map)..".#respawn") == "none" then mapsList[i] = getResourceInfo(map, "name") end end return mapsList -- As we're calling the function each time the command is executed, lets return the generated table instead of establishing a global variable end function check (player, _, ...) -- "..." refers to all the following arguments local arguments = {...} -- By doing this we insert all those arguments we didn't hold onto any variable into a table if #arguments == 0 then return end -- Stop the function's execution in case no arguments were introduced local mapName = table.concat(arguments, " ") -- This will convert the above table into a string, which will be formed by any value the table contains itself separated by spaces local maps = maps() -- mapsList for i,v in ipairs(maps) do -- ipairs(maps()) if we want to avoid creating an unnecessary extra variable if string.find(v, string.lower(mapName) then -- mapName:lower() = string.lower(mapName) outputChatBox("Map found: "..v) end end end addCommandHandler("check", check) And well, make sure that "mapsList" contains valid maps as I'm not sure that ".#respawn" is the setting name normally used.
  21. Apart from the functions declared above, you could also use timers @setTimer.
  22. novo

    Wiki Isssue

    We would be able to provide you deeper assistance in case you tell us what element you're exactly trying to eliminate. Though, in case you didn't know yet and it's what you were looking for, there's a function that permits you removing world objects @removeWorldModel.
  23. As specified here, an "ALTER TABLE ORDER BY" statement exists in the syntaxes accepted by MySQL so w3schools syntax checker might be slightly outdated. So, as Gallardo stated above, you should do it as follows: (reference) ALTER TABLE tablename ORDER BY columnname; ALTER TABLE tablename ORDER BY column1 ASC, column2 DESC; Though, at the beginning, the sort will begin to drift after additional INSERTs and DELETEs. Rows that will sorted will remain in their order, but new rows will be placed at the end. And well, in case this causes any grand dilemma to you, you could simply sort the rows when fetching the table's results. (table.sort)
×
×
  • Create New...