Jump to content

IIYAMA

Moderators
  • Posts

    6,063
  • Joined

  • Last visited

  • Days Won

    208

Everything posted by IIYAMA

  1. You sure they are integer values? Because they look more like floats to me. if elementMoney == itemMoney then And what is this result? Maybe the tonumber has something to with it. if tonumber(tostring(elementMoney)) == tonumber(tostring(itemMoney)) then And this?
  2. Why don't you take first inspiration of systems that use a SQL DB? Here you have a system that saves data based on serials: (SQL) https://community.multitheftauto.com/in ... ls&id=6313 And here you have a system that bans players: (SQL) https://community.multitheftauto.com/in ... ls&id=1670 Both are using a SQL database, enough inspiration if you ask me.
  3. optimization(handle more accounts), web related(mysql), multiple servers using one db(mysql), saving non account related data, easier to move database to a new server, etc.
  4. "onClientRender" getTickCount interpolateBetween setCameraMatrix
  5. This should do it. items = { {1337,1356.69360,1546.84326,10.82031}, {1337,1356.59802,1536.86560,10.8203}, {1337,1368.62585,1547.30847,10.82031} } function spawnLoot() local items = deepcopy(items) -- copy the table, so we can edit it without editing the original. for i=1, math.max(math.random(#items), math.ceil(#items*0.3)) do -- minimal 30% of the items count = 0.3. local randomItemIndex = math.random ( #items ) local objectID, x, y, z = unpack ( items[randomItemIndex]) table.remove(items, randomItemIndex) -- remove it, so you don't duplicate item/spawnpoint. createObject ( objectID,x,y,z,0,0,0) end end addEventHandler ( "onResourceStart", resourceRoot, spawnLoot) -- don't use the ROOTELEMENT! But resourceRoot! Swapped the table.remove line, with the table unpack line.
  6. function deepcopy(orig) local orig_type = type(orig) local copy if orig_type == 'table' then copy = {} for orig_key, orig_value in next, orig, nil do copy[deepcopy(orig_key)] = deepcopy(orig_value) end setmetatable(copy, deepcopy(getmetatable(orig))) else -- number, string, boolean, etc copy = orig end return copy end http://lua-users.org/wiki/CopyTable items = { {1337,1356.69360,1546.84326,10.82031}, {1337,1356.59802,1536.86560,10.8203}, {1337,1368.62585,1547.30847,10.82031} } function spawnLoot() local items = deepcopy(items) -- copy the table, so we can edit it without editing the original. for i=1, math.max(math.random(#items), math.ceil(#items*0.3)) do -- minimal 30% of the items count = 0.3. local randomItemIndex = math.random ( #items ) table.remove(items, randomItemIndex) -- remove it, so you don't duplicate item/spawnpoint. local objectID, x, y, z = unpack ( items[randomItemIndex]) createObject ( objectID,x,y,z,0,0,0) end end addEventHandler ( "onResourceStart", resourceRoot, spawnLoot) -- don't use the ROOTELEMENT! But resourceRoot!
  7. Every ped has his own behaviour, that's why it has to be complexer to prevent desync in multiplayer. But if it works for you Enjoy it!
  8. This is as far I go, study the code well and do you benefit with it. It is not tested, but this is one of the better ways to make it. local thisResourceDynamicRoot = getResourceDynamicElementRoot(getThisResource()) local spottedData = {} -- prevent data overuse. addEventHandler("onClientRender", root, function () local playerX, playerY, playerZ = getElementPosition(localPlayer) local peds = getElementsByType("ped", thisResourceDynamicRoot, true) local pedsSpottedPlayer = {} for i=1,#peds do local ped = peds[i] local pedX, pedY, pedZ = getElementPosition(ped) if not spottedData[ped] and getDistanceBetweenPoints3D(playerX, playerY, playerZ, pedX, pedY, pedZ) < 20 then spottedData[ped] = true pedsSpottedPlayer[#pedsSpottedPlayer+1] = ped end end if #pedsSpottedPlayer > 0 then triggerServerEvent("spottedByPed",localPlayer,pedsSpottedPlayer,true) end end) addEventHandler("onClientElementStreamOut",thisResourceDynamicRoot, function () if spottedData[source] then spottedData[source] = nil triggerServerEvent("spottedByPed",localPlayer,{ped},false) end end) addEvent("spottedByPed",true) addEventHandler("spottedByPed",root, function (peds, spottedStatus) if client == source and isElement(source) then -- validate. --local player = source end end)
  9. What the f.u.c.k. are you doing? How hard is it to follow a few instructions and letting go from your old code?
  10. There is always one spawnpoint? local pSpawnPoint = getElementsByType( "spawnpoint" ) if pSpawnPoint[1] then pSpawnPoint = pSpawnPoint[1] -- -- code -- -- code -- end
  11. Don't merge it with the code you already had, start over from scratch. Using the event onClientRender.
  12. First start with detecting if a ped should attack the localplayer. When to detect? [url=https://wiki.multitheftauto.com/wiki/OnClientRender]https://wiki.multitheftauto.com/wiki/OnClientRender[/url] How to detect? (simple version) [url=https://wiki.multitheftauto.com/wiki/GetElementPosition]https://wiki.multitheftauto.com/wiki/GetElementPosition[/url] > player [url=https://wiki.multitheftauto.com/wiki/GetElementsByType]https://wiki.multitheftauto.com/wiki/GetElementsByType[/url] > ped -- loop [url=https://wiki.multitheftauto.com/wiki/GetElementPosition]https://wiki.multitheftauto.com/wiki/GetElementPosition[/url] > ped [url=https://wiki.multitheftauto.com/wiki/GetDistanceBetweenPoints3D]https://wiki.multitheftauto.com/wiki/Ge ... enPoints3D[/url] > compare distance between player and ped
  13. IIYAMA

    Save

    https://wiki.multitheftauto.com/wiki/Xml Save: https://wiki.multitheftauto.com/wiki/XmlCreateFile https://wiki.multitheftauto.com/wiki/XmlCreateChild https://wiki.multitheftauto.com/wiki/XmlNodeSetValue https://wiki.multitheftauto.com/wiki/XmlSaveFile https://wiki.multitheftauto.com/wiki/XmlUnloadFile Load: https://wiki.multitheftauto.com/wiki/FileExists https://wiki.multitheftauto.com/wiki/XmlLoadFile https://wiki.multitheftauto.com/wiki/XmlFindChild https://wiki.multitheftauto.com/wiki/XmlNodeGetValue https://wiki.multitheftauto.com/wiki/XmlUnloadFile keep it safe, some people use the same passwords > https://wiki.multitheftauto.com/wiki/Sha256
  14. In my opinion, resourceRoot is the best solution when you send a trigger to all players.
  15. Where are your debug lines? .............................................................................................................................................................. Not even one? source: http://focusedshooter.com/2015/05/25/ge ... -so-wrong/ function trigger2(t) local name = getPlayerName(source) outputDebugString("serverside name: " .. name .. ", t: " .. t) -- debug triggerClientEvent("addone2",resourceRoot,name,t) end addEventHandler("onPlayerQuit",root,trigger2) function addOnQuit(n,t) outputDebugString("clientside n: " .. n .. ", t: " .. t) -- debug table.insert(joins,{name = n, ty = t}) setTimer(delete2,3000,1,n,t) end addEvent("addone2",true) addEventHandler("addone2",root,addOnQuit) function draw() -- local joinersCount = 0 -- debug local quitersCount = 0 -- debug -- for i=1,#joins do if joins[i].ty then local ty = joins[i].ty dxDrawImage(10,(sy/2)+(i*10),16,16,"images/quit.png") dxDrawText(joins[i].n.." left the game. ["..ty.."]",30,(sy/2)+(i*10)+3,nil,nil,tocolor(255,255,255,255),1,"default-bold") -- quitersCount = quitersCount+1 -- debug -- else local name = joins[i].name dxDrawImage(10,(sy/2)+(i*10),16,16,"images/join.png") dxDrawText(name.." joined the game.",30,(sy/2)+(i*10)+3,nil,nil,tocolor(255,255,255,255),1,"default-bold") -- joinersCount = joinersCount+1 -- debug -- end end -- dxDrawText("joinersCount: " .. joinersCount .. ", quitersCount: " .. quitersCount, 300, 300) -- debug -- end addEventHandler("onClientRender",root,draw) function delete2(n,t) for i=1,#joins do if joins[i].name == n and joins[i].ty == t then outputDebugString("item found and will be removed from table, n: " .. n .. ", t: " .. t) -- debug table.remove(joins,i) break -- BREAK IT!!!! OMG!!!!!!!!!!!!!!!!!!!!!!!!!! end end end
  16. I am not going to create large global examples for your code. You are the one that has to convert this information in to a script or at least trying to do so. And I am willing to help you with that, but you have to take those first steps.
  17. Script 75% at serverside and 25% clientside. Serverside decides which player a ped should attack, not the client. The client should only give the server the required data, so that serverside can make the right decision. The basic:
  18. Because it is most likely stolen if it is not on the community... With other words, it is not on the community because he didn't want other people to have it. So... stolen and leaked. If you want to use and edit leaked scripts, enjoy yourself. But don't be so disrespectful with somebody else his code and ask permission first.
  19. while is a kind of statement for a while loop. A loop is for executing the same code multiple times. and a break is for stopping an active loop. But you should not worry so much about those two. The while loop isn't required often, just once in a while under some circumstances.
  20. Those errors are obvious... You should first ask permission from the owner, because this resource is afaik not on the community. Also you need permission from the owner to show this code to the public.
  21. If you understand shaders, YES else NO.
  22. I don't work with oop and that repeat loop is required, because you never know which element is the resourceRoot. local elementParent = vehicle -- < add here the element. repeat local elementParent_ = getElementParent ( elementParent ) if elementParent_ and elementParent_ ~= root then elementParent = elementParent_ else elementParent_ = nil end until not elementParent_ local theResourceRoot = elementParent local theResourceName = getElementID(theResourceRoot) -- get the resource name. local resource = getResourceFromName(theResourceName) -- get the resource element.
  23. local theResourceRoot = --... resourceRoot from another resource ... local theResourceName = getElementID(theResourceRoot) -- get the resource name. local resource = getResourceFromName(theResourceName) -- get the resource element.
  24. This might be your problem: http://www.lotrointerface.com/forums/sh ... php?t=3502
×
×
  • Create New...