Jump to content

isPlayerInTeam


DRW

Recommended Posts

Posted
function medicenterVehicle ( player, seat, jacked ) 
    if not isPlayerInTeam (source, "Médico") then 
         cancelEvent() 
        outputChatBox ( "Debes de ser un médico para poder entrar al vehículo.", player ) 
    end 
end 

ERROR: attempt to call global 'isPlayerInTeam' (a nil value)

What's wrong?

tJ5zeFm.gif

Proud owner and developer of ZNEXT: Aftermath.

Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience.

Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. 

Español, Pусский, Türk, عربى, Polski, Português

IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB

Posted

You have to add isPlayerInTeam function to your script

function medicenterVehicle ( player, seat, jacked ) 
    if not isPlayerInTeam (source, "Médico") then 
         cancelEvent() 
        outputChatBox ( "Debes de ser un médico para poder entrar al vehículo.", player ) 
    end 
end 
  
function isPlayerInTeam(player, team) 
    assert(isElement(player) and getElementType(player) == "player", "Bad argument 1 @ isPlayerInTeam [player expected, got " .. tostring(player) .. "]") 
    assert((not team) or type(team) == "string" or (isElement(team) and getElementType(team) == "team"), "Bad argument 2 @ isPlayerInTeam [nil/string/team expected, got " .. tostring(team) .. "]") 
    return getPlayerTeam(player) == (type(team) == "string" and getTeamFromName(team) or (type(team) == "userdata" and team or (getPlayerTeam(player) or true))) 
end 

Posted

that's wrong replace source with player here

12401f3aab.png

i think he is trying to use "onVehicleStartEnter" and the source of this event is the vehicle in which a player began to enter.

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
that's wrong replace source with player here

12401f3aab.png

i think he is trying to use "onVehicleStartEnter" and the source of this event is the vehicle in which a player began to enter.

Yes but it's still not working, same error

tJ5zeFm.gif

Proud owner and developer of ZNEXT: Aftermath.

Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience.

Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. 

Español, Pусский, Türk, عربى, Polski, Português

IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB

Posted

Try this it should work

function medicenterVehicle ( player, seat, jacked ) 
    local playerTeam = getPlayerTeam(player) 
    if (playerTeam) then 
        if getTeamName(playerTeam) ~= "Médico" then 
            cancelEvent() 
            outputChatBox ( "Debes de ser un médico para poder entrar al vehículo.", player,255,0,0 ) 
        end 
    end 
end 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
Try this it should work
function medicenterVehicle ( player, seat, jacked ) 
    local playerTeam = getPlayerTeam(player) 
    if (playerTeam) then 
        if getTeamName(playerTeam) ~= "Médico" then 
            cancelEvent() 
            outputChatBox ( "Debes de ser un médico para poder entrar al vehículo.", player,255,0,0 ) 
        end 
    end end 
end 

Even people of the team can enter a vehicle

tJ5zeFm.gif

Proud owner and developer of ZNEXT: Aftermath.

Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience.

Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. 

Español, Pусский, Türk, عربى, Polski, Português

IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB

Posted

Even people of the team can enter a vehicle

You mean even medic players can't enter the vehicle if yes try this client side

function medicenterVehicle ( player, seat, jacked ) 
    if player == getLocalPlayer() then 
    local playerTeam = getPlayerTeam(player) 
    if (playerTeam) then 
        if not (getTeamName(playerTeam) == "Médico") then 
            cancelEvent() 
            outputChatBox ( "Debes de ser un médico para poder entrar al vehículo.", player ) 
            end 
        end 
    end  
end  
addEventHandler("onClientVehicleStartEnter",root,medicenterVehicle) 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

Even people of the team can enter a vehicle

You mean even medic players can't enter the vehicle if yes try this client side

function medicenterVehicle ( player, seat, jacked ) 
    if player == getLocalPlayer() then 
    local playerTeam = getPlayerTeam(player) 
    if (playerTeam) then 
        if not (getTeamName(playerTeam) == "Médico") then 
            cancelEvent() 
            outputChatBox ( "Debes de ser un médico para poder entrar al vehículo.", player ) 
            end 
        end 
    end  
end  
addEventHandler("onClientVehicleStartEnter",root,medicenterVehicle) 

Actually, every player can enter a vehicle, doesn't matter if it's in médico team nor in another team, every player can enter

tJ5zeFm.gif

Proud owner and developer of ZNEXT: Aftermath.

Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience.

Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. 

Español, Pусский, Türk, عربى, Polski, Português

IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB

Posted

Actually, every player can enter a vehicle, doesn't matter if it's in médico team nor in another team, every player can enter

Are you sure that it's "Médico" not "Médicos" because here you are trying to use "Médicos"

0f07006f5f.png

Anyways try this before you check my code

function checkTeam (player) 
    local playerTeam = getPlayerTeam(player) 
    if (playerTeam) then 
        outputChatBox("Your team is "..getTeamName(playerTeam),player,255,0,0) 
    end  
end  
addCommandHandler("team",checkTeam) 

function medicenterVehicle ( player, seat, jacked ) 
    if not isPlayerInTeam(player,"Médico") then 
        cancelEvent() 
        outputChatBox ( "Debes de ser un médico para poder entrar al vehículo.", player ) 
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), medicenterVehicle ) 
  
function isPlayerInTeam(src, TeamName) 
    if src and isElement ( src ) and getElementType ( src ) == "player" then 
           local team = getPlayerTeam(src) 
        if team then 
            if getTeamName(team) == TeamName then 
                return true 
                else 
                return false 
            end 
        end 
    end 
end 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

Yes, I changed it but didn't work. But hey, you helped me to solve this viewtopic.php?f=91&t=88021, that is almost the same as this script, thanks!

tJ5zeFm.gif

Proud owner and developer of ZNEXT: Aftermath.

Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience.

Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. 

Español, Pусский, Türk, عربى, Polski, Português

IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB

Posted
Yes, I changed it but didn't work. But hey, you helped me to solve this viewtopic.php?f=91&t=88021, that is almost the same as this script, thanks!

You are welcome , try always to change the subject of the topic when your problem is solved.

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

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