Jump to content

kieran

Members
  • Posts

    367
  • Joined

  • Last visited

Everything posted by kieran

  1. kieran

    Help-me

    @yMelo And what is the issue?
  2. Hey sorry for reviving this topic, but I have came across a problem (again) My killTimer will not work for the event triggered on login! It stops the sound, but it plays it after the timer is done.... I have tried setting element data on login and returning if the player has that data, but it is the exact same..... Any help would be nice, been trying to get this work for the best part of 2 days now... Server Client
  3. @koragg Thanks I solved it, it returns a whole number after I used math.floor..... But, it still doesn't set the timer to the sounds length, here is what I attempted to do, but it plays songs on top of each other.... songs = {} SongNum = 8 songs[1] = "sounds/1.mp3" songs[2] = "sounds/2.mp3" songs[3] = "sounds/3.mp3" songs[4] = "sounds/4.mp3" songs[5] = "sounds/5.mp3" songs[6] = "sounds/6.mp3" songs[7] = "sounds/7.mp3" songs[8] = "sounds/8.mp3" function PlayLoginSound() randomSong = math.random (1, SongNum) sound = playSound(tostring(songs[randomSong]), true) if (sound) then setSoundVolume(sound, 0.5) else return end soundLength = math.floor(getSoundLength ( sound )) --outputChatBox(""..soundLength) <-This shown me it returned a whole number if (soundLength) then setTimer(nextSound, soundLength*100, 1) end end addEventHandler ( "onClientResourceStart", resourceRoot, PlayLoginSound) --Perhaps my problem lays here? I don't know why, it should be triggered on a timer..... function nextSound() soundLength = math.floor(getSoundLength ( sound )) if (soundLength) then sound = playSound(tostring(songs[randomSong]), true) setSoundVolume(sound, 0.8) setTimer(nextSound, soundLength*100, 0) end end function StopLoginSound() stopSound(sound) end addEvent("stoploginsound", true) addEventHandler("stoploginsound", root, StopLoginSound) I know the problem MUST lay in my timer, I just don't know what the problem is Update Okay it works, it plays same song though..... Forgot 1 secong = 1000 ms and not 100 ms, how can I get it to actually play random songs?
  4. I just found out getSoundLength returns the length in seconds, say my song was exactly 2 minutes and 32 milliseconds long, it would return 120.32 The problem is I can't do "getSoundLength*100" because this would return a decimal value! So is there any way I can get the numbers before a decimal point?
  5. Hi, I am trying to make a script that will play a random sound from a table and then continue to play sounds, but I have a problem with the timer, all sounds play at once instead of one after the other... songs = {} SongNum = 2 songs[1] = "sounds/1.mp3" songs[2] = "sounds/2.mp3" --Login Sounds function PlayLoginSound() randomSong = math.random (1, SongNum)--Get a random song from table sound = playSound(tostring(songs[randomSong]), true) --Play the song if (sound) then setSoundVolume(sound, 0.2) --Set the sound volume to 20% else outputDebugString("error") end soundLength = getSoundLength ( sound ) if (soundLength) then setTimer(nextSound, soundLength, 1) end end addEventHandler ( "onClientResourceStart", resourceRoot, PlayLoginSound) function nextSound() soundLength = getSoundLength ( sound ) if (soundLength) then sound = playSound(tostring(songs[randomSong]), true) setSoundVolume(sound, 0.2) setTimer(nextSound, soundLength, 1) end end I have also tried converting "soundLength" to a number. I am basically trying to set a timer, then trigger a function to play the next sound... But both start at the same time, so it isn't a problem with 2 timers being active at once, I will kill timers after I get them starting one at a time, thanks for help.
  6. This has been solved, it was rather simple actually This: addEventHandler("stoploginsound", getRootElement(), StopLoginSound) Should of been this: addEventHandler("stoploginsound", root, StopLoginSound) And finally for my server side code, this: triggerClientEvent(source, "stoploginsound") Should of been this: triggerClientEvent(source, "stoploginsound", source) Hope this will help people that struggle with stopSound.
  7. So just remove the local from when I create the sound or put the local variable outside the function to allow me to stop it with the triggerClientEvent?
  8. This forum is meant for scripting help only, please contact an administrator or moderator on the server you are playing on. This being said I'll answer it anyway since I am a nice guy, to me it looks as if your friend accidentally pressed a button or typed a command that disables the HUD, a lot of servers have this. As I say, ask an admin on the PUBG server.
  9. kieran

    Help-me

    To me it looks like you are trying to add a player to ACL group on marker hit, right? Make sure you have your scripts included in your acl.xml example <group name="Admin"> <acl name="Moderator"></acl> <acl name="SuperModerator"></acl> <acl name="Admin"></acl> <acl name="RPC"></acl> <object name="resource.admin"></object> <object name="resource.webadmin"></object> <object name="resource.acpanel"></object> <object name="resource.SomeFolder"></object>--You will replace "SomeFolder" with your resources folder to allow it to edit your acl.xml The acl.xml file is located here: C:\Program Files (x86)\MTA San Andreas 1.5\server\mods\deathmatch\acl.xml Please tell us what is going wrong.
  10. Hello, I made a simple script to play a sound when my player renders, but I want to stop the sound when the player logs in and can't find out how. Client function PlayLoginSound() local sound = playSound("sounds/2.mp3", true) --Play wasted.mp3 from the sounds folder if (sound) then setSoundVolume(sound, 0.5) -- set the sound volume to 50% else return end end addEventHandler ( "onClientResourceStart", root, PlayLoginSound) function StopLoginSound() stopSound(sound) end addEvent("stoploginsound", true) addEventHandler("stoploginsound", getRootElement(), StopLoginSound) Server --Stop login sound function PlayLogin() triggerClientEvent(source, "stoploginsound") end addEventHandler("onPlayerLogin", root, PlayLogin) Any help would be nice, tried triggering client event from server when player logs in, but keeps playing even if it's not looped...
  11. My hero thanks, can't believe I missed that.
  12. Yeah, here is the original. Server(Original) Client(Original) You can see that a tab panel is used originally, which is not that nice on a login panel... And also there are error messages if you put wrong name/password in which I removed.
  13. I have been messing with a login panel I found on the community, made my own GUI since the one it had didn't center. The problem is, the text from the edit box's won't save to xml file, here is what I have. Client Server Thanks for help, looked over code and it all looks like the working resource.
  14. @Randomly Thanks so much, this works brilliant I understand it a bit better now, although unsure if it will work for many players as I'm doing it solo until I get an emulator on my linux PC. Well, it all works but the isPedOnGround output... But that's not important, important thing is that it's limited 1 vehicle per player now
  15. Yes, I took it out, but I do not know how to get the spawned vehicle when the player goes back into the marker, I never needed to destroy vehicles that are NOT occupied, so here is the very bad code I tried, it says it couldn't get the element from getElementData. Spawn = createMarker (1682.8740234375, -2326.5634765625, 12.5, "cylinder", 1.5, 0, 50, 150, 200) vehicle = {} function ShowPanel (hitElement, matchingDimension) if isElement(hitElement) and getElementType(hitElement) == "player" and matchingDimension then if not isPedOnGround ( hitElement ) then outputChatBox("You must be on foot!", hitElement, 230, 102, 103) end local theVeh = getElementData( hitElement, "freecar" ) if ( theVeh ) == veh then if ( vehicle ) then destroyElement(theVeh) vehicle = nil setElementData(hitElement, "freecar", nil) end end triggerClientEvent("showmenu", hitElement) bindKey ( hitElement, "1", "down", Sanchez ) end end addEventHandler("onMarkerHit", Spawn, ShowPanel) function Sanchez (hitElement) local x, y, z = getElementPosition (hitElement) local rotX, rotY, rotZ = getElementRotation (hitElement) vehicle = createVehicle (468, x, y+5, z, rotX, rotY, 270) warpPedIntoVehicle (hitElement, vehicle) setElementData(hitElement, "freecar", veh) end function DestroyPanel (hitElement, matchingDimension) if isElement(hitElement) and getElementType(hitElement) == "player" and matchingDimension then triggerClientEvent("hidemenu", hitElement) unbindKey ( hitElement, "1", "down", Sanchez ) end end addEventHandler("onMarkerLeave", Spawn, DestroyPanel) Say I have a bike spawned from the marker in the water, and I go back and spawn another, the bike in the water that the player spawned will be destroyed, but it won't destroy other vehicles that other players have spawned from the marker.
  16. This only destroys the vehicle when the player drives into the marker, I want it to destroy the vehicle when a player spawns a new one from the marker... I don't really get what you are saying, do you mean I should get the player first, add them to the table, set the vehicle spawned to there data, and if they have that data to use that in destroyElement when they spawn new vehicle?
  17. Hello, I have made a script that spawns vehicles, to avoid lag I have added the spawned vehicles to a table, I am trying to make it so if the data exists on the table, the vehicle for the player that spawned it only will be destroyed, the problem is, ALL vehicles in the table are destroyed instead of just the players vehicle. Here's my code, I thought of setting element data, but the only way I could think of was setting the players data to the license plate from the vehicle and then checking all vehicles, but this would create a load of lag if many people had vehicles spawned. The other problem is, it is only triggered when you are in the vehicle, I want it to check the player to see if the player has a vehicle spawned anywhere in the map, and then destroy it, I also want it to be activated when the player spawns the car with the bind key, not when they hit the marker. Server Spawn = createMarker (1682.8740234375, -2326.5634765625, 12.5, "cylinder", 1.5, 0, 50, 150, 200) VehiclesTable = {} function ShowPanel (hitElement, matchingDimension) if isElement(hitElement) and getElementType(hitElement) == "player" and matchingDimension then local theVeh = getPedOccupiedVehicle(hitElement) if ( theVeh ) then if ( VehiclesTable[hitElement] ) then destroyElement(theVeh) VehiclesTable[hitElement] = nil end end if isPedOnGround ( hitElement ) then triggerClientEvent("showmenu", hitElement) bindKey ( hitElement, "1", "down", Sanchez ) elseif not isPedOnGround ( hitElement ) then outputChatBox("You must be on foot!", hitElement, 230, 102, 103) end end end addEventHandler("onMarkerHit", Spawn, ShowPanel) function Sanchez (hitElement) local x, y, z = getElementPosition (hitElement) local rotX, rotY, rotZ = getElementRotation (hitElement) VehiclesTable[hitElement] = createVehicle (468, x, y+5, z, rotX, rotY, 270) warpPedIntoVehicle (hitElement, VehiclesTable[hitElement]) end function DestroyPanel (hitElement, matchingDimension) if isElement(hitElement) and getElementType(hitElement) == "player" and matchingDimension and isPedOnGround ( hitElement ) then triggerClientEvent("hidemenu", hitElement) unbindKey ( hitElement, "1", "down", Sanchez ) end end addEventHandler("onMarkerLeave", Spawn, DestroyPanel) The client stuff is just Dx window. And my isPedOnGround isn't working. Thanks for your help!
  18. Thanks, that's so simple sorry, this is my first time doing Dx drawing that needs to go when you leave marker, helped a lot
  19. Thanks, but um... The whole point is that it shows the panel then destroys it when you leave, I know how to destroy elements and set a GUI's visibility, but how can I destroy a Dx element...? Here is updated code (change names so makes more sense) Client Server Thanks for help
  20. Hello, I am creating a simple script to show a DX rectangle and text when a player hits a marker, it is for a vehicle system but I can do all but keep the DX box showing. It flashes up when you hit the marker then it just vanishes... I don't know why and I am struggling to understand why it just stays for a second then goes away, the code is below. Server --Make the markers CarSpawn = createMarker (1682.8740234375, -2326.5634765625, 12.5, "cylinder", 1.5, 0, 50, 150, 200) --When the player hits the marker trigger an event to create a GUI function FreeCars (hitElement, matchingDimension) if isElement(hitElement) and getElementType(hitElement) == "player" and matchingDimension and isPedOnGround ( hitElement ) then triggerClientEvent("showfreecar", hitElement)--This shows, then vanishes... else outputChatBox("You need to be on foot", hitElement, 230, 102, 103) end end addEventHandler("onMarkerHit", CarSpawn, FreeCars) --still to make all the spawn stuff and system to check spawned vehicles, but this is relatively easy. Client function FreeCarGUI() dxDrawLine(307 - 1, 458 - 1, 307 - 1, 590, tocolor(0, 0, 0, 255), 1, false) dxDrawLine(493, 458 - 1, 307 - 1, 458 - 1, tocolor(0, 0, 0, 255), 1, false) dxDrawLine(307 - 1, 590, 493, 590, tocolor(0, 0, 0, 255), 1, false) dxDrawLine(493, 590, 493, 458 - 1, tocolor(0, 0, 0, 255), 1, false) dxDrawRectangle(307, 458, 186, 132, tocolor(12, 49, 206, 152), false) dxDrawText("1. Sanchez", 323 - 1, 473 - 1, 476 - 1, 510 - 1, tocolor(234, 242, 18, 111), 2.50, "default", "left", "top", false, false, false, false, false) dxDrawText("1. Sanchez", 323 + 1, 473 - 1, 476 + 1, 510 - 1, tocolor(234, 242, 18, 111), 2.50, "default", "left", "top", false, false, false, false, false) dxDrawText("1. Sanchez", 323 - 1, 473 + 1, 476 - 1, 510 + 1, tocolor(234, 242, 18, 111), 2.50, "default", "left", "top", false, false, false, false, false) dxDrawText("1. Sanchez", 323 + 1, 473 + 1, 476 + 1, 510 + 1, tocolor(234, 242, 18, 111), 2.50, "default", "left", "top", false, false, false, false, false) dxDrawText("1. Sanchez", 323, 473, 476, 510, tocolor(0, 0, 0, 172), 2.50, "default", "left", "top", false, false, false, false, false) end addEvent("showfreecar", true) addEventHandler("showfreecar", root, FreeCarGUI) Thank you for any help. I used Remp's GUI editor for this, I am very bad with DX elements.
  21. It says it gets the account when the player logs in, so clearly not the player..... Here is the script that gets and saves a players team. --Team save function onPlayQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then -- if the player is logged in local myTeam = getPlayerTeam ( source ) if (myTeam) then local currentTeam = getTeamName ( myTeam ) setAccountData ( playeraccount, "TeamLog", currentTeam ) -- save it in his account end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayQuit ) --Team load function onPlayLogin (_, playeraccount ) if ( playeraccount ) then local LoadTeam = getAccountData ( playeraccount, "TeamLog" ) if ( LoadTeam ) then teamLoad = getTeamFromName ( LoadTeam ) setPlayerTeam ( source, teamLoad ) end end end addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayLogin ) It says: [2017-09-05 16:33:00] WARNING: IronMiner\Iron_Miner_S.lua:95: Bad argument @ 'getPlayerTeam' [Expected player at argument 1, got account] [2017-09-05 16:33:00] WARNING: IronMiner\Iron_Miner_S.lua:96: Bad argument @ 'getTeamName' [Expected team at argument 1, got boolean] So it is getting account, NOT player, I am wanting to know how to get the player only... remember what I said originally, I tried player, source, etc... But same result, source does notihng and player gets account. Same thing happens when I assign "thePlayer" to the function, as you shown me with player, it does the exact same.... At a wall here haha, all I need is to get the players team and trigger an event if that player is in the specified team when they log in.
  22. I'm trying to get the player when he joins and trigger an event tied to a function, it originally has a marker, you hit marker then you start the script, it works with adding a command handler to the function, but I can't just add an onPlayerLogin event as I want it to check team. Here's all you should need to save confusion. Function to trigger client side event (works 100%) IronMarker = createMarker (327.93359375, 865.84765625, 19.0625, "cylinder", 2, 0, 200, 55, 255) local IronMinerTeam = createTeam("Iron_Miner", 20, 100, 150) IronJobBlip = createBlipAttachedTo ( IronMarker, 56 ) function IronMiner ( hitElement, matchingDimension ) if isElement(hitElement) and getElementType(hitElement) == "player" and matchingDimension then if getElementData( hitElement, "Iron.pres" ) == nil then setElementData (hitElement, "Iron.pres", 0) --outputChatBox("You have successfully registered as an iron miner, please enter the marker again to start working!", hitElement, 255, 0, 0) end if ( IronMinerTeam ) then if isPedOnGround ( hitElement ) then setPlayerTeam(hitElement, IronMinerTeam) --triggerClientEvent ( hitElement, "ShowIron", hitElement ) local TheIron = getElementData( hitElement, "Iron.pres" ) if (TheIron) then if ( tonumber (TheIron) >= tonumber (9999999)) then outputChatBox ("You may only mine iron if your iron is below 99999999, please sell some at the T icon on F11 or by typing: /selliron amount", hitElement, 255, 0, 0) elseif ( tonumber (TheIron) <= tonumber (9999999) or nil) then triggerClientEvent ( hitElement, "IronMinerStuff", hitElement ) else outputChatBox("You must be on foot to change team!", hitElement, 255, 0, 0) end end end end end end addEvent("IronLoginEvent", true) addEventHandler("IronLoginEvent", getRootElement(), IronMiner) addEventHandler("onMarkerHit", IronMarker, IronMiner) Function that is not working (Meant to trigger the event above) function LoginHandler () local checkTeam = getTeamFromName("Iron_Miner") if ( checkTeam ) then local playerTeam = getPlayerTeam(player) if ( playerTeam == checkTeam ) then triggerEvent ( "IronLoginEvent", player ) end end end addEventHandler("onPlayerLogin", root, LoginHandler) So it keeps showing up with error on line 5 (on second code snippet) saying that it expected a player at argument one where getPlayerTeam is, I tried localPlayer and source.... How do I get the player? This is meant to trigger client event to make a marker and a blip, that's all. Thanks for help.
  23. Got it working, turns out that it was working... Must of forgot to restart the resource last time thanks anyways!
  24. function registerPlayer(username,password) if not (username == "") then if not (password == "") then local account = getAccount (username,password) if (account == false) then local accountAdded = addAccount(tostring(username),tostring(password)) if (accountAdded) then outputChatBox ("#FF0000* #00FF00You have sucessfuly registered! [Username: #FFFFFF" .. username .. " #00FF00| Password: #FFFFFF" .. password .. "#00FF00 ]",source,255,255,255,true ) triggerClientEvent (source,"hideLoginWindow",getRootElement()) end end end end end addEvent("onRequestRegister",true) addEventHandler("onRequestRegister",getRootElement(),registerPlayer) THIS is onRequestRegister, what it does is checks the 2 edits "username" and "password", if the account isn't there it then adds the account and outputs a message. In theory when a player registers, if I do: Everyone = createTeam ( "Everyone", 0, 255, 0 ) function regteam () setPlayerTeam ( source, Everyone ) outputChatBox ("Please press F1 for information and rules", source, 255, 50, 100) end addEventHandler("onRequestRegister",getRootElement(),regteam) The players team should be set.... But I don't know if I should just use localPlayer or onPlayerLogin.... I am slightly confusing myself basically I am going to make it to set the new registered players team and since there is no native event to check if an account is added for the first time, I am just trying to use the one on login panel.
  25. Hey, so I made a custom event with my login script, basically when a player registers an account it sets team to "Everyone" it was working, but my MTA messed up and I forget how I done it, scripts are below, any help would be great! Team Change Everyone = createTeam ( "Everyone", 0, 255, 0 ) function regteam () setPlayerTeam ( source, Everyone ) outputChatBox ("Please press F1 for information and rules", source, 255, 50, 100) end addEventHandler("onRequestRegister",getRootElement(),regteam) As you can see, this has a custom event to change team. Custom Event function registerPlayer(username,password) if not (username == "") then if not (password == "") then local account = getAccount (username,password) if (account == false) then local accountAdded = addAccount(tostring(username),tostring(password)) if (accountAdded) then outputChatBox ("#FF0000* #00FF00You have sucessfuly registered! [Username: #FFFFFF" .. username .. " #00FF00| Password: #FFFFFF" .. password .. "#00FF00 ]",source,255,255,255,true ) triggerClientEvent (source,"hideLoginWindow",getRootElement()) end end end end end addEvent("onRequestRegister",true) addEventHandler("onRequestRegister",getRootElement(),registerPlayer) Here is the event I have. When a player clicks "register" this event is triggered, all scripts are server side... Apart from the GUI of course It all works, but won't set team someone know where I gone wrong?
×
×
  • Create New...