Jump to content

myonlake

Members
  • Posts

    2,312
  • Joined

  • Days Won

    41

Everything posted by myonlake

  1. This should work unless I made some kind of weird mistake. Remember to add the sound files in your meta.xml file and make sure the path is correct with the table's paths. Client-side local sounds = {"sounds/1.wav", "sounds/2.wav"} addEvent("onPlayerTrueJoin", true) addEventHandler("onPlayerTrueJoin", root, function() playSound(sounds[math.random(1, #sounds)], false) end ) Server-side addEventHandler("onPlayerJoin", root, function() triggerClientEvent(source, "onPlayerTrueJoin", source) end )
  2. Or just don't even bother using Valhalla. Everybody hates fakes.
  3. myonlake

    Server list spam

    Two more -.- mtasa://199.168.139.190:22008 mtasa://198.245.62.127:22008
  4. myonlake

    DELETED

    When the player logs in, set element data to the player to mark that he is an administrator. Client-side doesn't understand ACL or account data, so you have to work with element data during the time being. setElementData getElementData When the player jumps or executes the jump function, make it so that it checks if the player is in administrator team.
  5. myonlake

    Server list spam

    199.168.139.190:22008 Fake ROOTGAMING server redirecting to some old Valhalla Gamemode server, please blacklist and ban this, thank you. http://puu.sh/QEof
  6. Skin mod: https://community.multitheftauto.com/index.php?p= ... ls&id=5398 DONE
  7. Skin mod: https://community.multitheftauto.com/index.php?p= ... ls&id=2088 https://community.multitheftauto.com/index.php?p= ... ls&id=1545 DONE
  8. You cannot have animation files in the current version of Multi Theft Auto.
  9. addEventHandler("onClientGUIClick", getRootElement(), hideGUI2) getRootElement() is not a GUI element, it is the root. You need to define the GUI element over root, and remember to add "false" argument in the end, so it only accepts the GUI element you entered. So the fix would be: function hideGUI2() guiSetVisible (window,false) showCursor(false) end addEventHandler("onClientGUIClick", button2, hideGUI2, false) Simpler way is this: function showGUI2() guiSetVisible(window, true) showCursor(true) end addEventHandler("onClientGUIClick", button2, function() showCursor(false) guiSetVisible(window, false) end, false)
  10. I will edit this post with an example that will show you what I am meaning. You just don't get it. EDIT: This will only output one data value into the gridlist. The reason why it is doing it, is because the for-loop is going through all vehicles with the data "testing", and the functions after the for-loop make as many vehicles with data "testing" as many vehicles there are in the game (before the actual for-loop, the script makes 20 vehicles so you see that it doesn't work). So the problem is, how can I prevent the functions to be executed during/before the for-loop. Gosh, how had it is to understand this plain English? addCommandHandler("tests", function(cmd) triggerEvent("onReloadRequested", localPlayer) end ) addEvent("onReloadRequested", true) addEventHandler("onReloadRequested", root, function() for i=1,20 do local vehicle = createVehicle(406, 0, 0, 3, 0, 0, 0) setElementCollisionsEnabled(vehicle, false) end for i,v in ipairs(getElementsByType("vehicle")) do for key,value in ipairs(getElementsByType("vehicle")) do if getElementData(value, "testing") then destroyElement(value) end end local vehicle = createVehicle(406, 2493.94, -1668.34, 13.34, 0, 0, 0) setElementCollisionsEnabled(vehicle, false) setElementFrozen(vehicle, true) setElementData(vehicle, "testing", math.random(0, 100)) runBoard() end end ) function runBoard() if isElement(g_runboard_gridlist) then destroyElement(g_runboard_gridlist) end g_runboard_gridlist = guiCreateGridList(49, 401, 295, 359, false) guiGridListSetSelectionMode(g_runboard_gridlist, 0) guiSetAlpha(g_runboard_gridlist, 0.9) local column = guiGridListAddColumn(g_runboard_gridlist, "Information", 0.92) for i,v in ipairs(getElementsByType("vehicle")) do if getElementData(v, "testing") then local row = guiGridListAddRow(g_runboard_gridlist) guiGridListSetItemText(g_runboard_gridlist, row, column, getElementData(v, "testing"), false, false) end end end So... -- BEFORE the functions are executed below for key,value in ipairs(getElementsByType("vehicle")) do if getElementData(value, "testing") then destroyElement(value) end end -- AFTER the for-loop has digged all the data local vehicle = createVehicle(406, 2493.94, -1668.34, 13.34, 0, 0, 0) setElementCollisionsEnabled(vehicle, false) setElementFrozen(vehicle, true) setElementData(vehicle, "testing", math.random(0, 100)) runBoard() -- Shows only one data value, because the vehicles created after the for-loop are deleted because for-loop is digging.
  11. What I mean with MTA Lua is Lua within MTA. I think you didn't read my post. I quite clearly said that the functions after for-loop get executed before for-loop as gone through all the data. You don't need my code to know what's the problem, because the script is working perfectly, the problem is in that part. And you can only just explain me how and what should I do. For example, think that you're currently making a sandwich. You eat it before it's finished. I want to eat it after it's finished.
  12. As AMARANT told you already... getPlayerAccount setAccountData getAccountData
  13. https://wiki.multitheftauto.com/wiki/Dxscoreboard
  14. Edited your code a bit smaller, not sure if it'll work or anything, but give it a try. No need to make a bunch of lines when you can instead just make one table. Try this first, and if it gives an error, try the other one. local classGroups = {} local spawning = { [1] = {"165, 286", "SPECIALUNITS"}, [2] = {"285", "SWAT"}, [3] = {"287, 312", "MF"}, [4] = {"294", "SPECIALFORCES"}, [5] = {"153, 211", "STAFF"}, [6] = {"30", "CLO"}, [7] = {"122", "NINJA"}, [8] = {"29, 115", "SoA"}, [9] = {"165, 164", "MIB"} } addEvent("spawn_clientRequestSpawn", true) addEventHandler("spawn_clientRequestSpawn", root, function(categoryIndex, classIndex, skinIndex) if skinIndex then local class = classGroups[categoryIndex].classes[classIndex] local skin = class.skinMngr.skins[skinIndex] local spawn = true local spawned --[[if not classGroups[cetegoryIndex].owner then -- if there is NO owner of the clan/gang spawn player spawn = true else -- if there IS owner of the clan/gang then check if he's member of the clan/gang end]] for i,v in ipairs(spawning) do if (skin.modelId == (string.find(spawning[i][1], ", ") and spawning[i][1]:gsub(", ", " or ") or spawning[i][1])) and (not isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(client)), aclGetGroup (spawning[i][2])))) then spawn = false else spawn = true break end end end if spawn then if not class.team then class.team = createTeam(class.name, class.color.red, class.color.green, class.color.blue) end local plrTeam = getPlayerTeam(client) if ((plrTeam) and (plrTeam ~= class.team) and (countPlayersInTeam(plrTeam) == 1)) then destroyElement(plrTeam) end spawned = spawnPlayer( client, skin.spawnLoc.x, skin.spawnLoc.y, skin.spawnLoc.z, skin.spawnLoc.rot, skin.modelId, 0, 0, class.team ) end if spawned then setElementData(client, "team", class.name) fadeCamera(client, true) setCameraTarget(client, client) setTimer(setCameraTarget, 200, 1, client, client) triggerClientEvent(client, "spawn_SpawnedSuccessfully", client) --setPlayerMoney(client, 500) for _, weapon in ipairs(class.weaponMngr.weapons) do giveWeapon(client, weapon.id, weapon.ammo, false) end createBlipAttachedTo(client, 0, 2, class.color.red, class.color.green, class.color.blue) else triggerClientEvent(client, "spawn_FailedToSpawn", client) if countPlayersInTeam(class.team) == 0 then destroyElement(class.team) class.team = nil; end end end ) addEventHandler("onPlayerSpawn", root, function() end ) addEventHandler("onPlayerWasted", root, function() fadeCamera(source, false, 4) setTimer(requestMenu, 5000, 1, source) deleteAllPlayerBlips(source) end ) function requestMenu(player) callClientFunc(player, "showSpawnMenu", true, true) callClientFunc(player, "classSelected") end addCommandHandler("kill", function(plr) killPed(plr) end ) function preloadClassesInfo() local groups = getElementsByType("category") for _, group in ipairs(groups) do table.insert(classGroups, Group:New(group)) end end addEventHandler("onResourceStart", resourceRoot, preloadClassesInfo) function deleteAllPlayerBlips(player) local elements = getAttachedElements(player) if (elements) then for i, element in ipairs(elements) do if (getElementType(element) == "blip") then destroyElement(element) end end end print("number of players in team: " .. tostring(countPlayersInTeam(getPlayerTeam(player))) end addEventHandler("onPlayerQuit", root, deleteAllPlayerBlips) function callClientFunc(player, funcName, ...) if #{...} ~= 0 then triggerClientEvent(player, "_clientCallFunction", root, funcName, ...) else triggerClientEvent(player, "_clientCallFunction", root, funcName) end end addEvent("_serverCallFunction", true) addEventHandler("_serverCallFunction", root, function(funcName, ...) _G[funcName](...) end ) local classGroups = {} local spawning = { [1] = {"165, 286", "SPECIALUNITS"}, [2] = {"285, 285", "SWAT"}, [3] = {"287, 312", "MF"}, [4] = {"294, 294", "SPECIALFORCES"}, [5] = {"153, 211", "STAFF"}, [6] = {"30, 30", "CLO"}, [7] = {"122, 122", "NINJA"}, [8] = {"29, 115", "SoA"}, [9] = {"165, 164", "MIB"} } addEvent("spawn_clientRequestSpawn", true) addEventHandler("spawn_clientRequestSpawn", root, function(categoryIndex, classIndex, skinIndex) if skinIndex then local class = classGroups[categoryIndex].classes[classIndex] local skin = class.skinMngr.skins[skinIndex] local spawn = true local spawned --[[if not classGroups[cetegoryIndex].owner then -- if there is NO owner of the clan/gang spawn player spawn = true else -- if there IS owner of the clan/gang then check if he's member of the clan/gang end]] for i,v in ipairs(spawning) do if (skin.modelId == spawning[i][1]:gsub(", ", " or ")) and (not isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(client)), aclGetGroup (spawning[i][2])))) then spawn = false else spawn = true break end end end if spawn then if not class.team then class.team = createTeam(class.name, class.color.red, class.color.green, class.color.blue) end local plrTeam = getPlayerTeam(client) if ((plrTeam) and (plrTeam ~= class.team) and (countPlayersInTeam(plrTeam) == 1)) then destroyElement(plrTeam) end spawned = spawnPlayer( client, skin.spawnLoc.x, skin.spawnLoc.y, skin.spawnLoc.z, skin.spawnLoc.rot, skin.modelId, 0, 0, class.team ) end if spawned then setElementData(client, "team", class.name) fadeCamera(client, true) setCameraTarget(client, client) setTimer(setCameraTarget, 200, 1, client, client) triggerClientEvent(client, "spawn_SpawnedSuccessfully", client) --setPlayerMoney(client, 500) for _, weapon in ipairs(class.weaponMngr.weapons) do giveWeapon(client, weapon.id, weapon.ammo, false) end createBlipAttachedTo(client, 0, 2, class.color.red, class.color.green, class.color.blue) else triggerClientEvent(client, "spawn_FailedToSpawn", client) if countPlayersInTeam(class.team) == 0 then destroyElement(class.team) class.team = nil; end end end ) addEventHandler("onPlayerSpawn", root, function() end ) addEventHandler("onPlayerWasted", root, function() fadeCamera(source, false, 4) setTimer(requestMenu, 5000, 1, source) deleteAllPlayerBlips(source) end ) function requestMenu(player) callClientFunc(player, "showSpawnMenu", true, true) callClientFunc(player, "classSelected") end addCommandHandler("kill", function(plr) killPed(plr) end ) function preloadClassesInfo() local groups = getElementsByType("category") for _, group in ipairs(groups) do table.insert(classGroups, Group:New(group)) end end addEventHandler("onResourceStart", resourceRoot, preloadClassesInfo) function deleteAllPlayerBlips(player) local elements = getAttachedElements(player) if (elements) then for i, element in ipairs(elements) do if (getElementType(element) == "blip") then destroyElement(element) end end end print("number of players in team: " .. tostring(countPlayersInTeam(getPlayerTeam(player))) end addEventHandler("onPlayerQuit", root, deleteAllPlayerBlips) function callClientFunc(player, funcName, ...) if #{...} ~= 0 then triggerClientEvent(player, "_clientCallFunction", root, funcName, ...) else triggerClientEvent(player, "_clientCallFunction", root, funcName) end end addEvent("_serverCallFunction", true) addEventHandler("_serverCallFunction", root, function(funcName, ...) _G[funcName](...) end )
  15. You had some unnecessary functions over there, and it didn't work because getElementID() isn't a name of a player (use getPlayerName()), you don't need to use getPlayerFromName() when you already have the source defined. In my opinion the script is anyways a mess, perhaps you should try to make your own. addEventHandler("onVehicleExplode", root, function() if isGuestAccount(getPlayerAccount(getVehicleController(source))) then return end setAccountData(getPlayerAccount(getVehicleController(source)), "hisCar", nil) end )
  16. myonlake

    Help plzzz

    Yeah, right That should work - but I haven't tested it. At least one of my gamemodes is using that kind of method and it works.
  17. about the car ,, i think you should use https://wiki.multitheftauto.com/wiki/Ser ... _functions and about health use https://wiki.multitheftauto.com/wiki/GetAccountData https://wiki.multitheftauto.com/wiki/SetAccountData im confused about the SQL_funcs. Explain plz viewtopic.php?f=148&t=38203
  18. Can you give me a MTA Lua example of coroutines. I rather would like MTA example instead of lua.org. I didn't know timers work with for-loops, because the timer is triggered the same way as before, it only just timers it.
  19. Also, just saying. Models are integers. When you try to compare a string with an integer, it will return an error. Then again when you try to output a message, which tells you your location, you don't need to separately mark them as floats/integers in general, because the message will always return a string, so adding tostring() or tonumber() won't affect anything. What you have there is the first thing I told you, which is trying to compare a string with an integer. So as solidsnake already advised you to do, is to add the string (quotation marks). It's logical and interesting afterall. Good luck!
  20. myonlake

    Help plzzz

    I don't think it's possible to make it correct for all, since if a developer uses the highest resolution, all the resolutions below will see it differently even if you minused the screen width and height. I am sorry, but I am on my phone and can't browse the codes you have, but this is an example of how it should display a welcome text near the right top on all resolutions. local screenX, screenY = guiGetScreenSize() function dx_welcome() dxDrawText("Welcome", screenX - 50, 30, 50, 30, 1.0, "bankgothic", "left", "top", false, false, false) setTimer(function() removeEventHandler("onClientRender", root, dx_welcome) end, 4 * 1000, 1) end addEventHandler("onClientRender", root, dx_welcome) Not tested, typos are possible.
  21. Yeah. /createinterior <0=gov, 1=house, 2=biz> It has to be a house or business to make it purchaseable if I remember right. Go on the pickup icon and hit Enter if you have enough money to buy the interior.
  22. Hey, I am just wondering, as I can't remember how it was done; how to make a function that will execute after the for loop has gone through everything. Currently I am doing like the following, and it doesn't work, and yes, I know the reason, but I am not sure how I can fix it so that it doesn't trigger before for loop as went through all the data. Anything else I should use or..? -- Loop here for i,v in ipairs(getElementsByType("vehicle")) do if getElementData(v, "example") then -- Do something end end -- Function here How should I organize it, or what should I do differently? That was just an example snippet by the way.
  23. function createSpeaker(thePlayer) local x, y, z = getElementPosition(thePlayer) car = createVehicle(470, x, y, z-1) speakerObject = createObject(2229, x, y, z-1) attachElements(speakerObject, car, 0, 0, 2) outputChatBox("Succesfully created a speaker!", thePlayer, 0, 250, 0) triggerClientEvent(root, "playTheSound", root, x, y, z, speakerObject) end addCommandHandler("placespeaker", createSpeaker) function deleteSpeaker(thePlayer) if (isElement(speakerObject)) then destroyElement(speakerObject) outputChatBox("Succesfully destroyed", thePlayer, 0, 250, 0) triggerClientEvent("stopTheSound", root) else outputChatBox("Object is not created.", thePlayer, 250, 0, 0) end end addCommandHandler("destroyspeaker", deleteSpeaker) local url = "http://a.tumblr.com/tumblr_m316nasa2R1rnvv34o1_r1.mp3" function playTheSound(x, y, z, object) sound = playSound3D(url, x, y, z) attachElements(sound, object) end addEvent("playTheSound", true) addEventHandler("playTheSound", root, playTheSound) function stopTheSound(x, y, z) stopSound(sound) end addEvent("stopTheSound", true) addEventHandler("stopTheSound", root, stopTheSound)
  24. It is working perfectly. Tell me what's wrong.
×
×
  • Create New...