Jump to content

getPlayerTeam problem...


m4rsje

Recommended Posts

Posted
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
)

Posted

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

Posted

debug?

on every step put some outputChatBox that will print every variable

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

im not talking about debugscript

read again

every step (which means generally "every IF") put outputChatBox.. you will know on which "if" it fails

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

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
)

If you require a paid scripter, don't contact me, you can't afford me.

my resources: autoteams_manager

Posted

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)

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted
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

If you require a paid scripter, don't contact me, you can't afford me.

my resources: autoteams_manager

Posted
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?

Posted

nice copy paste but you loosed indentation.

yes try my code in ur server and be surprised :D

If you require a paid scripter, don't contact me, you can't afford me.

my resources: autoteams_manager

Posted
nice copy paste but you loosed indentation.

yes try my code in ur server and be surprised :D

sorry dude i can still drive with it without having a team :P

Posted

it's working on my server, you might have an error somewhere else.

check if your script is a server-side one.

If you require a paid scripter, don't contact me, you can't afford me.

my resources: autoteams_manager

Posted
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
)

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted
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

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...