Lloyd Logan Posted January 25, 2013 Share Posted January 25, 2013 Hey, how do i warp a ped into a vehicle if the Ped isn't in that Team that vehicle is assigned to? I tried to warp a ped that i created into the team veh, but it was removed because the ped wasn't in the team. How do i fix this? Link to comment
Castillo Posted January 25, 2013 Share Posted January 25, 2013 You can't set the team of a ped. You can make a check when something enters the vehicle, if the type of element is a player, then remove him. Use: getElementType Link to comment
Lloyd Logan Posted January 25, 2013 Author Share Posted January 25, 2013 You can't set the team of a ped.You can make a check when something enters the vehicle, if the type of element is a player, then remove him. Use: getElementType So for my removePedFromVehicle, only do this if it is a player? Link to comment
Lloyd Logan Posted January 25, 2013 Author Share Posted January 25, 2013 Yes, exactly. So when a marker and blip is destroyed after picking up a ped, it keeps creating a random marker and blip from pickups, but I would like to be from the dropoff table, how would i do this? local dropoffs = { [1]={ 2060.7685546875, -1941.1181640625, 13.14103603363 }, [2]={ 2114.5068359375, -1611.302734375, 13.167269706726 }, [3]={ 1932.9521484375, -1776.1259765625, 13.16081237793 }, [4]={ 1057.41796875, -1568.4853515625, 13.166387557983 } } local sss = { [1]={ 1965.54296875 , -1883.013671875, 13.160305023193 }, [2]={ 1467.3916015625, -1736.419921875, 13.242918014526 }, [3]={ 2376.1064453125, -1728.4091796875, 13.162055015564 }, [4]={ 1066.5029296875, -1200.86328125, 18.405519485474 } } local pedCus = { [1]={ 9 }, [2]={ 10 }, [3]={ 14 }, [4]={ 15 }, [5]={ 37 } } Team = createTeam("Taxi Driver", 0, 255, 0) busTeams = { [Team] = true } busVehs = { [420] = true } function enterVehicle ( thePlayer, seat, jacked ) -- when a player enters a vehicle if getElementType ( thePlayer ) == "thePlayer" then if ( busVehs[getElementModel ( source )] ) and ( not busTeams[getPlayerTeam( thePlayer )] ) then -- if the vehicle is one of 4 police cars, and the skin is not a police skin removePedFromVehicle( thePlayer )-- force the player out of the vehicle outputChatBox("Only Taxi Drivers can drive this vehicle!", thePlayer) end end end addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) markers = { } blips = { } peds = { } function inVEH(thePlayer) if isPedInVehicle ( thePlayer ) then if ( getElementModel ( source ) == 420 ) then local x, y, z = unpack ( dropoffs [ math.random ( #dropoffs ) ] ) markers [ thePlayer ] = createMarker ( x, y, z, "cylinder", 3.5, 255, 0, 0 ) local skins = unpack ( pedCus [ math.random ( #pedCus ) ] ) peds [ thePlayer ] = createPed( skins, x, y, z ) blips [ thePlayer ] = createBlipAttachedTo ( markers [ thePlayer ], 41 ) addEventHandler ( "onMarkerHit", markers [ thePlayer ], warpit ) end else if ( isElement ( markers [ thePlayer ] ) ) then destroyElement ( markers [ thePlayer ] ) end if ( isElement ( blips [ thePlayer ] ) ) then destroyElement( blips [ thePlayer ] ) end end end addEventHandler("onVehicleEnter", getRootElement(), inVEH) function warpit ( thePlayer ) if ( getElementType ( thePlayer ) == "player" and isPedInVehicle ( thePlayer ) ) then local vehicle = getPedOccupiedVehicle ( thePlayer ) if ( getElementModel ( vehicle ) == 420 ) then if ( isElement ( markers [ thePlayer ] ) ) then destroyElement ( markers [ thePlayer ] ) end if ( isElement ( blips [ thePlayer ] ) ) then destroyElement( blips [ thePlayer ] ) end warpPedIntoVehicle ( peds [ thePlayer ], vehicle, 2 ) cancelEvent() end end end 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