Jump to content

ozulus

Members
  • Posts

    131
  • Joined

  • Last visited

Everything posted by ozulus

  1. Just change that part. local checkPlantGUI = nil function cCheckPlant() if checkPlantGUI == nil then --checkPlantGUI = checkPlantGUI --wtf this shit!? disabled.. checkPlantGUI will be always nil. local lplayer = getLocalPlayer() local width, height = 150, 175 local scrWidth, scrHeight = guiGetScreenSize() local x = scrWidth/2 - (width/2) local y = scrHeight/2 - (height/2) plantWindow = guiCreateWindow(x, y, width, height, "Cannabis Plant - Stage: " .. stage .. "", false) checkPlantGUI = plantWindow --added local width2, height2 = 10, 10 local x = scrWidth/2 - (width2/2) local y = scrHeight/2 - (height2/2) harvest = guiCreateLabel(0.1, 0.1, 0.75, 0.30, "Current Harvest: ".. harvest .."gram(s)", true, plantWindow) guiLabelSetHorizontalAlign(harvest, "center", true) guiLabelSetVerticalAlign(harvest, "center") --Buttons pick = guiCreateButton(0.1, 0.4, 0.75, 0.30, "Pick Buds", true, plantWindow) addEventHandler("onClientGUIClick", pick, harvestBud) close = guiCreateButton(0.1, 0.7, 0.75, 0.30, "Close", true, plantWindow) addEventHandler("onClientGUIClick", close, closeWindow) --Quick Settings guiWindowSetSizable(plantWindow, false) guiWindowSetMovable(plantWindow, true) guiSetVisible(plantWindow, true) showCursor(true) end end
  2. I'm trying to explain that already. The index in this loop is a NUMBER. Not a player element. Peace
  3. t1[1] returns nil. Only t1[2] gives the value which is "this". You are still wrong... Your solution is good btw. but its value.playerName , value.playerKills not killerTable[id].playerName , killerTable[id].playerKills
  4. If you don't know tables, please don't speak... Have you ever tried killerTable[id].playerName ? I have tried, it returns nil.
  5. Seems you didn't understand getting value from table in loop or my language skills not enough to explain it better killerTable[id].playerName must be value.playerName killerTable[id].playerKills must be value.playerKills --Client Draw with my Lib for id, value in pairs(killerTable) do if tonumber(id) == tonumber(1) then dxLibTopwinners(ddKill.posT,(sY*0.038+34*scale),sizeXT,sizeYT,value.playerName,1*font_size,fontTopKillers,255,255,255,ddKill.alphaT[1],0,0,0,ddKill.alphaT[2],sizeYT*0.8,sizeYT*0.8,255,136,0,ddKill.alphaT[1],"Kills: "..value.playerKills or "?","Hits: ".."",false,false) end if tonumber(id) == tonumber(2) then dxLibTopwinners(ddKill.posT,(sY*0.038+34*scale)+sizeYT*1.05,sizeXT,sizeYT,value.playerName,1*font_size,fontTopKillers,255,255,255,ddKill.alphaT[1],0,0,0,ddKill.alphaT[2],sizeYT*0.8,sizeYT*0.8,105,105,105,ddKill.alphaT[1],"Kills: "..value.playerKills or "?","Hits: ".."",false,false) end if tonumber(id) == tonumber(3) then dxLibTopwinners(ddKill.posT,(sY*0.038+34*scale)+sizeYT*1.05*2,sizeXT,sizeYT,value.playerName,1*font_size,fontTopKillers,255,255,255,ddKill.alphaT[1],0,0,0,ddKill.alphaT[2],sizeYT*0.8,sizeYT*0.8,139,54,38,ddKill.alphaT[1],"Kills: "..value.playerKills or "?","Hits: ".."",false,false) end --The next line is the 146 if tonumber(id) >= tonumber(4) and tonumber(id) <= tonumber(8) then dxLibToptime(ddKill.posT,(sY*0.038+34*scale)+sizeYT*1.05*(id-1),sizeXT,sizeYT,value.playerName,1*font_size,fontTopKillers,255,255,255,ddKill.alphaT[1],0,0,0,ddKill.alphaT[2],sizeYT*0.8,sizeYT*0.8,45,60,81,ddKill.alphaT[1],id,"Kills: "..value.playerKills or "?","Hits: ".."",1.2*font_size,false,false) end end
  6. Yeah i forgot that the loop returns index as a number, it's now more clear. For delete table you can use that, killerTable = nil Checking table is empty? if #killerTable == 0 then killerTable = nil -- delete the table.. end
  7. Don't know if it works but if i were you, i would use variable to get player rank like that. local rank = 1 for _, value in pairs(killerTable) do local color = "#FFFFFF" if rank == 1 then color = "#FF0000" elseif rank == 2 then color = "#FFFF00" elseif rank == 3 then color = "#00FF00" end local playerNameWithoutHex = removeColorCoding(value.playerName) -- removing hex color codes from nick... dxDrawText(color..playerNameWithoutHex.. " Kills: "..value.playerKills,sX/2,sY/2,0,0,tocolor(255,255,255,255),1,"default-bold","left","top",false,false,false,true) rank = rank + 1 --updating rank for next player... end -- remove color coding from string function removeColorCoding ( name ) return type(name)=='string' and string.gsub ( name, '#%x%x%x%x%x%x', '' ) or name end
  8. There is no indexed value in killerTable so you can't use indexed loop (ipairs and your loop). So use pairs loop. for _, value in pairs(killerTable) do dxDrawText(value.playerName.. " Kills: "..value.playerKills,sX/2,sY/2,0,0,tocolor(255,255,255,255),1,"default-bold","left","top",false,false,false,true) end
  9. That's because the sorting wasn't completed when you are looping. So in server-side, sort table. Then send the table to client-side, and loop it. --server side table.sort (killerTable, function (a, b) return a.playerKills > b.playerKills end) -- define the 'theElement' triggerClientEvent(theElement, "sendClientToTable", resourceRoot, killerTable) --client side function blabla(tableFromServerside) killerTable = tableFromServerside end addEvent("sendClientToTable", true) addEventHandler("sendClientToTable", root, blabla) function loopIt() if killerTable then for _, value in pairs(killerTable) do local playerName = value.playerName local playerKills = value.playerKills outputChatBox("playerName: "..playerName..", playerKills: "..playerKills) end end end addCommandHandler("loop", loopIt)
  10. It gives number of kill in my code... Here is your code, Overkillz killerTable = {} if ( not killerTable[killer] ) then killerTable[killer] = {playerName = getPlayerNametagText(killer), playerKills = 1} end killerTable[killer].playerKills = killerTable[killer].playerKills + 1 Table sorting, getting player name and kills with loop table.sort (killerTable, function (a, b) return a.playerKills > b.playerKills end) for _, value in pairs(killerTable) do local playerName = value.playerName local playerKills = value.playerKills outputChatBox("playerName: "..playerName..", playerKills: "..playerKills) end
  11. Ehm, i think that better than your code, i am not sure but it should work. (wrote on my phone) killerTable = {} if ( not killerTable [ killer ] ) then -- if it is first kill, set player table value '1' killerTable [ killer ] = 1 end -- if it isnt first kill, set player table value 'previous kills' + '1' killerTable [ killer ] = killerTable [ killer ] + 1
  12. -- you must change this setElementData(localPlayer, "ultimateHi", "Whatever") -- to local driver = getVehicleController(hit) setElementData(localPlayer, "ultimateHi", driver) function updateKiller() local thePlayer = getPlayerNametagText(source) local killer = getElementData(source,"lastHit") if killer then local killerName = getPlayerNametagText(killer) outputChatBox(thePlayer.." #ffffffhave been killed by: #00ff00"..killerName, getRootElement(),255,255,255,true) local previousKills = getElementData(killer, "kills") or 0 setElementData(killer, "kills", previousKills + 1) end end addEventHandler( "onPlayerWasted", getRootElement(),updateKiller)
  13. Just delete these lines, triggerEvent("onPlayerDeadInRace", gRoot, 1,Winner)
  14. ozulus

    Help.

    exports["notices"]:addNotification(source, "Test", "success");
  15. Use this event, there is 2 example it's enough for you https://wiki.multitheftauto.com/wiki/On ... DataChange
  16. Use comma_value function for that. local money = getPlayerMoney(getLocalPlayer()) local formattedMoney = comma_value(money) -- from [url=http://lua-users.org/wiki/FormattingNumbers]http://lua-users.org/wiki/FormattingNumbers[/url] function comma_value(amount) local formatted = amount while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if (k==0) then break end end return formatted end
  17. Looks beatiful, you guys have done a really good job. Good luck with that
  18. If you still need help, here you go. outputDebugString(userName.."WORD") -- output --> INFO: Username WORD -- Use string.gsub to remove spaces, so it will be like that, local userName = string.gsub(userName, " ", "") outputDebugString(userName.."WORD") -- output --> INFO: UsernameWORD
  19. This should work. addEventHandler( "onClientRender", root, function() for i, vehicle in ipairs(getElementsByType("vehicle")) do local x, y, z = getElementPosition( vehicle ) local sX, sY = getScreenFromWorldPosition( x, y, z ) local health = math.floor( getElementHealth( vehicle )/10) local Rhealth = 50 local lineLength = 56 * ( health / 100 ) if health < 25 then health = 0 else math.floor( getElementHealth( vehicle )/10) end local vehicleDriver = getVehicleOccupant ( vehicle ) -- get driver of car if isElement(vehicleDriver) then -- is there driver in car?, if yes draw the healthbar if isElementOnScreen( vehicle ) then if sX then dxDrawText( health, sX, sY ) dxDrawRectangle( sX-32, sY-82, 60, 14, tocolor( 0, 100, 0, 120 ) ) dxDrawRectangle( sX-30, sY-80, 56, 10, tocolor( 0, 220, 0, 120 ) ) dxDrawRectangle( sX-30, sY-80, lineLength, 10, tocolor( 0, 220, 0 ) ) end end end end end )
  20. function greetingHandler () setElementData(source, "MAX_Slots", 50) setElementData(source, "M4", 1) setElementData(source, "DMR", 1) setElementData(source, "PDW", 1) setElementData(source, "Hunting Knife", 1) setElementData(source, "Milk", 5) setElementData(source, "Cooked Meat", 5) setElementData(source, "M4 Mag", 90) setElementData(source, "DMR Mag", 10) setElementData(source, "PDW Mag", 90) end addEvent( "onGreeting", true ) addEventHandler( "onGreeting", getRootElement(), greetingHandler ) function greeting2Handler () setElementData(source, "Desert ghillie Suit", 1) setElementData(source, "Night Vision Goggles", 1) setElementData(source, "Infrared Goggles", 1) setElementData(source, "Map", 1) setElementData(source, "Box of Matches", 1) setElementData(source, "Watch", 1) setElementData(source, "GPS", 1) setElementData(source, "Toolbox", 1) setElementData(source, "Radio Device", 1) end addEvent( "onGreeting2", true ) addEventHandler( "onGreeting2", getRootElement(), greeting2Handler ) local spamTimer = {} local TIME_INTERVAL = 30 -- 30 secs function PlayerHaveLevel( ) if isTimer(spamTimer[source]) then return outputChatBox("You can't use it now",source) end local accName = getAccountName ( getPlayerAccount ( source ) ) if ( isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) ) then triggerClientEvent(source, "ShowVipPanel", source ) spamTimer[source] = setTimer(function() spamTimer[source] = nil end, TIME_INTERVAL * 1000, 1) else outputChatBox("U DON'T HAVE VIP DO USE THIS COMMAND",source) end end addEvent( "ClientHaveLevel", true ) addEventHandler( "ClientHaveLevel", getRootElement(), PlayerHaveLevel )
  21. addEventHandler("onVehicleExit", root, function() if not isVehicleCreatedByPlayer( source ) or not isVehicleEmpty( source ) then return -- It's not a vehicle created by a player or the vehicle is not empty then cancel end local destroyTimer = setTimer( function( vehicle ) if isElement( vehicle ) then destroyElement( vehicle ) end end, 5000, 1, source) -- vehicle is not defined here, so i wrote source instead of 'vehicle' setElementData(source, "destroyTimer", destroyTimer) -- same end)
  22. --[b]UPDATED[/b] function show() local showing = isCursorShowing () if showing and ( cursorX ~= nil and cursorY ~= nil ) then dxDrawImage ( cursorX, cursorY, 50, 50, 'files/crosshair.png') setCursorAlpha(0) end end addEventHandler('onClientRender', root, show ) addEventHandler( "onClientCursorMove", getRootElement( ), function( _, _, absX, absY ) cursorX = absX cursorY = absY end )
  23. ozulus

    lock

    I did it on my mobile phone, so i didn't test it. function removeak(player) if hasPedWeapon(player, 30) then takeWeapon(player, 30) end end addCommandHandler("removeak", removeak) function hasPedWeapon(ped, weaponID) if ped and isElement(ped) and getElementType(ped) == "ped" or getElementType(ped) == "player" and weaponID then for i=2,9 do local wep = getPedWeapon(ped,i) if wep and wep == weaponID then return true end end end return false end
  24. Add a variable for player count. Like that, addEvent("text", true) addEventHandler("text", getRootElement(), function() local playerCount = getPlayerCountInDimension( 2 ) if playerCount then setElementData(source,"players",Count) end end) function getPlayerCountInDimension( dimID ) local counter = 0 for k,v in ipairs(getElementsByType("player")) do if getElementDimension ( v ) == dimID then counter = counter + 1 end end return counter end
×
×
  • Create New...