-
Posts
1,255 -
Joined
-
Last visited
Everything posted by .:HyPeX:.
-
I'm planning on creating a resource wich would let you have all server-side functions client-side by using exports.
-
Becouse, i cant sort an unindexed table, but an indexed table cant contain information. Supposing Players have different values, you can search them back by their values and have also their position. EDIT: Added some locals, and changed names to longer ones wich hardly would be used.. and also organized it a bit better- function PositionOrdering(CoreSoftyTable, CoreSoftySmaller,CoreSoftyMax) if ( CoreSoftyTable ) and ( type( CoreSoftyTable ) == "table" ) then local CoreSoftyPTableValues = {} local CoreSoftyPTable = {} for i,v in pairs(Table) do function PositionOrdering(CoreSoftyTable, CoreSoftySmaller,CoreSoftyMax) if ( CoreSoftyTable ) and ( type( CoreSoftyTable ) == "table" ) then local CoreSoftyPTableValues = {} local CoreSoftyPTable = {} for i,v in pairs(Table) do CoreSoftyPTableValues[i] = v table.insert(CoreSoftyPTable, v) end if CoreSoftySmaller then table.sort(CoreSoftyPTable, function(a,b) return a>b end) else table.sort(CoreSoftyPTable) end CoreSoftyTableReturn = {} for i,v in ipairs(CoreSoftyPTable) do for k,s in pairs(CoreSoftyPTableValues) do if v == s then CoreSoftyTableReturn[k] = i break end end end if not CoreSoftyMax then return CoreSoftyTableReturn else local CoreSoftycount = 0 CoreSoftyTableReturn2 = {} for i,v in pairs(CoreSoftyTableReturn) do if CoreSoftycount >= CoreSoftyMax then break end CoreSoftyTableReturn2[i] = v CoreSoftycount = CoreSoftycount + 1 end return CoreSoftyTableReturn2 end else return false end end
-
Guys should i add this to useful functions? I've not tested it yet, so if anyone finds something wrong, please tell me. Idea: Give a table with Names and Values, and return a table ordered from smalller to bigger or bigger to smaller (by default smaller to bigger) and with a limit (If specified Max = 3 then table returned would only contain the 3 smallest or biggest.) Usage: UnOrderedTable = {} OrderedTable = PositionOrdering(UnOrderedTable, true, 5) Would return: A table ordered from biggest to smallest with a limit of 5. And finally, the function: function PositionOrdering(Table, Smaller,Max) if ( Table ) and ( type( Table ) == "table" ) then PTableValues = {} PTable = {} for i,v in pairs(Table) do PTableVales[i] = v table.insert(PTable, v) end if Smaller == true then table.sort(PTable, function(a,b) return a>b end) else table.sort(PTable) end TableReturn = {} for i,v in ipairs(PTable) do for k,s in pairs(PTableValues) do if v == s then TableReturn[k] = i break end end end if not Max then return TableReturn else count = 0 TableReturn2 = {} for i,v in pairs(TableReturn) do if count >= Max then break end TableReturn2[i] = v count = count + 1 end return TableReturn2 end else return false end end
-
Te paso a mostrar y explicar como lo hago en mi script de BF3: function DeployMetClick(button, state) if state == "up" then -- Solo se activa al hacer click (y no tambien al soltarlo) return -- Si esta siendo soltado, cancelar. end local CursorX, CursorY = getCursorPosition() -- Posicion Del mouse if CursorX > 0.79 and CursorY > 0.917 then -- Si esta dentro de X,Y coordenadas if CursorX < 0.96 and CursorY < 0.96 then -- Si esta dentro de X,Y coordenadas Deploy() -- llamar la funcion Deploy fadeCamera(true, 1) -- Ocultar camara outputConsole("DEPLOYED") -- Tirar a consola del cliente "DEPLOYED" end end end addEventHandler("onClientClick", getRootElement(), DeployMetClick)
-
Guys, if anyone need it, i solved it this way, not sure if it is efficient thought: PTableValues = {} PTableValues["PlayerA"] = 50 PTableValues["PlayerB"] = 45 PTableValues["PlayerC"] = 55 PTable = {} table.insert(PTable, 50) table.insert(PTable, 45) table.insert(PTable, 55) table.sort(PTable, function(a,b) return a>b end) for i,v in ipairs(PTable) do for k,s in pairs(PTableValues) do if v == s then outputServerLog("Player: "..k.." is Pos: "..i.." with value "..s .."/"..v) end end end EDIT: This will only return the last player, why? PTableValues = {} PTableValues["PlayerA"] = 50 PTableValues["PlayerB"] = 45 PTableValues["PlayerC"] = 55 PTable = {} table.insert(PTable, 50) table.insert(PTable, 45) table.insert(PTable, 55) table.sort(PTable, function(a,b) return a>b end) for i,v in ipairs(PTable) do for k,s in pairs(PTableValues) do if v == s then TableReturn = {} TableReturn[k] = i end end end for i,v in pairs(TableReturn) do outputServerLog("Player: "..i.." is pos: "..v) end
-
PTable = {} table.insert(PTable, 50) table.insert(PTable, 45) table.insert(PTable, 55) table.sort(PTable, function(a,b) return aend) for i,v in ipairs(PTable) do outputServerLog("Player: "..i.." Value:" .. v) end Did it like this and it did sorted it, but Smallest > Bigger. PD: How can i return players if i must use indexed tables?
-
Did a quick test: PTable = {} PTable["Player1"] = 50 PTable["Player2"] = 45 PTable["Player3"] = 55 table.sort(PTable, function(a,b) return aend) for i,v in pairs(PTable) do outputServerLog("Player: "..i.." Value:" .. v) end It only outputed the table normally...
-
Guys, i cant access http://www.lua.org, is this just me, or is it down?
-
Hey Guys, how could i do a math arrangement? Lets say i get player table: PTable = {} PTable[Player1] PTable[Player2] PTable[Player3] Now, each player has an element data. (Or value assigned) PTable = {} PTable[Player1] = 50 PTable[Player2] = 45 PTable[Player3] = 55 Now, how can i order them in order to be from biggest to smallest? PTable = {} PTable[Player3] = 55 PTable[Player1] = 50 PTable[Player2] = 45 Thanks HyPeX PD: Thought about something with math.max, but idk if there's a shorter way.
-
I'd go with onPlayerWasted instead..
-
Hey guys, how could i clone a function down?? Should it be like this? MySetAccountData = setAccountData i also thought about this, but could be harder and longer: function MySetAccountData(acc, data, val) local Return = setAccountData(acc, data, val) return Return end Thanks HyPeX
-
I'll do that once i need to lower down script consuption, and when its ready, for now i prefer easy understading and quick work. Thanks anyways.
-
I'll do that once i need to lower down script consuption, and when its ready, for now i prefer easy understading and quick work. Thanks anyways.
-
Woops.. carefully reading found this in the middle of the BF3_Core_S script.. i didnt remember to add it thought.. function SetTeamValues() local deaths = 0 local kills = 0 local headshots = 0 local score = 0 for i,v in ipairs(getPlayersInTeam(ATeam)) do kills = getElementData(v, "Kills") deaths = getElementData(v, "Deaths") headshots = getElementData(v, "Headshots") score = kills * 100 end setElementData(ATeam, "Kills","#0046C8Total: "..kills) setElementData(ATeam, "Deaths", "#0046C8Total: "..deaths) setElementData(ATeam, "Headshots", "#0046C8Total: "..headshots) setElementData(ATeam, "Score", "#0046C8Total: "..score) setElementData(ATeam, "FPS", "-") setElementData(ATeam, "Ping", "-") setElementData(ATeam, "Country", "-") end function SetTeamValues2() local deaths = 0 local kills = 0 local headshots = 0 local score = 0 for i,v in ipairs(getPlayersInTeam(BTeam)) do local kills = getElementData(v, "Kills") local deaths = getElementData(v, "Deaths") local headshots = getElementData(v, "Headshots") local score = kills * 100 end setElementData(BTeam, "Kills", "#0046C8Total: "..kills) setElementData(BTeam, "Deaths", "#0046C8Total: "..deaths) setElementData(BTeam, "Headshots", "#0046C8Total: "..headshots) setElementData(BTeam, "Score", "#0046C8Total: "..score) setElementData(BTeam, "FPS", "-") setElementData(BTeam, "Ping", "-") setElementData(BTeam, "Country", "-") end timer = setTimer(SetTeamValues, 1000,0) timer = setTimer(SetTeamValues2, 1000,0) Guess its fixed
-
No, i checked all over, i'm even setting it off on clientRender, it should atleast make some blurring.. EDIT: Just did it with onClientPreRender (And somehow it worked.)
-
Well, i cant simply make it go away, only by doing /showhud inside the game.. function SpawnPlayerToLobby(player,cmd) if source then showPlayerHudComponent(source, "all", false) takeAllWeapons(source) local source = source if not isPedDead(source) then killPed(source) end spawnPlayer(source, 584.79998779297, -2015.4000244141, 1.3999999761581, 180) setPlayerTeam(source, Lobby) outputChatBox("#006677[bF3]: Type in /help to see all commands!", source,255,255,255,true) setElementData(source, "State", "Lobby") setCameraTarget(source, source) fadeCamera(source, true) end if isElement(player) and getElementType(player) == "player" then local player = player if not isPedDead(player) then killPed(player) end takeAllWeapons(player) spawnPlayer(player, 584.79998779297, -2015.4000244141, 1.3999999761581, 180) setPlayerTeam(player, Lobby) setElementData(player, "State", "Lobby") setCameraTarget(player,player) fadeCamera(player, true) outputChatBox("#006677[bF3]: Type in /cmd to see all commands!", player,255,255,255,true) end end addEventHandler("onPlayerLogin", getRootElement(), SpawnPlayerToLobby) addCommandHandler("Lobby", SpawnPlayerToLobby)
-
EDIT: Found the problem, it wasnt actually one, it was just during joining becouse i wasnt assigned to any team (:L)
-
Nothing much, a radar function i'm looking at and trying to make to only own team. addEventHandler("onClientRender", getRootElement(), function() showPlayerHudComponent("radar", false) local px, py, pz = getElementPosition(lp) local pr = getPedRotation(lp) local cx,cy,_,tx,ty = getCameraMatrix() local north = findRotation(cx,cy,tx,ty) dxDrawImage(posx,posy,height,height, "img/radar.png") dxDrawImage(posx,posy,height,height, "img/north.png", north) for id, player in ipairs(getPlayersInTeam(getPlayerTeam(getLocalPlayer()))) do if player ~= lp then local _,_,rot = getElementRotation(player) local ex, ey, ez = getElementPosition(player) local dist = getDistanceBetweenPoints2D(px,py,ex,ey) if dist > range then dist = tonumber(range) end local angle = 180-north + findRotation(px,py,ex,ey) local cblipx, cblipy = getDistanceRotation(0, 0, height*(dist/range)/2, angle) local blipx = centerleft+cblipx-blipsize/2 local blipy = centertop+cblipy-blipsize/2 local yoff = 0 local r,g,b,a = 255,255,255,255 if getPlayerTeam(player) then r,g,b = getTeamColor( getPlayerTeam(player) ) end local img = "img/blip.png" if (ez - pz) >= 5 then img = "img/blipup.png" elseif (ez - pz) <= -5 then img = "img/blipdown.png" end dxDrawImage(blipx, blipy, blipsize, blipsize, img, north-rot+45, 0, 0, tocolor(r,g,b,a)) end end dxDrawImage(centerleft - lpsize/2, centertop - lpsize/2, lpsize,lpsize, "img/local.png", north-pr) end ) Pd: local lp = getLocalPlayer() Pd2: Debug: Error in line: Bad Argument @getPlayersInTeam Error in line: bad argument to #1 ipairs (table expected, got boolean)
-
Yeah, (i'm the only sole guy in the sv, i disconnect and when i come back its gone to 0)
-
Help guys, what i'm doing wrong? for id, player in ipairs(getPlayersInTeam(getPlayerTeam(getLocalPlayer()))) do
-
Hey guys, i'm setting an ElementData to a team upon me killing someone, and if i suicide its -1. But i reconnected and the data is lost. (All this data setting is done server-side). Any idea why is it lost? (The team is never deleted) Thanks HyPeX
-
i got the values directly from my ingame function wich returns mouse X:Y, i'll check again.. EDIT: Got it, there's an extra 0, it should be 0.1367, not 0.01367.
