Hazard| Posted June 18, 2014 Share Posted June 18, 2014 Hello, I'm wondering how you use getElementData in this example (below) to disable / enable the blowVehicle, like if you do /speckill then it outputs to the chatbox > Hazard enables spectator kill / Hazard disables spectator kill. disable = normal (not blowing any vehicles) enable = blows all the vehicles in the spectatorteam function spectatorkill () local theSpectatorTeam = getTeamFromName("Spectators") if ( theSpectatorTeam ) then local players = getPlayersInTeam ( theSpectatorTeam ) for key, player in ipairs ( players ) do local theVehicle = getPedOccupiedVehicle ( player ) if ( theVehicle ) then blowVehicle(theVehicle,false) end end end end) addCommandHandler("speckill", spectatorkill) Could you do it? I would really appreciate that. Thanks alot This is what I mean with getElementData function toggleRespawnModeFunc ( player ) local now = getElementData ( getRootElement ( ), "cwRespawn", true ) if now then state = "disabled" else state = "enabled" end echo ( "*"..getUncolored ( player ).. " has " ..state.." respawn mode" ) setElementData ( getRootElement ( ), "cwRespawn", not now ) setElementData ( resRoot, "respawn", getElementData ( getRootElement ( ), "cwRespawn" ) ) -- end end addCommandHandler ( "respawn", toggleRespawnModeFunc ) setElementData ( resRoot, "respawn", getElementData ( getRootElement ( ), "cwRespawn" ) ) Link to comment
ADCX Posted June 18, 2014 Share Posted June 18, 2014 Code: function spectatorkill() if (getElementData(getRootElement(),"BlowVehicleEnabled")) then local theSpectatorTeam = getTeamFromName("Spectators") if ( theSpectatorTeam ) then local players = getPlayersInTeam ( theSpectatorTeam ) for key, player in ipairs ( players ) do local theVehicle = getPedOccupiedVehicle ( player ) if ( theVehicle ) then blowVehicle(theVehicle,false) end end end else outputChatBox("This command is disabled!") end end addCommandHandler("speckill", spectatorkill) By default, it will be disabled. To enable it, use setElementData. Link to comment
Hazard| Posted June 18, 2014 Author Share Posted June 18, 2014 Like this? function spectatorkill() if (getElementData(getRootElement(),"BlowVehicleEnabled")) then setElementData ( getRootElement ( ), "BlowVehicleEnabled", true ) local theSpectatorTeam = getTeamFromName("Spectators") if ( theSpectatorTeam ) then local players = getPlayersInTeam ( theSpectatorTeam ) for key, player in ipairs ( players ) do local theVehicle = getPedOccupiedVehicle ( player ) if ( theVehicle ) then blowVehicle(theVehicle,false) end end end else outputChatBox("This command is disabled!") end end addCommandHandler("speckill", spectatorkill) Link to comment
ADCX Posted June 18, 2014 Share Posted June 18, 2014 Well that additional setElementData that you added won't do anything since it already has to be true to even execute that part of the code. Element data is not predefined, think of it like a variable storage for element or object. Link to comment
Et-win Posted June 19, 2014 Share Posted June 19, 2014 May I ask why you want to use get/setElementData and not a variable? 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