Jump to content

Lpsd

Administrators
  • Posts

    319
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by Lpsd

  1. No idea if this will still work with latest Minecraft versions, but you can look around for something similar to this https://www.spigotmc.org/resources/remote-chat.10046/ That'll stream the chat from MC Server > Web Once you've got something like that set up, you'll simply need to then feed the data from Web > MTA, with the functions MrTasty provided, callRemote or fetchRemote
  2. That's exactly what he just told you to do. Using a loop with dxDrawLine you can create the effect of rounded corners.
  3. Lpsd

    host mtasa

    https://www.1and1.co.uk/dynamic-cloud-server
  4. I'm not sure what you mean with regards to XML functions: "They are for saving data, not setting/replacing text" With XML functions you can open files, search for tags/data, change their attributes, add tags/attributes, save them, and pretty much everything else you're wanting to do. tl;dr - use XML functions
  5. Would be good if you share your solution. This will help anyone who stumbles across this topic with a similar problem.
  6. I mean, I could spend all day pasting every single function from the MTA wiki - you are the one building the script so you should decide which functions are needed. To answer your question - no, that's not all you'll need for a fully functioning cruise control. For starters, how will you calculate the paths in which the vehicles/planes are allowed to travel once in cruise control mode? I find it best to do some planning or brain storming before writing any code, run through the process in your head, or on paper. Doing this will help you to make a better script, and more importantly get a better understanding of what will be required to create it.
  7. http://www.luafaq.org/#T1.10 local table = {fruit = "apple", sport = "football", "toast", language = "french"} local itable = {"apple", "football", "toast", language = "french"} for i,v in pairs(table) do print(i,v) end --[OUTPUT] --1 toast --fruit apple --sport football --language french for i,v in pairs(itable) do print(i,v) end --[OUTPUT] --1 apple --2 football --3 toast --language french for i,v in ipairs(itable) do print(i,v) end --[OUTPUT] --1 apple --2 football --3 toast for i,v in ipairs(table) do print(i,v) end --[OUTPUT] --1 toast
  8. Store it as so local myFunction function drawTextAbove(source, dText, dFont, dZize, dColor) local dText, dFont, dZize, dColor = dText, dFont, dZize, dColor local dElement = source myFunction = function () dxDrawTextOnElement(dElement ,"Kurisu",1,20,0,0,255,255,1,"arial") end addEventHandler("onClientRender", source, myFunction) end And further to what you're trying to achieve: local myFunction local renderHandler = false addEvent("drawTextForElement", true) addEventHandler("drawTextForElement", getRootElement(), function () if renderHandler then removeEventHandler("onClientRender", source, myFunction) renderHandler = false end drawTextAbove(source, dText, dFont, dZize, dColor) end) function drawTextAbove(source, dText, dFont, dZize, dColor) local dText, dFont, dZize, dColor = dText, dFont, dZize, dColor local dElement = source myFunction = function () dxDrawTextOnElement(dElement ,"Kurisu",1,20,0,0,255,255,1,"arial") end addEventHandler("onClientRender", source, myFunction) renderHandler = true end A better way would be to just make your 'dText' (and such other variables) global, or atleast within the scope of this whole script; then create a named function instead of anonymous one.
  9. That's exactly what's supposed to happen if you disable the collision for an object. No collision = you can't hit the object, you just pass through it.
  10. Make sure the script is set to clientside in meta.xml Also you can't do something such as this: local setPedVoice() The correct way would be this: local voice = setPedVoice()
  11. I've no clue about shaders, but this is what I normally use texture Ped; technique J { pass P0 { Texture[0] = Ped; DepthBias=-0.0002; } } If that fails, can we see your meta.xml?
  12. Password for what exactly? Another MTA forum account? A server you play on? Your bank account? Facebook? Be more specific.
  13. Lpsd

    HoursToDay

    Can't edit original post. Doublepost ftw! Here's your original code, fixed: function hoursToDays(hours) local totalHours = tonumber(hours) if totalHours then local hours = math.floor(totalHours/60) hours = totalHours - hours*60 if hours then return hours else return 0,0 end end end FYI: this comes no where close to converting hours to days. I would suggest you use my examples
  14. Lpsd

    HoursToDay

    To answer your original question about the problem with the code; once you have defined a local variable there's no need to declare its scope again within the same block. Simply change line 5 of your code to: hours = totalHours - hours*60 Moving on, your maths is completely wrong. See these examples. function hoursToDays(hours) if not hours then return false end local days = math.floor(hours/24) return days end Or if you want to be more specific: function round(num, numDecimalPlaces) local mult = 10^(numDecimalPlaces or 0) return math.floor(num * mult + 0.5) / mult end function hoursToDays(hours) if not hours then return false end local days = round(hours/24, 1) return days end
  15. Look at the code carefully, it's not that hard to work out what's going wrong. Change the 3rd argument of 'bindKey' to be 'vehicleWarp' (there's currently a typo, 'vehicleWrap')
  16. Does removing event handlers work like that? (when using anonymous functions) I'd much rather store it in a variable, or create a named function for that.
  17. Lpsd

    Timer Help

    Goddamn. Remind me not to post stuff when I'm half asleep. local spinTimer = {} function spincoin(player, cmd, ...) if not isTimer(spinTimer[player]) then spinTimer[player] = setTimer(function() outputChatBox("[Spin Coin]: Your spin is ready! Do /spin to test your luck", player) spinTimer[player] = nil end, 600000, 1) local text = table.concat({...}, " ") if not ... then outputChatBox("#2BFF00[Spin Coin]: #FFFFFFYour Spin is Ready use #2BFF00/Spin [money]#FFFFFFto Test your luck", player, 255, 255, 255, true) return end if tonumber(text) < 1 then outputChatBox("#2BFF00[Spin Coin]: #FFFFFFuse /Spin ( 1 - "..max_spin.." )", player, 255, 255, 255, true) return end if tonumber(text) > max_spin then outputChatBox("#2BFF00[Spin Coin]: #FFFFFFSorry, you cannot Spin Money more than #FF000010000 "..max_spin.."!", player, 255, 255, 255, true) outputChatBox(tonumber(text), player, 255, 255, 255, true) return end if getPlayerMoney(player) < tonumber(text) then outputChatBox("#2BFF00[Spin Coin]: #FFFFFFSorry, You don´t have enough money!", player, 255, 255, 255, true) return else coin = math.random(1, 2) if coin == 1 then outputChatBox("#2BFF00[Spin Coin]: #FF0000"..getPlayerName(player).." #ffffffhas spinned the coin and won #2BFF00+"..tonumber(text).."$ !", player, 255, 255, 255, true) givePlayerMoney(player, tonumber(text)) elseif coin == 2 then outputChatBox("#2BFF00[Spin Coin]: #FF0000"..getPlayerName(player).." #ffffffhas spinned the coin and lost #FF0000-"..tonumber(text).."$ !", player, 255, 255, 255, true) takePlayerMoney(player, tonumber(text)) end end else outputChatBox("You already used /spin in the past 10 minutes!", player) end end addCommandHandler("spin", spincoin)
  18. Lpsd

    Timer Help

    local spinTimer function spincoin(player, cmd, ...) if not isTimer(spinTimer) then spinTimer = setTimer(function() outputChatBox("[Spin Coin]: Your spin is ready! Do /spin to test your luck", player) spinTimer = nil end, 600000, 1) local text = table.concat({...}, " ") if not ... then outputChatBox("#2BFF00[Spin Coin]: #FFFFFFYour Spin is Ready use #2BFF00/Spin [money]#FFFFFFto Test your luck", player, 255, 255, 255, true) return end if tonumber(text) < 1 then outputChatBox("#2BFF00[Spin Coin]: #FFFFFFuse /Spin ( 1 - "..max_spin.." )", player, 255, 255, 255, true) return end if tonumber(text) > max_spin then outputChatBox("#2BFF00[Spin Coin]: #FFFFFFSorry, you cannot Spin Money more than #FF000010000 "..max_spin.."!", player, 255, 255, 255, true) outputChatBox(tonumber(text), player, 255, 255, 255, true) return end if getPlayerMoney(player) < tonumber(text) then outputChatBox("#2BFF00[Spin Coin]: #FFFFFFSorry, You don´t have enough money!", player, 255, 255, 255, true) return else coin = math.random(1, 2) if coin == 1 then outputChatBox("#2BFF00[Spin Coin]: #FF0000"..getPlayerName(player).." #ffffffhas spinned the coin and won #2BFF00+"..tonumber(text).."$ !", player, 255, 255, 255, true) givePlayerMoney(player, tonumber(text)) elseif coin == 2 then outputChatBox("#2BFF00[Spin Coin]: #FF0000"..getPlayerName(player).." #ffffffhas spinned the coin and lost #FF0000-"..tonumber(text).."$ !", player, 255, 255, 255, true) takePlayerMoney(player, tonumber(text)) end end else outputChatBox("You already used /spin in the past 10 minutes!", player) end end addCommandHandler("spin", spincoin)
  19. I'm not sure if I'd rely on using that timer. I see a flaw in the logic of setting the timer to 1 per hour, what if the script was initiated at 5 minutes past the hour? If the timer is only then checking once per hour, it'll never work. Here's how I'd prefer to do it Clientside: local paydayValid = true local function realtime() local time = getRealTime() local hours = time.hour local minutes = time.minute if paydayValid == true then if hours == 7 and minutes == 0 then outputChatBox("Payday, ka-ching!") triggerServerEvent("onClientPayday", resourceRoot) paydayValid = false end else if hours == 6 and minutes == 59 then paydayValid = true end end end addEventHandler("onClientRender", getRootElement(), realtime) Serverside: local function payday() givePlayerMoney(client, 1500) end addEvent("onClientPayday", true) addEventHandler("onClientPayday", getRootElement(), payday) Not tested, but it's not exactly a complicated script excuse the indenting, the forum code editor uses 2 spaces whereas I use tab
  20. addCommandHandler("deposit",function(player,cmd,money) local money = math.ceil(tonumber(money)) -- line 14 if not money then outputChatBox(syntax.." /"..cmd.." [Amount]",player,38,194,129,true) else if (money) <= 0 then outputChatBox(error.." Bigger hatn 0.",player,177,9,45,true) elseif exports["rc_core"]:getMoney(player) >= tonumber(money) then exports["rc_core"]:takeMoney(player,tonumber(money)) giveBankMoney(player,money) else outputChatBox(error.." You cant afford that.",player,177,9,45,true) end end end )
  21. Lpsd

    Laugh from :D

    emoticons = { {":D", "laugh"}, {":(", "sad"} } function checkMessage(message) for i=1,#emoticons do if string.find(message, emoticons[i][1]) then message:gsub(emoticons[i][1], emoticons[i][2]) end end end checkMessage("Testing message :D") something like this?
  22. Why would you need to do it that way? Just ensure different dimensions for each player when in a house, and same dimension for all when outside.
  23. @MrSecreto07 as I said, these animations are only available in certain versions of the SP - so it's most likely the MTA team stopped them being able to work altogether as to avoid any issues with compatibility between clients.
×
×
  • Create New...