Jump to content

Vehicle team restriction


DRW

Recommended Posts

I'm editing the https://community.multitheftauto.com/index.php?p= ... ls&id=4058 resource so I can use it in my server.

It's supposed to check two vehicles' models and then if a player is not in the team "Médicos" then it won't be able to enter, the problem is that it doesn't even allow people from "Médicos" to enter. What's wrong?

medicVehicles = { [416]=true }  
medicVehicles2 = { [563]=true }  
medicTeam = { [Médicos]=true } 
  
function medicenterVehicle ( player, seat, jacked ) 
    if ( medicVehicles[getElementModel ( source )] ) and --Here is the wrong thing ( not medicTeam[getPlayerTeam ( player )] ) and ( seat == 0 ) then  
            cancelEvent() 
        outputChatBox ( "Debes de ser un médico para poder entrar al vehículo.", player )  
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), medicenterVehicle ) 

Link to comment
medicVehicles = { [416]=true, [563]=true } 
medicTeam = { [Médicos]=true } 
  
function medicenterVehicle ( player, seat, jacked ) 
    if ( medicVehicles[getElementModel ( source )] and ( not medicTeam[getPlayerTeam ( player )] ) and seat == 0 ) then 
         cancelEvent() 
        outputChatBox ( "Debes de ser un médico para poder entrar al vehículo.", player ) 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), medicenterVehicle ) 

Link to comment
medicVehicles = { [416]=true, [563]=true } 
medicTeam = { [Médicos]=true } 
  
function medicenterVehicle ( player, seat, jacked ) 
    if ( medicVehicles[getElementModel ( source )] and ( not medicTeam[getPlayerTeam ( player )] ) and seat == 0 ) then 
         cancelEvent() 
        outputChatBox ( "Debes de ser un médico para poder entrar al vehículo.", player ) 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), medicenterVehicle ) 

It said ']' expected near ' so i removed the é and now it says table index is nil

Link to comment
  
medicVehicles = { [416]=true, [563]=true } 
medicTeam = { ['Médicos']=true } 
  
function medicenterVehicle ( player, seat, jacked ) 
    if ( medicVehicles[getElementModel ( source )] and ( not medicTeam[getPlayerTeam ( player )] ) and seat == 0 ) then 
         cancelEvent() 
        outputChatBox ( "Debes de ser un médico para poder entrar al vehículo.", player ) 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), medicenterVehicle ) 

Link to comment
medicVehicles = { [416]=true, [563]=true } 
medicTeam = { ['Médicos']=true } 
  
function medicenterVehicle ( player, seat, jacked ) 
    if ( medicVehicles[getElementModel ( source )] and ( medicTeam[getPlayerTeam ( player )] ) and seat == 0 ) then 
         cancelEvent() 
        outputChatBox ( "Debes de ser un médico para poder entrar al vehículo.", player ) 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), medicenterVehicle ) 

Link to comment

it should work

medicVehicles = {[416]=true, [563]=true } 
medicTeam = { ['Médicos']=true } 
  
function medicenterVehicle ( player, seat, jacked ) 
    local model = getElementModel ( source ) 
    local medic = getTeamName(getPlayerTeam (player)) 
    if ( medicVehicles[model] and ( not medicTeam[medic] ) and seat == 0 ) then 
        cancelEvent() 
        outputChatBox ( "Debes de ser un médico para poder entrar al vehículo.", player,255,0,0) 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), medicenterVehicle ) 

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