Jump to content

getPlayerTeam problem...


m4rsje

Recommended Posts

local root = getRootElement()
 
addEventHandler("onVehicleEnter", root,
function(player)
-- local vehicle = source
local team = getPlayerTeam(player)
if team then
local teamName = getTeamName(team)
if teamName == "Medic" then
outputChatBox("* Don't abuse your lights! *", player)
else
removePedFromVehicle(player)
outputChatBox("* You are not allowed to get in here! *", player)
end
end
end
)

Link to comment

its still not solved.

you can still drive away without having the team

script:

local root = getRootElement()
 
addEventHandler("onVehicleEnter", root,
function(player)
local vehicle = source
local id = getElementModel(vehicle)
 
if id == 416 then 
local team = getPlayerTeam(player)
if team then
local teamName = getTeamName(team)
if (teamName) == "Medic" then
outputChatBox("((* Don't abuse your lights! *))", player)
else
removePedFromVehicle(player)
outputChatBox("((* You are not allowed to get in here! *))", player)
end
end
elseif id == 420 then 
local team = getPlayerTeam(player)
if team then
local teamName = getTeamName(team)
if (teamName) == "Taxi" then
outputChatBox("((pickup people and bring them to their chosen place))", player)
else
removePedFromVehicle(player)
outputChatBox("((*You are not allowed to get in here*))", player)
end
end
end
end
)

thx <3

Link to comment

hummmm check this code

local root = getRootElement()
 
addEventHandler("onVehicleEnter", root,
function(player)
local id = getElementModel(source)
--get the team
local team = getPlayerTeam(player)
local teamName = ""
if team then
        teamName = getTeamName(team)
end
--check the vehicles
if id == 416 then
if (teamName) == "Medic" then
outputChatBox("((* Don't abuse your lights! *))", player)
else
removePedFromVehicle(player)
outputChatBox("((* You are not allowed to get in here! *))", player)
end
elseif id == 420 then
if (teamName) == "Taxi" then
outputChatBox("((pickup people and bring them to their chosen place))", player)
else
removePedFromVehicle(player)
outputChatBox("((*You are not allowed to get in here*))", player)
end
end
end
)

Link to comment
its still not solved.

you can still drive away without having the team

after checking your code:

one thing is missing - players without team can drive ambulance.. rest is working ok (Medics can drive it, others teams can not)

That was exactly his problem lol

the code i have put should resolve it

Link to comment
local root = getRootElement()
 
addEventHandler("onVehicleEnter", root,
function(player)
local id = getElementModel(source)
--get the team
local team = getPlayerTeam(player)
local teamName = ""
if team then
        teamName = getTeamName(team)
else
outputChatBox("You cant drive!!", thePlayer)
end
--check the vehicles
if id == 416 then
if (teamName) == "Medic" then
outputChatBox("((* Don't abuse your lights! *))", player)
else
removePedFromVehicle(player)
outputChatBox("((* You are not allowed to get in here! *))", player)
end
elseif id == 420 then
if (teamName) == "Taxi" then
outputChatBox("((pickup people and bring them to their chosen place))", player)
else
removePedFromVehicle(player)
outputChatBox("((*You are not allowed to get in here*))", player)
end
end
end
)

like that?

Link to comment
local root = getRootElement()
 
addEventHandler("onVehicleEnter", root,
function(player)
local vehicle = source
local id = getElementModel(vehicle)
 
if id == 416 then 
local team = getPlayerTeam(player)
if team then
local teamName = getTeamName(team)
if (teamName) == "Medic" then
outputChatBox("((* Don't abuse your lights! *))", player)
else
removePedFromVehicle(player)
outputChatBox("((* You are not allowed to get in here! *))", player)
end
else
removePedFromVehicle(player)
outputChatBox("((* You are not allowed to get in here! *))", player)
end
elseif id == 420 then 
local team = getPlayerTeam(player)
if team then
local teamName = getTeamName(team)
if (teamName) == "Taxi" then
outputChatBox("((pickup people and bring them to their chosen place))", player)
else
removePedFromVehicle(player)
outputChatBox("((*You are not allowed to get in here*))", player)
end
else
removePedFromVehicle(player)
outputChatBox("((* You are not allowed to get in here! *))", player)
end
end
end
)

Link to comment
local root = getRootElement()
 
addEventHandler("onVehicleEnter", root,
function(player)
local vehicle = source
local id = getElementModel(vehicle)
 
if id == 416 then 
local team = getPlayerTeam(player)
if team then
local teamName = getTeamName(team)
if (teamName) == "Medic" then
outputChatBox("((* Don't abuse your lights! *))", player)
else
removePedFromVehicle(player)
outputChatBox("((* You are not allowed to get in here! *))", player)
end
else
removePedFromVehicle(player)
outputChatBox("((* You are not allowed to get in here! *))", player)
end
elseif id == 420 then 
local team = getPlayerTeam(player)
if team then
local teamName = getTeamName(team)
if (teamName) == "Taxi" then
outputChatBox("((pickup people and bring them to their chosen place))", player)
else
removePedFromVehicle(player)
outputChatBox("((*You are not allowed to get in here*))", player)
end
else
removePedFromVehicle(player)
outputChatBox("((* You are not allowed to get in here! *))", player)
end
end
end
)

it worked thank you <3

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...