Jump to content

Tomc0

Members
  • Posts

    38
  • Joined

  • Last visited

Everything posted by Tomc0

  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!
  14. Tomc0

    Destroying GUI

    Oh, what a noob mistake... Thank you!
  15. Tomc0

    Destroying GUI

    Hello guys, I have a problem with destroying a GUI. So, I'm doing a script where the player can select his spawn skin in a GUI, and if he clicks "Select", the script saves the selected skin and spawns the player with it. The main part of the script is okay, it works, but if the player spawns, I want to destroy GUI, but it doesn't work. Here's the code: CharacterCreation.lua (Server) SkinChooser.lua (CLIENT) Maybe the problem is that the selectSkin() function is attached to the GUI, because if you click on the "Select" button it runs... So maybe that's why I can't call the setGuiVisible() function... If someone have an idea, please help. Thansk!
  16. Can you help me with that? Do I need to use the "require" lua statement for that? Thanks!
  17. Thanks for the help! And if I want to use a variable from a server side script in a client type script? I can't do it?
  18. Hello, if that's going to be a noob question sorry, but I just can't find a great tutorial for my problem. So, I want to reach a variable from another lua file, like that: Example1.lua: function example() string = "Test" end So, if I'm in another lua file (Example2.lua), and I want to get the "string" variable from the Example1.lua file, what do I need to do? I heard about "require", but I can't really understand how to use it. Thanks!
  19. Thanks, but still not works. There's an error message: ERROR: tg\RegisterLogin.lua:81: attempt to index global 'gui' (a nil value) Interesting... UPDATE: Okay, I modified some parts, and now it's works. If someone wants to check the whole code and the fix, here you go: Thanks iMr.3a[Z]eF for the help.
  20. Nothing, just an info: votemanager precreateGuiElements.
  21. WARNING: tg\RegisterLogin.lua58: Bad argument @ 'guiEditSetMaxLength' [Expected gui-element at argument 1, got nil] But that's not my problem, that was just a simple bug, I fixed it.
  22. Hello. I have a little problem with the guiGetText() function. So, I'm doing a register/login GUI form, and I want to get the edit box's text. I made the GUI design with the QT to Lua program. In the code, there are so many GUI button, label, edit creation functions, so I'm not going to post the whole code. function drawWindow() gui = {} gui._placeHolders = {} gui["_root"] = guiCreateWindow(left, top, windowWidth, windowHeight, "Login/Register", false) gui["tabWidget"] = guiCreateTabPanel(0, 20, 251, 181, false, gui["_root"]) gui["tab_2"] = guiCreateTab("Register", gui["tabWidget"]) gui["registerUsernameEdit"] = guiCreateEdit(110, 10, 113, 20, "", false, gui["tab_2"]) guiEditSetMaxLength(gui["registerUsernameEdit"], 32767) gui["registerPasswordEdit"] = guiCreateEdit(110, 40, 113, 20, "", false, gui["tab_2"]) guiEditSetMaxLength(gui["registerPasswordEdit"], 32767) gui["registerPasswordEditRepeat"] = guiCreateEdit(110, 70, 113, 20, "", false, gui["tab_2"]) guiEditSetMaxLength(gui["lineEdit"], 32767) gui["registerButton"] = guiCreateButton(52,105, 131, 23, "Register", false, gui["tab_2"]) if on_registerButton_clicked then addEventHandler("onClientGUIClick", gui["registerButton"], on_registerButton_clicked,false) end username = guiGetText(gui["registerUsernameEdit"]) pw = guiGetText(gui["registerPasswordEdit"]) pw2 = guiGetText(gui["registerPasswordEditRepeat"]) return gui, windowWidth, windowHeight end addEventHandler("onClientResourceStart",getRootElement(),drawWindow) function on_registerButton_clicked() outputChatBox(username) outputChatBox(pw) outputChatBox(pw2) end So, the problem: If I click the Register button, the chatbox just outputs nothing, so I think the program can't get the values of the edit boxes. If someone wants to see that, here's the whole code: Thanks for the help.
×
×
  • Create New...