Jump to content

AfuSensi

User Guide Contributor
  • Posts

    59
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by AfuSensi

  1. Why arent you checking if the sound already exists before creating a new sound? If you do not check if the sound element already exists, then it will just ignore the old sound so sound[vehicle] will only give the newly created sound. Maybe try this: local url = "http://www.181.fm/winamp.pls?station=181-power&style=mp3&description=Power%20181%20(Top%2040)&file=181-power.pls" sound = {} function playTheSound(x, y, z, vehicle) if not isElement(vehicle) then outputChatBox("Vehicle does not exist") return false end -- Checks if vehicle exist, and returns if vehicle does not exist if isElement(sound[vehicle]) then outputChatBox("Sound is already playing") return false end -- Checks if sound exist, and returns if sound does exist local theSound = playSound3D(url, x, y, z) if theSound then sound[vehicle] = theSound attachElements(sound[vehicle], vehicle) else outputChatBox("Sound failed to play") return false end end addEvent("playTheSound", true) addEventHandler("playTheSound", getRootElement(), playTheSound) function stopTheSound(vehicle) stopSound(sound[vehicle]) end addEvent("stopTheSound", true) addEventHandler("stopTheSound", getRootElement(), stopTheSound)
  2. Do you see anything in the console (f8) when starting the resource? We need more info to be able to help. You can follow this to make yourself admin in your server: https://wiki.multitheftauto.com/wiki/Ser ... nistrators
  3. This is not a request forum, if you have problems you can post it here. I doubt anyone will help you if you are not willing to put in any effort. (referring to this topic too: viewtopic.php?f=91&t=88508 )
  4. Not always As far as i know, it is always. Since you can replace txd with shaders, but afaik there is no way to replace an object for 1 element only.
  5. AfuSensi

    fixed

    I wonder if you read the warning message, since it tells you what's wrong pretty clear. spawnPlayer argument 1 needs a player, and you gave it a resource. source in "onResourceStart" is a resource, not a player.
  6. Great idea, but i wouldn't use compiled scripts with these sort of things.
  7. This is how i would do it (not tested by the way, but hopefully you'll get the general idea): function drawDisplay() if isTimer(theTimer) then -- Check if timer is running to prevent errors local timeLeft = mstoSec(getTimerDetails(theTimer)) -- Get ms from timer and convert to seconds local message = "Your car will be spawned in"..tostring(timeLeft).." seconds." dxDrawText(message, ,2,2,resX + 2,102,tocolor(255,255,255,255),2,"default-bold","center","center",true,true,false) dxDrawText(message, 0,0,resX,100,tocolor(255,255,255,200),2,"default-bold","center","center",true,true,false) end end addEventHandler("onClientRender",root,drawDisplay) function startDisplay(jTime) theTimer = setTimer(function() -- Set the timer -- Write what timer has to execute here, or to a named function end ,10000,1) end addEvent("hii",true) addEventHandler("hii", localPlayer, startDisplay) function mstoSec(ms) local ms = ms/1000 if string.find(tostring(ms),"%.") then local seconds = string.match(tostring(ms),"%d+") return seconds else return ms end end
  8. You can do it with setTimer() getTimerDetails()
  9. [quote name=..&G:..] The line song = playSound("http://example.com/song.mp3") is in another function, I am only triggering that line from another function. If you don't want the error "Bad argument @ 'playSound' [Expected string at argument 1]", then you should do it like he showed you. If you want to keep "song", define something like songURL = "http://songurl.com/song.mp3" and use it for the stopSound and playSound functions.
  10. https://bugs.multitheftauto.com/view.php?id=8459
  11. This is actually not the problem, and wasnt really my question. It does not matter in what order the keys bind, only if they bind. The problem is if i unbind 1 bind, function UnbindThem(n, whatnumber) outputChatBox("Unbound "..whatnumber) unbindKey( tostring(whatnumber), "down", "chatbox" ) end addCommandHandler( "unbindme", UnbindThem) -- usage, /unbindme (number/key) It removes all binds bound the the chatbox control. This might be an MTA bug, thats why i created this simple script for people to test or if i have the syntax for unbindKey wrong in this case. If you want to test it on your own way, make 2 binds to the control "chatbox", and then unbind one of them, Both will be gone.
  12. Hey, I'm trying to make an bind system for my script, it binds a key to a chatbox command. So for purpose of testing, i made a simple script to showcase what's going wrong. bindKeyTable = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"} function bindTheKeys() for f, u in pairs(bindKeyTable) do bindKey(tostring(u), "down", "chatbox", tostring(f) ) end end addEventHandler("onClientResourceStart", resourceRoot, bindTheKeys) function UnbindThem(n, whatnumber) outputChatBox("Unbound "..whatnumber) unbindKey( tostring(whatnumber), "down", "chatbox" ) end addCommandHandler( "unbindme", UnbindThem) -- usage, /unbindme (number/key) As you can see, it creates chatbox binds from number 1 to 10. And adds a command to unbind a cerntain key. But if i use the command, it deletes all binds for the chatbox made by this resource. Is this wrong? unbindKey( tostring(whatnumber), "down", "chatbox" ) Thanks.
  13. Thanks for the clarification. The math goes above my head, since i started scripting seriously about a month ago. It's a shame the dxGUI resource has bugs, and i dont understand much of the script to fix it myself. EDIT: For the people that have the same problem, in the file dxGui.lua, if you set the variables to 0, it will work. I added this to my dxGui.lua: cpx = 0 cpy = 0 cx = 0 cy = 0 just above: attachedElements = {}
  14. Hmm, the function doesnt seem to work, or i'm using it wrong, and it doesnt output errors. searchField = guiCreateEdit(2, 30, 200, 50, "Search", false) g:guiAttachToDirectX(searchField, mainWindow, 500, 0) EDIT: Seems like dxGUI is bugged. g:guiAttachToDirectX(mainWindow, searchField, 0, 0) Oh well, then i'll have to script one for myself.
  15. Hi, I'm trying to create a GUI window with the resource https://wiki.multitheftauto.com/wiki/Resource:DxGUI But as you can see, there is no edit box, or memo. Is there a way to attach a normal GUI edit box and memo to the drawn dx rectangle? Or is there a way to make a custom edit box and memo? Thanks. EDIT: oh wow, i see a function : guiAttachToDirectX. Ill report back when it works for other people who may have the same problem.
  16. It would be great if there would be a mod or script that allowed this.
  17. If i understand it correctly, the table PlayerData has subtables of data ( like the key in setElementData ), and in that subtable there is another subtable with all the players in it? So this is server sided. If i understand that correctly, then i have a question. If the player leaves, how do i destroy the subtables that contain information of that player? Like, if thePlayer leaves, it still has the tables timePlayed = { [thePlayer] = 0 } inside of the table.
  18. Thanks! It worked. Mind explaining what userdata is? I can find nothing on wiki about it.
  19. Hi, I'm trying to call the function "getRunningGamemode" to detect what gamemode the current map is. But it returns userdata instead of the gamemode. I have no idea what userdata is. I use this to call the function: gamemode = call(getResourceFromName("mapmanager"), "getRunningGamemode") outputChatBox(tostring(gamemode)) Returns: userdata: 020000F5 https://wiki.multitheftauto.com/wiki/Map ... _functions
  20. You arent asking for help, you are asking for someone to do it for you. Im pretty sure that if you at least tried it, that someone would be happy to help you.
  21. You can make it with this function: https://wiki.multitheftauto.com/wiki/Se ... idableWith
  22. Well, i learned something new today. Never test scripts via the map editor. On a server it works perfectly fine. Anyway, thanks for your help!
  23. This doesn't pass "and not ( isPedInVehicle( hitElement )" And if i remove "not", it fires up twice like before. edit: to make things clear, the gamemode is race, so i have to pass the vehicle, but somehow ignore the player.
×
×
  • Create New...