Gastonito Posted January 9, 2017 Share Posted January 9, 2017 Hello guys, i made these functions with some help of a friend, but idk why it isnt working, there are no errors, etc ... Client Side : --Flying Car elseif ( source == vehfly ) then triggerServerEvent("toggle_aircars",localPlayer) else triggerServerEvent("disable_aircars",localPlayer) addEventHandler ( "onClientGUIClick", root, function ( ) if (source == vehfly) then if (guiGetText (source) == 'Flying On') then guiSetText (source,'Flying Off') elseif (guiGetText (source) == 'Flying Off') then guiSetText (source, 'Flying On') end end end ) addEvent("toggle_aircars", true) function toggle_aircars(eventVeh) for i, veh in ipairs(getElementsByType("vehicle")) do if isWorldSpecialPropertyEnabled("aircars") then setWorldSpecialPropertyEnabled("aircars", false, eventVeh) end end end addEventHandler("toggle_aircars", root, toggle_aircars) addEvent("disable_aircars", true) function disable_aircars(eventVeh) for i, veh in ipairs(getElementsByType("vehicle")) do if isWorldSpecialPropertyEnabled("aircars") then setWorldSpecialPropertyEnabled("aircars", true, eventVeh) end end end addEventHandler("disable_aircars", root, disable_aircars) Server Side : addEvent("toggle_aircars", true) function toggle_aircars() for eventPlayers in pairs(WrapedPlayers) do local eventManager = getAccountName(getPlayerAccount(source)) if ( eventVehicles[eventManager] ) then for i, eventVeh in ipairs ( eventVehicles[eventManager] ) do triggerClientEvent("toggle_aircars", source, eventVeh) end end exports.SAEGcommands:sendMessage("Vehicle Flying has been Enabled by "..getPlayerName(client), 0, 255, 0,eventPlayers) end end addEventHandler("toggle_aircars", root, toggle_aircars) addEvent("disable_aircars", true) function disable_aircars() for eventPlayers in pairs(WrapedPlayers) do local eventManager = getAccountName(getPlayerAccount(source)) if ( eventVehicles[eventManager] ) then for i, eventVeh in ipairs ( eventVehicles[eventManager] ) do triggerClientEvent("disable_aircars", source, eventVeh) end end exports.SAEGcommands:sendMessage("Vehicle Flying has been Dis abled by "..getPlayerName(client), 255, 0, 0,eventPlayers) end end addEventHandler("disable_aircars", root, disable_aircars) Link to comment
Gastonito Posted January 9, 2017 Author Share Posted January 9, 2017 Please guys i need help ... Link to comment
Adolfram Posted January 9, 2017 Share Posted January 9, 2017 there are so many wrong things in your code. first of all, for i, eventVeh in ipairs ( eventVehicles[eventManager] ) do triggerClientEvent("disable_aircars", source, eventVeh) end this is ok but in client, for i, veh in ipairs(getElementsByType("vehicle")) do if isWorldSpecialPropertyEnabled("aircars") then setWorldSpecialPropertyEnabled("aircars", true, eventVeh) end this makes it all wrong. there is no 3rd arg in that function so the loop is useless. if you want to make it only enabled when a player gets in the event car, pass the event vehicles to client and check on onClientVehicleEnter and then enable property. Link to comment
Gastonito Posted January 9, 2017 Author Share Posted January 9, 2017 1 hour ago, Adolfram said: there are so many wrong things in your code. first of all, for i, eventVeh in ipairs ( eventVehicles[eventManager] ) do triggerClientEvent("disable_aircars", source, eventVeh) end this is ok but in client, for i, veh in ipairs(getElementsByType("vehicle")) do if isWorldSpecialPropertyEnabled("aircars") then setWorldSpecialPropertyEnabled("aircars", true, eventVeh) end this makes it all wrong. there is no 3rd arg in that function so the loop is useless. if you want to make it only enabled when a player gets in the event car, pass the event vehicles to client and check on onClientVehicleEnter and then enable property. No u dont undrestand, i dont want it when the player enters the car, its a gui ( event panel ) its made so if the event manager clicks the button the flying gets enabled for event vehicles Link to comment
Gastonito Posted January 10, 2017 Author Share Posted January 10, 2017 FFS why none wants to help dirrabkom ? ..... Link to comment
pa3ck Posted January 10, 2017 Share Posted January 10, 2017 Did you just say "FFS" to get help from volunteers? Link to comment
Moderators IIYAMA Posted January 10, 2017 Moderators Share Posted January 10, 2017 @Angel02 Why don't place some debuglines in your code? Simply: outputDebugString("HEY this **** is actually working!") (you can view those in your debugscript) and if it doesn't output, you know you have done something wrong in the code before that message. Easy right? Just fill up your entire code with debug messages and you will know @Angel02 "FFS"!!! what's @Angel02 "f.ing" going on! and after you showed me what's wrong, I am happy to help. YES? Link to comment
Gastonito Posted January 11, 2017 Author Share Posted January 11, 2017 14 hours ago, IIYAMA said: @Angel02 Why don't place some debuglines in your code? Simply: outputDebugString("HEY this **** is actually working!") (you can view those in your debugscript) and if it doesn't output, you know you have done something wrong in the code before that message. Easy right? Just fill up your entire code with debug messages and you will know @Angel02 "FFS"!!! what's @Angel02 "f.ing" going on! and after you showed me what's wrong, I am happy to help. YES? Yeah, Sry for being rue but i was mad cuz none helped me. Anyways, i tryied that already, the debugging messages showed up, the script is actually working, but the flying isnt working :C Link to comment
Gastonito Posted January 12, 2017 Author Share Posted January 12, 2017 Please ....... Link to comment
Syntrax# Posted January 12, 2017 Share Posted January 12, 2017 This code is a real mess, wtf should EventPlayers and WrapedPlayers even mean, since i don't see it being defined. Thanks to this it can be everything or maybe you didn't post the full code.But without that it's not easy to fix this. triggerClientEvent(source, "disable_aircars", source, eventVeh) triggerClientEvent(source, "toggle_aircars", source, eventVeh) triggerClientEvent(source, "disable_aircars", source, eventVeh) triggerClientEvent(source, "toggle_aircars", source, eventVeh) triggerClientEvent always must be like this triggerClientEvent(element, "exportname", playertorecieve, arguments, ...) Link to comment
Moderators IIYAMA Posted January 13, 2017 Moderators Share Posted January 13, 2017 (edited) setWorldSpecialPropertyEnabled doesn't accept specific cars, it is ONLY ON or OFF per player for ALL cars. You should use(serverside) https://wiki.multitheftauto.com/wiki/OnVehicleEnter to check if he has access to the vehicle. triggerClientEvent > setWorldSpecialPropertyEnabled And(serverside) https://wiki.multitheftauto.com/wiki/OnVehicleExit + https://wiki.multitheftauto.com/wiki/OnPlayerWasted to disable it: triggerClientEvent > setWorldSpecialPropertyEnabled With other words, you have to rewrite your code from the start. Although it is written simpler than you have right now :). Edited January 13, 2017 by IIYAMA Link to comment
Gastonito Posted January 14, 2017 Author Share Posted January 14, 2017 It got fixed by the :O @Simple01 --SERV SIDE addEvent("toggle_aircars", true) function toggle_aircars() for eventPlayers in pairs(WrapedPlayers) do local eventManager = getAccountName(getPlayerAccount(source)) if ( eventVehicles[eventManager] ) then for eventPlayer in pairs( WrapedPlayers ) do triggerClientEvent( eventPlayer, "toggle_client_aircars", eventPlayer ) exports.SAEGcommands:sendMessage("Vehicle Flying has been Enabled by "..getPlayerName(client), 0, 255, 0,eventPlayers) end end end end addEventHandler("toggle_aircars", root, toggle_aircars) addEvent("disable_aircars", true) function disable_aircars() for eventPlayers in pairs(WrapedPlayers) do local eventManager = getAccountName(getPlayerAccount(source)) if ( eventVehicles[eventManager] ) then for eventPlayer in pairs( WrapedPlayers ) do triggerClientEvent( eventPlayer, "disable_client_aircars", eventPlayer ) end exports.SAEGcommands:sendMessage("Vehicle Flying has been Disabled by "..getPlayerName(client), 255, 0, 0,eventPlayers) end end end addEventHandler("disable_aircars", root, disable_aircars) --CLIENT SIDE addEvent("toggle_client_aircars", true) function toggle_aircars(eventVeh) if not ( isWorldSpecialPropertyEnabled("aircars") ) then setWorldSpecialPropertyEnabled("aircars", true) end end addEventHandler("toggle_client_aircars", root, toggle_aircars) addEvent("disable_client_aircars", true) function disable_aircars(eventVeh) if isWorldSpecialPropertyEnabled("aircars") then setWorldSpecialPropertyEnabled("aircars", false) end end addEventHandler("disable_client_aircars", root, disable_aircars) Link to comment
Moderators IIYAMA Posted January 16, 2017 Moderators Share Posted January 16, 2017 Here you have some more: tips, optimisations and clean up. Good luck! Serverside: An account name is an 'eventManager'? 'eventVehicles' contains account names? You should name them after what they will contain or what function they have. Also you have now 2 loops per block, only the inner loop is required to operate the system: (if you don't remove this: playerCount * playerCount = loop length) for eventPlayers in pairs(WrapedPlayers) do local eventManager = getAccountName(getPlayerAccount(source)) if ( eventVehicles[eventManager] ) then for eventPlayer in pairs( WrapedPlayers ) do triggerClientEvent( eventPlayer, "toggle_client_aircars", eventPlayer ) exports.SAEGcommands:sendMessage("Vehicle Flying has been Enabled by "..getPlayerName(client), 0, 255, 0,eventPlayers) end end end Clientside: function toggle_aircars(eventVeh) function toggle_aircars(eventVeh) -- clean up function disable_aircars(eventVeh) function disable_aircars(eventVeh) -- clean up 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now