Jump to content

Thorxx

Members
  • Posts

    52
  • Joined

  • Last visited

Everything posted by Thorxx

  1. Thank you both guys, managed to do it your way a it works very well and looks a lot better. But to not start a new thread I will ask here. As you maybe understood I am working on a multigamemode and I would like to ask you, how would you handle file loading? Its running as a one big gamemode, where I created folder race with race client and race server. These files are called by function from those peds clicl events... Lets say, you go to an npc, press F and it does this Race.main() and calls function Race.main from my race folder. Then in Race.main I have trigger for client to handle the drawings, but when I leave race to join lobby I need to separately remove all the drawing events and everything included, such as kill list and so on... Is there a way to disable it all at once? For localPlayer only to not kill the mode for other players...
  2. Hello, I have returned to MTA after a really long time and as I have returned I also returned to scripting, so count me as a beginner. I was a little bit bored of playing gamemodes and stuff, so I decided to script something and give it a try to make something on my own, just for fun and so on... What I am working on is a simple version of Multigamemode, but I am currently struggling with something easy I suppose (as usual lol). First of all... I would like someone to take a look at my code and check if there's a way to make things easier or make it not contain the same code twice, which is my problem. function Lobby.arenaDraw() -- draw ped/npc names above their head if roomDeathmatch then local pedX, pedY, pedZ = getElementPosition(roomDeathmatch) local sx, sy = getScreenFromWorldPosition(pedX, pedY, pedZ) local cameraX, cameraY, cameraZ = getCameraMatrix() dxDrawTextOnElement(roomDeathmatch, "Deathmatch", 1, 20, 255, 255, 255, 255, 2, "sans") dxDrawTextOnElement(roomDeathmatch, "#2980b9Press #ffffff".."F".." #2980b9to join", 0.9, 20, 255, 255, 255, 255, 1.6, "sans") dxDrawTextOnElement(roomDemolition, "Demolition Derby", 1, 20, 255, 255, 255, 255, 2, "sans") dxDrawTextOnElement(roomDemolition, "#2980b9Press #ffffff".."F".." #2980b9to join", 0.9, 20, 255, 255, 255, 255, 1.6, "sans") if (isLineOfSightClear(pedX, pedY, pedZ+2, cameraX, cameraY, cameraZ)) then if getDistanceBetweenPoints3D(cameraX, cameraY, cameraZ, pedX, pedY, pedZ) <= interactRange then if getElementData(localPlayer, "Room") == "Lobby" then bindKey("F", "up", Lobby.roomJoinDeathmatch) end else unbindKey("F", "up", Lobby.roomJoinDeathmatch) end end end if roomDemolition then local pedX, pedY, pedZ = getElementPosition(roomDemolition) local sx, sy = getScreenFromWorldPosition(pedX, pedY, pedZ) local cameraX, cameraY, cameraZ = getCameraMatrix() dxDrawTextOnElement(roomDemolition, "Demolition Derby", 1, 20, 255, 255, 255, 255, 2, "sans") dxDrawTextOnElement(roomDemolition, "#2980b9Press #ffffff".."F".." #2980b9to join", 0.9, 20, 255, 255, 255, 255, 1.6, "sans") if (isLineOfSightClear(pedX, pedY, pedZ+2, cameraX, cameraY, cameraZ)) then if getDistanceBetweenPoints3D(cameraX, cameraY, cameraZ, pedX, pedY, pedZ) <= interactRange then if getElementData(localPlayer, "Room") == "Lobby" then bindKey("F", "up", Lobby.roomJoinDemolition) end else unbindKey("F", "up", Lobby.roomJoinDemolition) end end end end addEventHandler("onClientRender", getRootElement(), Lobby.arenaDraw) The problem is that with every room I create I basically copy the code above and replace some functions and stuff... Which I think is not a really good work as it will only flood my code later on. I would like to find a solution to make it shorter with only one part of code instead of copying things over and over again. And one more thing I would like to ask... I am drawing nicknames above players, but they are not separated by dimension... Basically when you switch the dimension and play DM for example, you can see nicknames from DD (if the map is at the same place or somewhere closer...) addEventHandler("onClientRender", getRootElement(), function () for _, player in ipairs(getElementsByType("player")) do if getElementData(player, "Room") then dxDrawTextOnElement(player, getPlayerName(player), 0.9, 70, 255, 255, 255, 255, 1.5, "sans") end end end) I would like to separate the names by dimension, so players from dimension 1 wont see names of players from dimension 2. Would be really happy for someone to help me out solving these (simple, I guess?) issues. Thanks in advance.
  3. Show us the part of the code with onClientRender
  4. You can also use my resource: https://community.multitheftauto.com/ind ... ls&id=8824
  5. Did you make /refresh?
  6. Try this mode=0 DestructionDerby = setmetatable({}, RaceMode) DestructionDerby.__index = DestructionDerby DestructionDerby:register('Destruction derby') winprice = nil winplayer = nil dead = 0 function DestructionDerby:isApplicable() return not RaceMode.checkpointsExist() and RaceMode.getMapOption('respawn') == 'none' end function DestructionDerby:getPlayerRank(player) return #getActivePlayers() end -- Copy of old updateRank function DestructionDerby:updateRanks() for i,player in ipairs(g_Players) do if not isPlayerFinished(player) then local rank = self:getPlayerRank(player) if not rank or rank > 0 then setElementData(player, 'race rank', rank) end end end -- Make text look good at the start if not self.running then for i,player in ipairs(g_Players) do setElementData(player, 'race rank', '' ) setElementData(player, 'checkpoint', '' ) end end end function DestructionDerby:onPlayerWasted(player) if isActivePlayer(player) then self:handleFinishActivePlayer(player) if getActivePlayerCount() <= mode then local activePlayers = getActivePlayers() if #activePlayers == 1 then if getElementData(activePlayers[1], "isDonator") ~= true or string.find(g_MapName, "[sHOOTER]", 1, true) or string.find(g_MapName, "[FUN]", 1, true) or string.find(g_MapName, "[DD]", 1, true) or getElementModel(getPedOccupiedVehicle(activePlayers[1])) == 425 then RaceMode.endMap() else TimerManager.createTimerFor("map",player):setTimer(clientCall, 2000, 1, player, 'Spectate.start', 'auto') end else RaceMode.endMap() end else TimerManager.createTimerFor("map",player):setTimer(clientCall, 2000, 1, player, 'Spectate.start', 'auto') end local pvpElements = getElementsByType ( "pvpElement" ) for theKey,pvpElement in ipairs(pvpElements) do if (getElementData(pvpElement, "player1") == player or getElementData(pvpElement, "player2") == player) and getElementData(pvpElement, "accepted") == true then local player1 = getElementData(pvpElement, "player1") local player2 = getElementData(pvpElement, "player2") if player1 == player then addPlayerArchivement( player2, 44 ) outputChatBox("#256484:PVP: #FFFFFF"..getPlayerName(player2).." has won a PVP war against "..getPlayerName(player1).." and receives "..tostring(getElementData(pvpElement, "money")).." VIP.",getRootElement(),255,0,0, true) setPlayerMoney(player2, getPlayerMoney(player2)+getElementData(pvpElement, "money")*2) elseif player2 == player then addPlayerArchivement( player1, 44 ) outputChatBox("#256484:PVP: #FFFFFF"..getPlayerName(player1).." has won a PVP war against "..getPlayerName(player2).." and receives "..tostring(getElementData(pvpElement, "money")).." VIP.",getRootElement(),255,0,0, true) setPlayerMoney(player1, getPlayerMoney(player1)+getElementData(pvpElement, "money")*2) end destroyElement(pvpElement) break end end if getActivePlayerCount() ~= 0 then if isLoggedIn(player) == true and getElementData(player, "AFK") == false then local onlinePlayers = 0 local players = getElementsByType ( "player" ) for theKey,thePlayer in ipairs(players) do onlinePlayers = onlinePlayers + 1 end local endPoints = math.floor(onlinePlayers*(8.5+(onlinePlayers/100))/(getActivePlayerCount()+1)) local endMoney = math.floor(onlinePlayers*(65+(onlinePlayers/100))/(getActivePlayerCount()+1)) if g_eventInProgress == 1 or g_eventInProgress == 2 or g_eventInProgress == 3 then endPoints = endPoints*2 end outputChatBox("#00aa46:Points: #ffffff You received "..tostring(endPoints).." points and "..tostring(endMoney).." VIP for playing this map.", player, 255, 255, 255, true) setElementData(player, "Points", getElementData(player, "Points") + endPoints) setElementData(player, "Money", getElementData(player, "Money") + endMoney) if isTimer ( WinTimer ) then killTimer ( WinTimer ) end end end end RaceMode.setPlayerIsFinished(player) showBlipsAttachedTo(player, false) end function DestructionDerby:onPlayerQuit(player) if isActivePlayer(player) then self:handleFinishActivePlayer(player) if getActivePlayerCount() <= 1 then local activePlayers = getActivePlayers() if #activePlayers == 1 then if getElementData(activePlayers[1], "isDonator") ~= true then RaceMode.endMap() end else RaceMode.endMap() end end end end function DestructionDerby:handleFinishActivePlayer(player) -- Update ranking board for player being removed if not self.rankingBoard then self.rankingBoard = RankingBoard:create() self.rankingBoard:setDirection( 'up', getActivePlayerCount() ) end local timePassed = self:getTimePassed() self.rankingBoard:add(player, timePassed) -- Do remove finishActivePlayer(player) -- Update ranking board if one player left local activePlayers = getActivePlayers() if #activePlayers == 1 then givePlayerBetWinning (activePlayers[1]) self.rankingBoard:add(activePlayers[1], timePassed) setElementData(activePlayers[1], "winningCounter", getElementData(activePlayers[1], "winningCounter") + 1) if getElementData(activePlayers[1], "winningCounter") == 5 then addPlayerArchivement(activePlayers[1], 12) elseif getElementData(activePlayers[1], "winningCounter") == 7 then addPlayerArchivement(activePlayers[1], 13) elseif getElementData(activePlayers[1], "winningCounter") == 11 then addPlayerArchivement(activePlayers[1], 14) end if tonumber(getElementData(activePlayers[1], "winningCounter")) >= tonumber(getElementData(activePlayers[1], "WinningStreak")) then setElementData(activePlayers[1], "WinningStreak", getElementData(activePlayers[1], "winningCounter")) end if isTimer ( WinTimer ) then killTimer ( WinTimer ) end local onlinePlayers = 0 local players = getElementsByType ( "player" ) for theKey,thePlayer in ipairs(players) do onlinePlayers = onlinePlayers + 1 if activePlayers[1] ~= thePlayer then if isLoggedIn(thePlayer) == true then setElementData(thePlayer, "winningCounter", 0) end end end local endPoints = math.floor(onlinePlayers*(8.5+(onlinePlayers/100))) local endMoney = math.floor(onlinePlayers*(65+(onlinePlayers/100))) if g_eventInProgress == 1 or g_eventInProgress == 2 or g_eventInProgress == 3 then endPoints = endPoints*2 end if isLoggedIn(activePlayers[1]) == true and getElementData(activePlayers[1], "AFK") == false then outputChatBox("#00aa46:Points: #ffffff You received "..tostring(endPoints).." points and "..tostring(endMoney).." VIP for winning this map.", activePlayers[1], 255, 255, 255, true) setElementData(activePlayers[1], "WonMaps", getElementData(activePlayers[1], "WonMaps")+1) --triggerClientEvent ( activePlayers[1], "onRefreshGui" ) setElementData(activePlayers[1], "Points", getElementData(activePlayers[1], "Points")+ endPoints) setElementData(activePlayers[1], "Money", getElementData(activePlayers[1], "Money")+ endMoney) if onlinePlayers >= 10 then addPlayerArchivement( activePlayers[1], 8 ) end if string.find(g_MapInfo.name, "[DM]", 1, true) then setElementData(activePlayers[1], "DMWon", getElementData(activePlayers[1], "DMWon")+1) end if getElementData(activePlayers[1], "DMWon") == 100 then addPlayerArchivement( activePlayers[1], 19 ) end if getElementData(activePlayers[1], "DMWon") == 1000 then addPlayerArchivement( activePlayers[1], 21 ) end if string.find(g_MapInfo.name, "[DD]", 1, true) then setElementData(activePlayers[1], "DDWon", getElementData(activePlayers[1], "DDWon")+1) end if getElementData(activePlayers[1], "DDWon") == 100 then addPlayerArchivement( activePlayers[1], 20 ) end if getElementData(activePlayers[1], "DDWon") == 1000 then addPlayerArchivement( activePlayers[1], 22 ) end end local ran_win_mesage = { [1] = "He won "..tostring(getElementData(activePlayers[1], "DMWon")).." DM maps", [2] = "He won "..tostring(getElementData(activePlayers[1], "DDWon")).." DD maps", [3] = "He drove "..tostring(math.floor(getElementData(activePlayers[1], "KM"))).." KM in this server!", [4] = "He did "..tostring(getElementData(activePlayers[1], "TopTimes")).." toptimes!", [5] = "He is Level "..tostring(getElementData(activePlayers[1], "Rank")).."!", [6] = "He got "..tostring(getElementData(activePlayers[1], "Money")).." Vero", [7] = "He played "..tostring(getElementData(activePlayers[1], "PlayedMaps")).." maps!", [8] = "He got "..tostring(getElementData(activePlayers[1], "Points")).." points!", [9] = "His winning streak is x"..tostring(getElementData(activePlayers[1], "winningCounter")).."!", [10] = "He is already for "..tostring(math.floor(getElementData(activePlayers[1], "TimeOnServer")/60)).." minutes on the Server!" } local hasCustomText = false if getElementData(activePlayers[1], "isDonator") == true then if getElementData(activePlayers[1], "useWinsound") ~= 0 then local players = getElementsByType ( "player" ) for theKey,thePlayer in ipairs(players) do if getElementData(thePlayer, "toggleWinsounds") == 1 then callClientFunction(thePlayer, "playSound", "audio/winsounds/"..tostring(getElementData(activePlayers[1], "useWinsound"))..".mp3") end end end if getElementData(activePlayers[1], "customWintext") ~= "none" then showWinMessage("#FFFFFF"..tostring(getElementData(activePlayers[1], "customWintext")), "#00aa46"..tostring(ran_win_mesage[math.random(1,10)]), 0, 170, 77) hasCustomText = true end end if hasCustomText == false then showWinMessage("#FFFFFF".._getPlayerName(activePlayers[1]) .. '#00aa46 has won the map!', "#FFFFFF"..tostring(ran_win_mesage[math.random(1,10)]), 0, 170, 77) end end end ------------------------------------------------------------ -- activePlayerList stuff -- function isActivePlayer( player ) return table.find( g_CurrentRaceMode.activePlayerList, player ) end function addActivePlayer( player ) table.insertUnique( g_CurrentRaceMode.activePlayerList, player ) end function removeActivePlayer( player ) table.removevalue( g_CurrentRaceMode.activePlayerList, player ) end
  7. Download links are fixed now!
  8. Hello ladies and gentlemans! As you might know I've been working on a script called LogSystem. And today I finally finished the script. The scripts includes website to show the logs. WHAT DO YOU NEED TO USE THIS SCRIPT? - MySQL Database - MTA Server - Website that allows you to use php applications/systems ------------------------------------------------------------------------------------------ The script is under free licence (Copyleft) ------------------------------------------------------------------------------------------ 1. Download the logSystem from https://community.multitheftauto.com/in ... ls&id=8824 2. Upload it into a server 3. Open logSys.lua and change your MySQL Database Settings! 4. Open your MySQL server and run this command through Query 5. Download the Website files from http://uploaded.net/file/ksj01m0r 6. Upload the files into your website (FTP) 7. Open settings.php and change your MySQL Databse Settings! 8. Start the script 9. Check the website out! http://www.img.tpx.cz/uploads/bans.png http://www.img.tpx.cz/uploads/Commands.png http://www.img.tpx.cz/uploads/Changenick.png http://www.img.tpx.cz/uploads/chaticeke.png http://www.img.tpx.cz/uploads/joinquit.png http://www.img.tpx.cz/uploads/LoginLogout.png THE SCRIPT WON'T WORK IF YOU WON'T CHANGE THE MYSQL SETTINGS!!! IGNORE THE ADVERTS ABOVE THE TABLE I'M USING FREE WEB HOSTING!!! DID YOU FIND A BUG? HAVE YOU GOT AN IDEA TO MAKE THE SCRIPT BETTER? TYPE IT BELOW THE POST!
  9. Thorxx

    Cars

    If you'd like to have a red marker you must have it like this createMarker(0,0,0,"cylinder", 4, 255, 0, 0 ) It's RGB R = Red | Maximal value is 255 (Clearly red) G = Green B = Blue Also if you want to get more colors you can use this free colorpicker http://colorpicker.net/
  10. Thorxx

    Cars

    Yeah, sure. He tried to code it right? If this guy didn't know what "debugscript" was then he's pretty new to scripting in MTA. So he asked the forums for help, and then gets stupid reactions like "meep meep, show your full debugscript 3". Gosh, these forums where 4 years ago pretty different, the people were so much friendlier to each other. I don't want to discuss here, I only want to make it clear, if you want to discuss with me then you can send me a PM. Kindly regards, Danny. They were friendly, but because no one was asking to that stupid questions and they were using google or wiki on their own.
  11. Thorxx

    Cars

    That's a job for beginners and you must know that! setMarkerSize() setMarkerColor()
  12. Thorxx

    Cars

    He's just utterly brain-damaged
  13. Thorxx

    Cars

    This is the worst lie that you can ever write! You can start your own server by using the server files provided by MTA:SA. MTA\server\MTA Server.exe
  14. Thorxx

    Cars

    It is not exactly since you didn't write everything about the errors.
  15. Thorxx

    Cars

    We want to know what EXACTLY the errors are!
  16. Thorxx

    Cars

    How can we help you if we don't see the errors?
  17. Thorxx

    Cars

    What does debugscript3 say?
  18. Thorxx

    New Chat

    I didn't write all the ways to make it done, I just wrote two ways that he can use.
  19. Thorxx

    New Chat

    You can have it done by using MySQL or tables.
  20. Do the same with: engineLoadDFF
  21. Hi, I'd like to suggest you Czechoslovakian language, it's a language that we use in Czech and Slovakia.
  22. It might work by editing the textures.
×
×
  • Create New...