SoMoRay Posted May 16, 2013 Share Posted May 16, 2013 how to make just police team join car police? Link to comment
iPrestege Posted May 16, 2013 Share Posted May 16, 2013 Make a table for the police vehicles ids then check the team then if not police team then cancelEvent "onVehicleStartEnter" getPlayerTeam getTeamName cancelEvent() Link to comment
SoMoRay Posted May 16, 2013 Author Share Posted May 16, 2013 Make a table for the police vehicles ids then check the team then if not police team then cancelEvent "onVehicleStartEnter" getPlayerTeam getTeamName cancelEvent() ok thanx man , Link to comment
SoMoRay Posted May 16, 2013 Author Share Posted May 16, 2013 Np . I want him just outputchat for player entered and not in team pollice and I do it but make wrong with team function Vehicle = { 523 } addEventHandler("onVehicleStartEnter",getRootElement(), function () for _,v in ipairs ( Vehicle ) do if ( getTeamName( getPlayerTeam( v ) ) ~= "Police" ) then outputChatBox("* You Must Be In Police Team !",source,255,0,0,true) cancelEvent() end end end ) Link to comment
iPrestege Posted May 16, 2013 Share Posted May 16, 2013 -- # Server Side !! VehicleIDs = { [523]=true } addEventHandler ("onVehicleStartEnter",root, function ( player ) local team = getPlayerTeam ( player ) local TeamName = ( team and getTeamName ( team ) ) if ( TeamName ~= "Police" ) then if ( VehicleIDs[getElementModel(source)] ) then cancelEvent( true ) outputChatBox ( "* You Must Be In Police Team !", player,255,0,0 ) end end end ) Link to comment
LucasBaker Posted May 16, 2013 Share Posted May 16, 2013 here teams = { 'Police', 'SWAT' } cars = { 598 } function checkTeam( player ) for k,v in ipairs( teams ) do if getTeamName( getPlayerTeam( player ) ) == v then return true end end return false end addEventHandler( 'onVehicleStartEnter', root, function( player ) for k,v in ipairs( cars ) do if getElementModel( source ) == v then local check = checkTeam( player ) if not check then cancelEvent( ) outputChatBox( '#F08080[ERROR] #FF0000* You Must Be In Police Team ! !', player, 255, 255, 255, true ) end end end end ) Link to comment
SoMoRay Posted May 16, 2013 Author Share Posted May 16, 2013 I don't want open new topic what proplem when speed vehicle 120 doesn't give player 1 star and this my code I do it's function getElementSpeed(element,unit) if (unit == nil) then unit = 0 end if (isElement(element)) then local x,y,z = getElementVelocity(element) if (unit=="mph" or unit==1 or unit =='1') then return (x^2 + y^2 + z^2) ^ 0.5 * 100 else return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 end else outputDebugString("Not an element. Can't get speed") return false end end addEventHandler("onClientRender",getRootElement(), function ( ) local vehicle = getPedOccupiedVehicle ( localPlayer ) if ( vehicle ) then local Speed = getElementSpeed ( vehicle,"kmh" ) if ( Speed >= 120 ) then if ( getPlayerWantedLevel == 0 ) then triggerServerEvent("Wanted0",thePlayer0,localPlayer) elseif ( getPlayerWantedLevel == 1 ) then triggerServerEvent("Wanted1",thePlayer1,localPlayer) elseif ( getPlayerWantedLevel == 2 ) then triggerServerEvent("Wanted2",thePlayer2,localPlayer) elseif ( getPlayerWantedLevel == 3 ) then triggerServerEvent("Wanted3",thePlayer3,localPlayer) elseif ( getPlayerWantedLevel == 4 ) then triggerServerEvent("Wanted4",thePlayer4,localPlayer) elseif ( getPlayerWantedLevel == 5 ) then triggerServerEvent("Wanted5",thePlayer5,localPlayer) end end end end) server addEvent("Wanted0",true) addEventHandler("Wanted0",root, function (thePlayer0) setPlayerWantedLevel ( thePlayer0, 1 ) end ) addEvent("Wanted1",true) addEventHandler("Wanted1",root, function (thePlayer1) setPlayerWantedLevel ( thePlayer1, 2 ) end ) addEvent("Wanted2",true) addEventHandler("Wanted2",root, function (thePlayer2) setPlayerWantedLevel ( thePlayer2, 3 ) end ) addEvent("Wanted3",true) addEventHandler("Wanted3",root, function (thePlayer3) setPlayerWantedLevel ( thePlayer3, 4 ) end ) addEvent("Wanted4",true) addEventHandler("Wanted4",root, function (thePlayer4) setPlayerWantedLevel ( thePlayer4, 5 ) end ) addEvent("Wanted5",true) addEventHandler("Wanted5",root, function (thePlayer5) setPlayerWantedLevel ( thePlayer5, 6 ) end ) Link to comment
iPrestege Posted May 16, 2013 Share Posted May 16, 2013 -- # Client Side function getElementSpeed(element,unit) if (unit == nil) then unit = 0 end if (isElement(element)) then local x,y,z = getElementVelocity(element) if (unit=="mph" or unit==1 or unit =='1') then return (x^2 + y^2 + z^2) ^ 0.5 * 100 else return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 end else outputDebugString("Not an element. Can't get speed") return false end end addEventHandler("onClientRender",getRootElement(), function ( ) local vehicle = getPedOccupiedVehicle ( localPlayer ) if ( vehicle ) then local Speed = getElementSpeed ( vehicle,"kmh" ) if ( Speed >= 40 ) then local Level = getPlayerWantedLevel ( ) if Level == 0 then triggerServerEvent("ServerWanted",localPlayer,1) elseif Level == 1 then triggerServerEvent("ServerWanted",localPlayer,2) elseif Level == 2 then triggerServerEvent("ServerWanted",localPlayer,3) elseif Level == 4 then triggerServerEvent("ServerWanted",localPlayer,5) elseif Level == 5 then triggerServerEvent("ServerWanted",localPlayer,6) end end end end ) ) -- # Server Side addEvent("ServerWanted",true) addEventHandler("ServerWanted",getRootElement(), function ( Level ) if Level == 0 then setPlayerWantedLevel ( source,1 ) elseif Level == 1 then setPlayerWantedLevel ( source,2 ) elseif Level == 2 then setPlayerWantedLevel ( source,3 ) elseif Level == 3 then setPlayerWantedLevel ( source,4 ) elseif Level == 4 then setPlayerWantedLevel ( source,5 ) elseif Level == 5 then setPlayerWantedLevel ( source,6 ) end end ) Try it or you can make if the speed 120 or up then get player wanted level then set the wanted level +1 . Link to comment
SoMoRay Posted May 16, 2013 Author Share Posted May 16, 2013 -- # Client Side function getElementSpeed(element,unit) if (unit == nil) then unit = 0 end if (isElement(element)) then local x,y,z = getElementVelocity(element) if (unit=="mph" or unit==1 or unit =='1') then return (x^2 + y^2 + z^2) ^ 0.5 * 100 else return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 end else outputDebugString("Not an element. Can't get speed") return false end end addEventHandler("onClientRender",getRootElement(), function ( ) local vehicle = getPedOccupiedVehicle ( localPlayer ) if ( vehicle ) then local Speed = getElementSpeed ( vehicle,"kmh" ) if ( Speed >= 40 ) then local Level = getPlayerWantedLevel ( ) if Level == 0 then triggerServerEvent("ServerWanted",localPlayer,1) elseif Level == 1 then triggerServerEvent("ServerWanted",localPlayer,2) elseif Level == 2 then triggerServerEvent("ServerWanted",localPlayer,3) elseif Level == 4 then triggerServerEvent("ServerWanted",localPlayer,5) elseif Level == 5 then triggerServerEvent("ServerWanted",localPlayer,6) end end end end ) ) -- # Server Side addEvent("ServerWanted",true) addEventHandler("ServerWanted",getRootElement(), function ( Level ) if Level == 0 then setPlayerWantedLevel ( source,1 ) elseif Level == 1 then setPlayerWantedLevel ( source,2 ) elseif Level == 2 then setPlayerWantedLevel ( source,3 ) elseif Level == 3 then setPlayerWantedLevel ( source,4 ) elseif Level == 4 then setPlayerWantedLevel ( source,5 ) elseif Level == 5 then setPlayerWantedLevel ( source,6 ) end end ) Try it or you can make if the speed 120 or up then get player wanted level then set the wanted level +1 . not work Link to comment
iPrestege Posted May 16, 2013 Share Posted May 16, 2013 -- # Client Side function getElementSpeed(element,unit) if (unit == nil) then unit = 0 end if (isElement(element)) then local x,y,z = getElementVelocity(element) if (unit=="mph" or unit==1 or unit =='1') then return (x^2 + y^2 + z^2) ^ 0.5 * 100 else return (x^2 + y^2 + z^2) ^ 0.5 * 1.61 * 100 end else outputDebugString("Not an element. Can't get speed") return false end end addEventHandler("onClientRender",getRootElement(), function ( ) local vehicle = getPedOccupiedVehicle ( localPlayer ) if ( vehicle ) then local Speed = getElementSpeed ( vehicle,"kmh" ) if ( Speed >= 120 ) then local Level = getPlayerWantedLevel ( ) if Level == 0 then triggerServerEvent("ServerWanted",localPlayer,1) elseif Level == 1 then triggerServerEvent("ServerWanted",localPlayer,2) elseif Level == 2 then triggerServerEvent("ServerWanted",localPlayer,3) elseif Level == 3 then triggerServerEvent("ServerWanted",localPlayer,4) elseif Level == 4 then triggerServerEvent("ServerWanted",localPlayer,5) elseif Level == 5 then triggerServerEvent("ServerWanted",localPlayer,6) end end end end ) Link to comment
Castillo Posted May 18, 2013 Share Posted May 18, 2013 That's a really bad method, it'll keep triggering to server side which isn't good. Also, you can just set it to one or two lines, no need for all these 'if' checks. Link to comment
iPrestege Posted May 18, 2013 Share Posted May 18, 2013 That's a really bad method, it'll keep triggering to server side which isn't good. Also, you can just set it to one or two lines, no need for all these 'if' checks. Yes i know i can make it like that : setPlayerWantedLevel ( source,getPlayerWantedLevel ( source ) + 1 ) But i do it like what he want . 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