Hero192 Posted August 31, 2015 Share Posted August 31, 2015 (edited) I made an hospital system, i did that when the player spawn in the Nearest hospital he be alpha 155 and i added timer for it. Also i made an Spawner system my problem is, i want to check if the timer still not ended from hospital system then the player spawn a vehicle with alpha 155 and if the timer ended the player spawn a car with alpha 255 ,thats all addEvent ("Hospital", true) addEventHandler ("Hospital", root, function ( data ) spawnPlayer (source, data[2], data[3], data[4]+2, data[8], data[9], 0, 0) setCameraTarget (source,source) setElementData ( source, "SpawnProtectionEnabled", true ) setElementData ( source, "GodmodeEnabled", true ) setElementAlpha ( source, 150 ) toggleControl ( source, "fire", false ) toggleControl ( source, "next_weapon", false ) toggleControl ( source, "previous_weapon", false ) setTimer ( function ( source ) setElementData ( source, "GodmodeEnabled", false ) setElementData ( source, "SpawnProtectionEnabled", false ) setElementAlpha ( source, 255 ) toggleControl ( source, "fire", true ) toggleControl ( source, "next_weapon", true ) toggleControl ( source, "previous_weapon", true ) end, 10000, 1, source ) end) so i want to check if the SpawnProtectionEnabled == false then the setElementAlpha be 255 i tried that in the spawner system but doesn't working here's the part of my code when the player spawn a VEHICLE: addEvent("spawn",true) addEventHandler("spawn",root, function (player, ID, marker) if isElement(Vehicles[player]) then destroyElement(Vehicles[player]) end local x, y, z = getElementPosition(marker) Vehicles[player] = createVehicle(ID, x, y, z+3, 0, 0, markers[marker][3]) warpPedIntoVehicle(player, Vehicles[player]) setElementData(Vehicles[player],"allowedRoles",markers[marker][1]) setElementData(Vehicles[player],"allowedData",markers[marker][4]) if (Vehicles[player] and getElementData ( player, "isSpawnProtectionEnabled" ) == true) then setElementData ( player, "isSpawnProtectionEnabled", true ) setElementData ( player, "isGodmodeEnabled", true ) setElementAlpha ( Vehicles[player], 150 ) toggleControl ( player, "fire", false ) toggleControl ( player, "next_weapon", false ) toggleControl ( player, "previous_weapon", false ) elseif (veh and getElementData ( player, "isSpawnProtectionEnabled" ) == false) then setElementData ( player, "isGodmodeEnabled", false ) setElementData ( player, "isSpawnProtectionEnabled", false ) setElementAlpha ( Vehicles[player], 255 ) toggleControl ( player, "fire", true ) toggleControl ( player, "next_weapon", true ) toggleControl ( player, "previous_weapon", true ) end end) Edited August 31, 2015 by Guest Link to comment
HUNGRY:3 Posted August 31, 2015 Share Posted August 31, 2015 setElementAlpha -- invisible cancelEvent() "onClientPlayerDamage" Link to comment
MAB Posted August 31, 2015 Share Posted August 31, 2015 Anyone? You didn't understand hungry?! Link to comment
Hero192 Posted September 1, 2015 Author Share Posted September 1, 2015 I didn't, it doesn't fit my problem Link to comment
ozulus Posted September 1, 2015 Share Posted September 1, 2015 Use setTimer. Just like that: addEvent("spawn",true) addEventHandler("spawn",root, function (player, ID, marker) if isElement(Vehicles[player]) then destroyElement(Vehicles[player]) end local x, y, z = getElementPosition(marker) Vehicles[player] = createVehicle(ID, x, y, z+3, 0, 0, markers[marker][3]) warpPedIntoVehicle(player, Vehicles[player]) setElementData(Vehicles[player],"allowedRoles",markers[marker][1]) setElementData(Vehicles[player],"allowedData",markers[marker][4]) if (Vehicles[player] and getElementData ( player, "isSpawnProtectionEnabled" ) == true) then setElementData ( player, "isSpawnProtectionEnabled", true ) setElementData ( player, "isGodmodeEnabled", true ) setElementAlpha ( Vehicles[player], 150 ) toggleControl ( player, "fire", false ) toggleControl ( player, "next_weapon", false ) toggleControl ( player, "previous_weapon", false ) setTimer( function(player) setElementData ( player, "isGodmodeEnabled", false ) setElementData ( player, "isSpawnProtectionEnabled", false ) setElementAlpha ( Vehicles[player], 255 ) toggleControl ( player, "fire", true ) toggleControl ( player, "next_weapon", true ) toggleControl ( player, "previous_weapon", true ) end,10000,1,player) else setElementData ( player, "isGodmodeEnabled", false ) setElementData ( player, "isSpawnProtectionEnabled", false ) setElementAlpha ( Vehicles[player], 255 ) toggleControl ( player, "fire", true ) toggleControl ( player, "next_weapon", true ) toggleControl ( player, "previous_weapon", true ) end end) Link to comment
Hero192 Posted September 1, 2015 Author Share Posted September 1, 2015 Okay,how to use setElementData for this setTimer and i want to get this elementdata for checking if this getElementData == true then the ghost mod be working and if it's ended mean false so then it must back to 255 ALPHA, NOTE: i want to use getElementData because i have to use this ghost system in other script Help me please if you know Link to comment
ozulus Posted September 1, 2015 Share Posted September 1, 2015 You can use onElementDataChange for check data. function outputChange(dataName,oldValue) if getElementType(source) == "player" and dataName == "isSpawnProtectionEnabled" then local ghostmode = getElementData(source,"isSpawnProtectionEnabled") if ghostmode == false then -- do nothing else -- add your own function here ex: disableGhostMode(source) -- use setTimer in disable ghost mode function end end end addEventHandler("onElementDataChange",getRootElement(),outputChange) if you want you can make your own function it would be better to use Sorry for my bad English, i hope you'll understand Link to comment
Hero192 Posted September 1, 2015 Author Share Posted September 1, 2015 Thanks can you help me to create the setElementData of isSpawnProtectionEnabled to use the getElementData because i tried it and i failed , i hope you give me a hand on that Link to comment
ozulus Posted September 1, 2015 Share Posted September 1, 2015 function enableGhostMode(player) setElementData ( player, "SpawnProtectionEnabled", true ) setElementData ( player, "GodmodeEnabled", true ) setElementAlpha ( player, 150 ) toggleControl ( player, "fire", false ) toggleControl ( player, "next_weapon", false ) toggleControl ( player, "previous_weapon", false ) end function disableGhostMode(player) setElementData ( player, "GodmodeEnabled", false ) setElementData ( player, "SpawnProtectionEnabled", false ) setElementAlpha ( player, 255 ) toggleControl ( player, "fire", true ) toggleControl ( player, "next_weapon", true ) toggleControl ( player, "previous_weapon", true ) end Usage: addEvent ("Hospital", true) addEventHandler ("Hospital", root, function ( data ) spawnPlayer (source, data[2], data[3], data[4]+2, data[8], data[9], 0, 0) setCameraTarget (source,source) enableGhostMode(source) -- like that setTimer ( function ( source ) disableGhostMode(source) -- like that end, 10000, 1, source ) end) Link to comment
Hero192 Posted September 1, 2015 Author Share Posted September 1, 2015 Okay thanks , now we made the ghost system so how we can use this by getElementData from spawner system when the player spawn a car his vehicle should be with the ghost system , if the timer of ghostmod still not false i mean not 0 so the vehicle should be with the ghost mod too if the ghost mod ended then the vehicle will back to 255 ALPHA , i hope you can solve for me this because thats what i need 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