Price. Posted July 17, 2016 Share Posted July 17, 2016 (edited) Fixed Edited July 18, 2016 by Guest Link to comment
Walid Posted July 17, 2016 Share Posted July 17, 2016 Done fixed local timersTable = {} local islandCOL = createColRectangle (3528.18994, -326.39496, 1000, 300 ) function Island (player) if player and isElement(player) and (getElementType(player) == "player") then local player = (isPedInVehicle(player) and getVehicleController (getPedOccupiedVehicle (player))) or player local account = getPlayerAccount(player) if account and not isGuestAccount(account) then local accName = getAccountName(account) if ( isObjectInACLGroup ("user."..accName, aclGetGroup ("Admin"))) then return false end if eventName == "onColShapeHit" then if not(timersTable[player]) then timersTable[player] = setTimer(killPed, 20000, 1, player) outputChatBox("You have entered Staff Island, you have 20 seconds to leave or you'll be killed.", player, 255, 0, 0, true) end elseif eventName == "onColShapeLeave" then if isTimer(timersTable[player]) then killTimer(timersTable[player]) timersTable[player] = nil outputChatBox("You have left the area.", player, 0, 200, 0) end end end end end addEventHandler ( "onColShapeHit", islandCOL, Island) addEventHandler ( "onColShapeLeave", islandCOL, Island) addEventHandler( "onPlayerWasted", getRootElement( ), function() if isTimer(timersTable[source]) then killTimer(timersTable[source]) timersTable[source] = nil end end ) Link to comment
Price. Posted July 17, 2016 Author Share Posted July 17, 2016 when I enter the col shape, I pretty much think it doesn't let the timer go on from where it left off when I entered first time, I entered a lot and every time I go out and go on several times, I don't die so I pretty much think the timer doesnt save where it left off Link to comment
Walid Posted July 17, 2016 Share Posted July 17, 2016 when I enter the col shape, I pretty much think it doesn't let the timer go on from where it left off when I entered first time, I entered a lot and every time I go out and go on several times, I don't die so I pretty much think the timer doesnt save where it left off The timer will be killed when you leave the colship. read my code again Link to comment
Price. Posted July 17, 2016 Author Share Posted July 17, 2016 I want it to be saved so when the player keeps getting out and inside the col shape it continues from where it left off so the player doesn't abuse going out and it Link to comment
Walid Posted July 17, 2016 Share Posted July 17, 2016 I want it to be saved so when the player keeps getting out and inside the col shape it continues from where it left off so the player doesn't abuse going out and it So all what you need is: getTimerDetails () setElementData() getElementData() Link to comment
Price. Posted July 17, 2016 Author Share Posted July 17, 2016 getElement data doesn't save if he logs out of the server and logs in too, I honestly don't like to use element data, isn't there a way around to save it using account, same style you used? Link to comment
Walid Posted July 17, 2016 Share Posted July 17, 2016 getElement data doesn't save if he logs out of the server and logs in too, I honestly don't like to use element data, isn't there a way around to save it using account, same style you used? bro it's only 20 seconds , anyways you can use setAccountData() getAccountData() For more information , Check my answer, they already asked the same question Here Link to comment
Price. Posted July 17, 2016 Author Share Posted July 17, 2016 is it possible to save using getPlayerAccount? bec its already there and I think I saved a time before using it instead of accountdata Link to comment
Price. Posted July 17, 2016 Author Share Posted July 17, 2016 still can't figure out how to save the time so when he enters again the timer continues where it left off Link to comment
Walid Posted July 17, 2016 Share Posted July 17, 2016 is it possible to save using getPlayerAccount? bec its already there and I think I saved a time before using it instead of accountdata still can't figure out how to save the time so when he enters again the timer continues where it left off Here is all what you need: local timersTable = {} local islandCOL = createColRectangle (3528.18994, -326.39496, 1000, 300 ) function Island (player) if player and isElement(player) and (getElementType(player) == "player") then local player = (isPedInVehicle(player) and getVehicleController (getPedOccupiedVehicle (player))) or player local account = getPlayerAccount(player) if account and not isGuestAccount(account) then local accName = getAccountName(account) if ( isObjectInACLGroup ("user."..accName, aclGetGroup ("Admin"))) then return false end if eventName == "onColShapeHit" then local timer = getAccountData(account, "timer") -- get the timer using getAccountData if (timer) then timersTable[player] = setTimer(killPed, tonumber(timer), 1, player) else if not(timersTable[player]) then timersTable[player] = setTimer(killPed, 20000, 1, player) end end outputChatBox("You have entered Staff Island, you have 20 seconds to leave or you'll be killed.", player, 255, 0, 0, true) elseif eventName == "onColShapeLeave" then if isTimer(timersTable[player]) then local remaining = getTimerDetails(timersTable[player]) setAccountData(account, "timer", tonumber(remaining)) killTimer(timersTable[player]) timersTable[player] = nil outputChatBox("You have left the area.", player, 0, 200, 0) end end end end end addEventHandler ( "onColShapeHit", islandCOL, Island) addEventHandler ( "onColShapeLeave", islandCOL, Island) addEventHandler( "onPlayerWasted", getRootElement( ), function() local account = getPlayerAccount(source) if account and not isGuestAccount(account) then if isTimer(timersTable[source]) then killTimer(timersTable[source]) timersTable[source] = nil setAccountData(account, "timer",false) end end end ) function save () local playerAccount = getPlayerAccount ( source ) if (isTimer(timersTable[source])) then local remaining = getTimerDetails(timersTable[source]) if playerAccount and not isGuestAccount(playerAccount) then setAccountData(playeraccount, "timer", tonumber(remaining)) killTimer(timersTable[source]) -- kill the timer timersTable[source] = nil end end end addEventHandler ("onPlayerQuit", root, save ) Link to comment
Price. Posted July 17, 2016 Author Share Posted July 17, 2016 i've tried doing as you've gave in the link but i reversed accounts, added setaccountdata first and get it later and reversed events, now i know how i could save time with acc data, thanks walid! Link to comment
Walid Posted July 17, 2016 Share Posted July 17, 2016 i've tried doing as you've gave in the link but i reversed accounts, added setaccountdata first and get it later and reversed events, now i know how i could save time with acc data, thanks walid! You are welcome. 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