Jump to content

JR10

Retired Staff
  • Posts

    2,947
  • Joined

  • Last visited

Everything posted by JR10

  1. Well, you shouldn't do xmlNodeGetAttributes, no you should get one one, using xmlNodeGetAttribute Here: function createVehsFromXML() local xmlfile = xmlLoadFile("veh.xml") for i, node in ipairs(xmlNodeGetChildren(xmlfile)) do local modelid = xmlNodeGetAttribute(node, "modelid") local posx = xmlNodeGetAttribute(node, "posx") local posy = xmlNodeGetAttribute(node, "posy") local posz = xmlNodeGetAttribute(node, "posz") local rotx = xmlNodeGetAttribute(node, "rotx") local roty = xmlNodeGetAttribute(node, "roty") local rotz = xmlNodeGetAttribute(node, "rotz") local plate = xmlNodeGetAttribute(node, "plate") createVehicle(tonumber(modelid), tonumber(posx), tonumber(posy), tonumber(posy), tonumber(rotx), tonumber(roty), tonumber(rotz), plate) end end addEventHandler("onResourceStart", resourceRoot, createVehsFromXML) This should work.
  2. <team name="Team Name" color="#00FF00" tag="[TM]" aclGroup="Moderator" />
  3. Try this: -- CLIENT SIDE local sX, sY = guiGetScreenSize() local locplayer = getLocalPlayer() addEventHandler("onClientPreRender", root, function() local x, y, z = getWorldFromScreenPosition(sX/2, sY/2, 10) local px, py = getElementPosition(locplayer) setPedRotation(locplayer, findRotation(px, py, x, y)) end) function findRotation(x1,y1,x2,y2) local t = -math.deg(math.atan2(x2-x1,y2-y1)) if t < 0 then t = t + 360 end return t end
  4. If i'm right, change 'both' to anything.
  5. Yep, and add as much as you want, to add more teams, in the same form ofc.
  6. In the same file dude, in config.xml.
  7. Put your teams in it, as it says, and the example should help you. like this: <team name="Team Name" color="#00FF00" tag="[TM]" aclGroup="Moderator" required="both" />
  8. local xmlFile = xmlLoadFile("veh.xml") for i, node in ipairs(xmlNodeGetChildren(xmlFile)) do --here this code will happen for each --get the attributes and create your vehicle end
  9. Search for them on the community? -.- here: https://community.multitheftauto.com/index.php?p=resources
  10. hmm?, that's what i posted: --ClientSide addEventHandler("onClientPlayerDamage", root, function(attacker, weapon, bodypart) if weapon == 0 then cancelEvent() end end) if weapon == 0 then
  11. --ClientSide addEventHandler("onClientPlayerDamage", root, function(attacker, weapon, bodypart) if weapon == 0 then cancelEvent() end end)
  12. Something like this: -- CLIENT SIDE local sX, sY = guiGetScreenSize() local x, y, z = getWorldFromScreenPosition(sX/2, sY/2, 10) local px, py = getElementPosition(getLocalPlayer()) setPedRotation(getLocalPlayer(), findRotation(px, py, x, y)) function findRotation(x1,y1,x2,y2) local t = -math.deg(math.atan2(x2-x1,y2-y1)) if t < 0 then t = t + 360 end return t end
  13. This will work, but, there is something wrong with the resource, idk what's wrong, because i tested that too, and i tested his whole script file, and it still worked, so i guess it's something in another script file.
  14. Lol???, 1297 1023 and it's relative? And, why you are getting the x, y and you didn't use it.
  15. Well look at this code: string.find("blabla", "bla") string.lower("BLABLA") Which is exactly the same as local str = "blabla" str:find("bla") local str = "BLABLA" str:lower() And here strings tutorial: http://lua-users.org/wiki/StringLibraryTutorial
  16. And: There is no such topic. MTA Scripting Tutorials can be found in the wiki: https://wiki.multitheftauto.com/wiki/Main_Page Learn scripting, and then you can make it yourself.
  17. Something like this: local images = {} for i, image in ipairs(getResourceFiles(getThisResource(), ".png")) do table.insert(images, image) end triggerClientEvent("recieveImagesTable", root, images) function getResourceFiles(resource, ext) local filesTable = {} ext = ext or "" local meta = xmlLoadFile(":"..getResourceName(resource).."/meta.xml") if meta then local i = 0 while xmlNodeGetChildren(meta, i) ~= false do local node = xmlNodeGetChildren(meta, i) local src = xmlNodeGetAttribute (node, "src") if src then if src:lower():find(ext) then table.insert(filesTable, src) end end i = i + 1 end xmlUnloadFile(meta) end return filesTable end
  18. It's unlikely you will get someone to help you for free, why didn't you understand, It's easier than you think, but i bet you didn't read carefully.
  19. filling?, once you made the table no need for filling. You want it random? If so here how you can get a random element from a table: local randomElement = theTable[math.random(#theTable)]
  20. I tested the whole script, and it worked, i don't understand it's not even in the script you posted, because i just tested it and it worked. Here that's what i tested: local skinsForEMI = {183,158,159,160,162,132,136} addEvent("buttonClicked",true) gamemodeStarted = false playersForIMI = {} playersForPOL = {} function setcolor(playerSource) outputChatBox("cona") setPlayerNametagColor(playerSource, 255, 10, 40) end addCommandHandler("nametagcolor", setcolor) function joinHandler(equipa) if (gamemodeStarted == false) then if(equipa == 'imigrante') then table.insert(playersForIMI, source) --setPlayerNametagColor(source, tonumber(205), tonumber(133), tonumber(63)) elseif(equipa == 'police') then table.insert(playersForPOL, source) --setPlayerNametagColor(source, 30, 144, 255) else local numberOfTeam = math.random(2) if numberOfTeam == 1 then table.insert(playersForIMI, source) else table.insert(playersForPOL, source) end end end end addEventHandler("buttonClicked", root, joinHandler) function playerJoin () local name = getPlayerName(source) for i, v in ipairs(getElementsByType("player")) do if (v ~= source) then outputChatBox("[" .. name .. "] has joined the server", v, 255, 64, 64) end end end addEventHandler ( "onPlayerJoin", getRootElement(), playerJoin ) function destroyBlipsWhenPlayerLeavesServer ( quitType) local name = getPlayerName(source) outputChatBox("[" .. name .. "] has left the server [" .. quitType .."]", getRootElement(), 255, 64, 64) if source then local attacheds = getAttachedElements ( source ) if ( attacheds ) then for k,element in ipairs(attacheds) do if getElementType ( element ) == "blip" then destroyElement ( element ) end end end end end addEventHandler ( "onPlayerQuit", getRootElement(), destroyBlipsWhenPlayerLeavesServer ) function colocarDeNoite () setTime ( 1, 0) --setWeather ( 22 ) end addEventHandler ( "onResourceStart", getRootElement(), colocarDeNoite) segundos = 30 timerEnabled = false gamemodeStarted = false local mostrou = false addEvent("checkTwoPlayersOnMode", true) function checkTwoAndNotStartedRunIT () if gamemodeStarted == false then if timerEnabled == false then if(getPlayerCount() >= 1) then setTimer(escreve, 200, 1) triggerClientEvent("canShowGUISPAWN",getRootElement()) mostrou = true else outputChatBox("NOTE: This gamemode need at least 2 players online to start!", source) end else setElementData(source,"secondsRemaining",tostring(segundos)) triggerClientEvent ( source, "showDX", source ) triggerClientEvent(source,"canShowGUISPAWN",source) end else outputChatBox("You will need to wait the gamemode to finish, sorry", source) end end addEventHandler("checkTwoPlayersOnMode", getRootElement(), checkTwoAndNotStartedRunIT) function escreve () timerEnabled = true for i,v in pairs(getElementsByType("player")) do setElementData(v,"secondsRemaining",tostring(segundos)) triggerClientEvent ( v, "showDX", v ) if(mostrou ~= true) then triggerClientEvent(v,"canShowGUISPAWN",v) end end setTimer(countDown,1000,30) end function countDown() segundos = segundos -1 for i,v in pairs(getElementsByType("player")) do setElementData(v,"secondsRemaining",tostring(segundos)) end if segundos == 3 then triggerClientEvent("hadChosenTeam", getRootElement()) end if segundos == 0 then triggerClientEvent ( "hideDX", getRootElement() ) triggerClientEvent("hideSpawnGUI", getRootElement()) timerEnabled = false gamemodeStarted = true if(#playersForIMI==#playersForPOL or #playersForIMI == #playersForPOL + 1 or #playersForPOL == #playersForIMI + 1) then spawn() else outputChatBox("---Gamemode will run auto-balance---", getRootElement(), 255, 64, 64) autobalance() end end end function onStart () timerEnabled = false if(getPlayerCount() >= 2) then removeEventHandler ("checkTwoPlayersOnMode", getRootElement(), checkTwoAndNotStartedRunIT ) setTimer(escreve, 1500, 1) end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), onStart ) function autobalance() if(#playersForIMI - #playersForPOL >= 2) then local sync = false local dif = #playersForIMI - #playersForPOL if(dif % 2 == 0) then while(sync ~= true) do if(#playersForIMI ~= #playersForPOL) then table.insert(playersForPOL, playersForIMI[#playersForIMI]) table.remove(playersForIMI, #playersForIMI) setPlayerTeam ( playersForPOL[#playersForPOL], team_policeSP ) outputChatBox(">>Auto-balance system changed your team!", playersForPOL[#playersForPOL], 255, 64, 64) else sync = true end end spawn() else while(sync ~= true) do if(#playersForIMI ~= #playersForPOL + 1) then table.insert(playersForPOL, playersForIMI[#playersForIMI]) table.remove(playersForIMI, #playersForIMI) setPlayerTeam ( playersForPOL[#playersForPOL], team_policeSP ) outputChatBox(">>Auto-balance system changed your team!", playersForPOL[#playersForPOL], 255, 64, 64) else sync = true end end spawn() end elseif(#playersForPOL - #playersForIMI >= 2) then local sync = false local dif = #playersForPOL - #playersForIMI if(dif % 2 == 0) then while(sync ~= true) do if(#playersForPOL ~= #playersForIMI) then table.insert(playersForIMI, playersForPOL[#playersForPOL]) table.remove(playersForPOL, #playersForPOL) setPlayerTeam ( playersForIMI[#playersForIMI], team_immigrantsSP ) outputChatBox(">>Auto-balance system changed your team!", playersForIMI[#playersForIMI], 255, 64, 64) else sync = true end end spawn() else while(sync ~= true) do if(#playersForPOL ~= #playersForIMI + 1) then table.insert(playersForIMI, playersForPOL[#playersForPOL]) table.remove(playersForPOL, #playersForPOL)
  21. hehe, congratulation. Show it to me, you should be sure that i don't want it, i just want to see what did you do.
  22. Then how it's the same just with a 0. ??
×
×
  • Create New...