Jump to content

Tomc0

Members
  • Posts

    38
  • Joined

  • Last visited

Tomc0's Achievements

Rat

Rat (9/54)

0

Reputation

  1. Tomc0

    DD ! command

    Okay, I'm officially dumb as hell. I forgot to add the "onPlayerChat" event handler. Anyways, thanks guys!
  2. Tomc0

    DD Random map

    Oh, I totally forgot this... Thanks!
  3. Tomc0

    DD ! command

    Hello guys, I think you know this ! command thing... It's usually used on DD/DM servers, if you write this to the chatbox: !wins examplePlayer, the server outputs the wins of the examplePlayer. I want to implement this thing to one of my script, but I have no idea how to do that. I have a code like that right now, but it's not working: function queryData(message,type) local nickName = getPlayerName(source) if (string.find(message,"!points")) and not (string.find(message," !points")) then else if message == "!cash" or message == "!money" then else if message == "!kills" then outputChatBox(nickName .. " has " .. tostring(getAccountData(account,"totalStatKills")) .. " points.") else if(string.find(message,"!playtime")) and not (string.find(message," !playtime")) then outputChatBox(nickName .. "'s playtime is " .. tostring(return_Played_time(getAccountData(account,"totalStatTime")))) else if(string.find(message,"!wins")) and not (string.find(message," !wins")) then outputChatBox(nickName .. " has " .. tostring(getAccountData(account,"totalStatFirstPlace")) .. " wins.") else if(string.find(message,"!deaths")) and not (string.find(message," !deaths")) then outputChatBox(nickName .. " died " .. tostring(getAccountData(account,"totalStatDies")) .. " times.") else if(string.find(message,"!messages")) and not (string.find(message," !messages")) then outputChatBox(nickName .. " send " .. tostring(getAccountData(account,"totalStatMessages")) .. " messages." ) else if(string.find(message,"!matches")) and not(string.find(message," !matches")) then outputChatBox(nickName .. " played " .. tostring(getAccountData(account,"totalStatMatches")) .. " matches.") end end end end end end end end end Any of you know how to do that? If yes, can someone help me? Thanks for the answers!
  4. Tomc0

    DD Random map

    Hello guys, I'm writing a little addon for the DD/DM gamemode. If only one player is alive in the DM mode, the server lets the player finish the race - this part is okay of the script. But if the last player is dead, I want to switch to a random map. How can I do that? Here's my modified script: function tablelength(T) local count = 0 for _ in pairs(T) do count = count + 1 end return count 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 local rank = self:getPlayerRank(player) finishActivePlayer(player) if rank and rank > 1 then triggerEvent( "onPlayerFinishDD",player,tonumber( rank ) ) end -- Update ranking board if one player left local activePlayers = getActivePlayers() if #activePlayers == 1 then self.rankingBoard:add(activePlayers[1], timePassed) showMessage(getPlayerName(activePlayers[1]) .. ' is the final survivor!', 0, 255, 0) end if #activePlayers == nil then triggerEvent( "onPlayerWinDD",activePlayers[0] ) local maps = exports["mapmanager"]:getMaps() maps_length = tablelength(maps) exports["mapmanager"]:changeGamemodeMap(maps[Math.random(0,maps_length)]) end end But that not works, and I can't really understand why. Can you please help? Thanks!
  5. I've just asked for a technique for it, but here's a part of the code: SERVER: function getDiesOnLogin() totalDies = getAccountData(account,"totalDies") or 0 setAccountData(account,"totalDies",totalDies or 0) totalStatDies = getAccountData(account,"totalStatDies") or 0 setAccountData(account,"totalStatDies",totalStatDies or 0) triggerClientEvent("updateDieStats",getRootElement(),totalDies) triggerClientEvent("updateTotalDieStats",getRootElement(),totalStatDies) end addEventHandler("onPlayerLogin",getRootElement(),getDiesOnLogin) addEvent("onCountDie",true) function countDie() totalDies = tonumber(getAccountData(account,"totalDies")) + 1 totalStatDies = tonumber(getAccountData(account,"totalStatDies")) + 1 triggerEvent("onCountDie",getRootElement()) end addEventHandler("onPlayerWasted",getRootElement(),countDie) function setDieData() setAccountData(account,"totalDies",totalDies) setAccountData(account,"totalStatDies",totalStatDies) triggerClientEvent("updateDieStats",getRootElement(),totalDies) triggerClientEvent("updateTotalDieStats",getRootElement(),totalStatDies) end addEventHandler("onCountDie",getRootElement(),setDieData) CLIENT: addEvent("updateDieStats",true) addEvent("updateTotalDieStats",true) function getDies(dies) totalDies = dies guiSetText(gui["diesLabel"],tostring(totalDies)) end addEventHandler("updateDieStats",getRootElement(),getDies) function getTotalDieStats(dies) totalStatDies = dies guiSetText(gui["totalDiesLabel"],tostring(totalStatDies)) end addEventHandler("updateTotalDieStats",getRootElement(),getTotalDieStats) function drawStatWindow() gui = {} gui._placeHolders = {} local screenWidth, screenHeight = guiGetScreenSize() local windowWidth, windowHeight = 270, 178 local left = screenWidth/2 - windowWidth/2 local top = screenHeight/2 - windowHeight/2 gui["_root"] = guiCreateWindow(left, top, windowWidth, windowHeight, "Statistics", false) guiWindowSetSizable(gui["_root"], false) gui["tabWidget"] = guiCreateTabPanel(0, 20, 272, 149, false, gui["_root"]) gui["tab"] = guiCreateTab("Month", gui["tabWidget"]) gui["diesLabel"] = guiCreateLabel(160, 79, 46, 13, "N/A", false, gui["tab"]) guiLabelSetHorizontalAlign(gui["diesLabel"], "left", false) guiLabelSetVerticalAlign(gui["diesLabel"], "center") end addEventHandler("onClientResourceStart",getRootElement(),drawStatWindow) I hope this will be enough... Thanks!
  6. Hello guys, I have a really big problem. I'm writing a DD addon with a GUI system, and there's a statistics system. The problem is, when a player dies, the resource adds everyone +1 deaths, and I don't want that: I only want to add that death to the player that died... How is it possible? How I can refresh the GUI just for one player? Thanks!
  7. Oh, I'm just testing it alone right now... But I will try it with another players soon. Do you think that's the problem? I need more players? Because that would be great...
  8. Tomc0

    Time format

    Thank you very much.
  9. Thank you, but the rank is still returns 0
  10. So, now, my code looks like that: function getOtherPlaces(rank) if(exports["race"]:getPlayerRank(player) == 1) then --firstPlace = firstPlace + 1 outputChatBox("1") --triggerEvent("onCalculatePlace",getRootElement()) else if(exports["race"]:getPlayerRank(player) == 2) then --secondPlace = secondPlace + 1 --triggerEvent("onCalculatePlace",getRootElement()) else if(exports["race"]:getPlayerRank(player) == 3) then --thirdPlace = thirdPlace + 1 --triggerEvent("onCalculatePlace",getRootElement()) else if(exports["race"]:getPlayerRank(player) == 4) then else if(exports["race"]:getPlayerRank(player) == 5) then else if(exports["race"]:getPlayerRank(player) == 6) then else if(exports["race"]:getPlayerRank(player) == 7) then else if(exports["race"]:getPlayerRank(player) == -- s8) --> then else if(exports["race"]:getPlayerRank(player) == 9) then else if(exports["race"]:getPlayerRank(player) == 10) then end end end end end end end end end end end addEventHandler("onRacePlayerWasted",getRootElement(),getOtherPlaces) But still not works Can you please tell me what's wrong with it? I just can't find the problem, and that's annoying as hell Maybe the problem is that I want to write a resource for the DD mod? I mean maybe the "race" functions are don't really working on the Destruction Derby... Thanks.
  11. Tomc0

    Time format

    Hello guys, I need some help with one my scripts: I need a timer, that counts the playtime of the player. So, if I have a code like that: playTime = 0 function updateTimer() playTime = playTime + 1 end setTimer(updateTimer,60000,0) How I can format the "playTime" variable like that: 1h,24m? Because right now, I just have a variable like "81 minutes" what is lame as hell. So can you guys help me with switching minutes to hours? Yes, I know, I could do that like this: if(playTime >= 60) then playTime = "1h 0m" end But that's not good, because I can't do it forever. So, thanks for the help!
  12. Thanks, but there is no "rank" parameter for it, so I can't really use it. Should I use the "getPlayerRank" function? Because I used it before, and because I called it when the player "died", the rank was 0. Any other ideas? Oh, and I've seen this forum topic: /viewtopic.php?f=91&t=58893&p=563255 And that's the reason why I used those DD functions... They are worked for this guy.
  13. Hell guys. I'm doing an addon for the gamemode DD, and I have a little problem. I want to get how many times the player finished in the first, second or the third places. I have an idea how to do this, but it's looks like that's not going to work. I don't know why this is not working. The MTA not supports those DD events anymore? If you can, please help me! Thank you!
×
×
  • Create New...