WzKhalifa Posted January 11, 2015 Share Posted January 11, 2015 I need to put the onPlayerQuit function to the player go to jail, I've tried everything, more unable, someone help? function jailPlayer ( p, dur, announce, element, reason ) if( p and dur ) then local announce = announce or false jailedPlayers[p] = dur setElementInterior ( p, 2 ) setElementDimension ( p, 33 ) setElementPosition ( p, 2559, -1291, 1032 ) setElementData ( p, 'VDBGJail:JailTime', tonumber ( dur ) ) setElementData ( p, "isGodmodeEnabled", true ) exports['VDBGJobs']:updateJobColumn ( getAccountName ( getPlayerAccount ( p ) ), 'TimesArrestedOfficer', "AddOne" ) if ( announce ) then local reason = reason or "Ter estrela." local msg = "" if ( element and reason ) then msg = getPlayerName ( p ).." Was arrested for "..getPlayerName ( element ).." by "..tostring ( dur ).." seconds ("..reason..")" elseif ( element ) then msg = getPlayerName ( p ).." Was arrested for "..getPlayerName ( element ).." by "..tostring ( dur ).." seconds" end exports['VDBGMessages']:sendClientMessage ( msg, root, 0, 120, 255 ) exports['VDBGLogs']:outputPunishLog ( tostring ( msg ) ) end triggerEvent ( "onPlayerArrested", p, dur, element, reason ) triggerClientEvent ( p, "onPlayerArrested", p, dur, element, reason ) return true end return false end Link to comment
Enargy, Posted January 11, 2015 Share Posted January 11, 2015 addEventHandler("onPlayerQuit",root, function () local playerAccount = getPlayerAccount ( source ) if ( playerAccount ) and not isGuestAccount ( playerAccount ) then -- here your code using setAccountData & setElementData end end ) Link to comment
WzKhalifa Posted January 11, 2015 Author Share Posted January 11, 2015 So I spent the wrong function, it is here, try to add a onPlayerQuit in onMarkerHit region, for both work together when the player pass the marker, and the prisoner and reconnect the onPlayerQuit function into action .. this script is client-side local locs = { { 1549.45, -1718.64, 13.86 } } local e = { ['blip'] = { }, ['marker'] = { } } addEvent ( "onPlayerStartArrested", true ) addEventHandler ( "onPlayerStartArrested", root, function ( p, c) if ( c == localPlayer ) then for i, v in ipairs ( locs ) do local x, y, z = unpack ( v ) e['marker'][i] = createMarker ( x, y, z - 1, "cylinder", 1.8, 0, 120, 255, 120 ) e['blip'][i] = createBlip ( x, y,z, 30 ) addEventHandler ( "onClientMarkerHit", e['marker'][i], function ( p ) if ( p == localPlayer ) then for i, v in pairs ( e ) do for i, v in pairs ( v ) do if ( isElement ( v ) ) then destroyElement ( v ) end end end triggerServerEvent ( "vdbgpolice:onJailCopCrimals", localPlayer ) end end ) end end end ) Link to comment
MTA Team botder Posted January 12, 2015 MTA Team Share Posted January 12, 2015 for i, v in pairs ( e ) do for i, v in pairs ( v ) do Does that even work? You may try giving your variables other names. By the way, you should give your variables better names, because it's pain to read your code with all the shortcuts "x, y, z, a, b, v, c" Link to comment
WzKhalifa Posted January 12, 2015 Author Share Posted January 12, 2015 Well what the script below does is simple, if the (crim) out he pays the police, holding the criminal and informs the police, the more he can not hold the player as he left the game, will be whether to keep some of the cache the (crim) soon after he left? if ( not isElement ( crim ) ) then -- If the criminal then log out givePlayerMoney ( cop, 4999 ) -- Pay cash the police exports['VDBGPolice']:jailPlayer ( crim, 900, false, cop, "Police Arrest" ) -- Here he holds criminal for 900 seconds, more as it turned out, can not exports['VDBGMessages']:sendClientMessage ( "The player you have held out and you will $ 5000,00", cop, 0, 255, 0 ) -- Inform the police who handcuffed the criminal end Function that holds the player in the script (VDBGPolice) local jailedPlayers = { } function isPlayerJailed ( p ) if ( p and getElementType ( p ) == 'player' ) then if ( jailedPlayers[p] ) then return tonumber ( getElementData ( p, 'VDBGPolice:JailTime' ) ) else return false end end return nil end function jailPlayer ( p, dur, announce, element, reason ) if( p and dur ) then local announce = announce or false jailedPlayers[p] = dur setElementInterior ( p, 0 ) setElementDimension ( p, 33 ) setElementPosition ( p, 2232.94, -1055.15, 655.27 ) setElementData ( p, 'VDBGPolice:JailTime', tonumber ( dur ) ) setElementData ( p, "isGodmodeEnabled", true ) exports['VDBGJobs']:updateJobColumn ( getAccountName ( getPlayerAccount ( p ) ), 'TimesArrested', "AddOne" ) if ( announce ) then local reason = reason or "Classified" local msg = "" if ( element and reason ) then msg = getPlayerName ( p ).." has been jailed by "..getPlayerName ( element ).." for "..tostring ( dur ).." seconds ("..reason..")" elseif ( element ) then msg = getPlayerName ( p ).." has been jailed by "..getPlayerName ( element ).." for "..tostring ( dur ).." seconds" end exports['VDBGMessages']:sendClientMessage ( msg, root, 0, 120, 255 ) exports['VDBGLogs']:outputPunishLog ( tostring ( msg ) ) end triggerEvent ( "onPlayerArrested", p, dur, element, reason ) triggerClientEvent ( p, "onPlayerArrested", p, dur, element, reason ) return true end return false end or create some function within the first script like this informing time setElementData ( p, 'VDBGPolice:JailTime' stating the value too, more like I'm starting my knowledge in lua get lost 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