Hero192 Posted September 5, 2015 Share Posted September 5, 2015 Hey guys, i made an hospital system with spawn protection also i made vehicle spawner ,so my problem is i want to check if the disableGhostMode function is still running and the timer isn't false i mean 0sec. 1st code part is the spawnprotection its in hospital resource. 2nd code part is the vehicle spawner system in other resource, and its what im looking for, i want to know how to do an getElementData and setElementData in this situation to check if the timer is still not 0 sec or false if it still working not false then when a player spawn a car from the spawner system the vehicle be with 140ALPHA too and if the timer is on the 0sec then the vehicle should back to 255 ALPHA. --1st code part is the spawnprotection function enableGhostMode(player) setElementData( player, "spawnProtection", true ) toggleControl ( player,"fire", false ) toggleControl ( player,"next_weapon", false ) toggleControl ( player,"previous_weapon", false ) setElementAlpha( player, 170 ) end function disableGhostMode(player) setElementData(player,"disableGhostMode",disableGhostMode) setTimer( setElementData, 15000, 1, player, "spawnProtection", false ) setTimer( toggleControl, 15000, 1, player,"fire", true ) setTimer( toggleControl, 15000, 1, player,"next_weapon", true ) setTimer( toggleControl, 15000, 1, player,"previous_weapon", true ) setTimer( setElementAlpha, 15000, 1,player, 255 ) end --2nd code part is the vehicle spawner system addEvent("spawner",true) addEventHandler("spawner",root, function (player, vehicleID, marker) local x, y, z = getElementPosition(marker) Vehicles[player] = createVehicle(vehicleID, x, y, z+2, 0, 0, markers[marker][3]) warpPedIntoVehicle(player, Vehicles[player]) local Vehicle = Vehicles[player] local disableGhostMode= getElementData(player, "disableGhostMode") if not disableGhostModethen return end if (disableGhostMode== true) then setElementAlpha ( Vehicle, 150 ) else setElementAlpha ( Vehicle, 250 ) end end) I hope someone can help me because i stuck here.. thanks in advance Link to comment
Hero192 Posted September 5, 2015 Author Share Posted September 5, 2015 Anyone please,im stuck here i tried alot of time but i out without result Link to comment
JR10 Posted September 5, 2015 Share Posted September 5, 2015 You can use isTimer to check if a timer is still running. You can also use getTickCount and store it in a table where the key is the player, then on spawning the vehicle calculate how many seconds passed. Link to comment
Hero192 Posted September 5, 2015 Author Share Posted September 5, 2015 I tried what JR10 said but i failed can anyone help me? Link to comment
Hero192 Posted September 5, 2015 Author Share Posted September 5, 2015 When the player spawn the vehicle i checked with the function isTimer like what you said if the timer still running or not but doesn't works Also please can you look at the elemnt datas because im not sure of myself if they're correct i still have no experience with elementdatas. addEvent("spawner",true) addEventHandler("spawner",root, function (player, vehicleID, marker) local x, y, z = getElementPosition(marker) Vehicles[player] = createVehicle(vehicleID, x, y, z+2, 0, 0, markers[marker][3]) warpPedIntoVehicle(player, Vehicles[player]) local Vehicle = Vehicles[player] local disableGhostMode= getElementData(player, "disableGhostMode") if not disableGhostMode then return end if isTimer disableGhostMode[player] then --Here where is the problem... setElementAlpha ( Vehicle, 150 ) else setElementAlpha ( Vehicle, 250 ) end end) Link to comment
JR10 Posted September 5, 2015 Share Posted September 5, 2015 You're missing a pair of parentheses. isTimer(disableGhostMode[player]) Next time, use /debugscript3 to look for errors and warnings. 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