Jump to content

Clothes for Team


Recommended Posts

Help me with my script, does not work.

function team(
    if (isObjectInACLGroup("user." ..account, aclGetGroup("Law Enforcement"))) then
        setPlayerTeam(source, team)
        setTeamFriendlyFire(team, false)
        addPedClothes ( source, "policetr", "policetr", 17 ) 
    end
end)
addEventHandler ( "onPlayerTeamChange", getRootElement (), team )

help me with my script

Edited by Gabriel Vasconcelos
Link to comment

The event "onPlayerTeamChange" doesn't exist (although it would be useful if it's implemented in MTA).
You also have some errors in your code, like:
- A parenthesis missing at the beginning of the function.
- An extra parenthesis at the end of the function.
- 'account' and 'team' not defined

Next time remember to post your code using the button <> and select the appropriate code language (ie: Lua). Read: https://forum.multitheftauto.com/topic/94790-guidelines-and-formatting-for-this-section-read-before-posting/

 

Link to comment

You didn't fixed the erros I mentioned.

Try this:


function team( player )
	if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(player)), aclGetGroup("Law Enforcement")) then
		local g_team = getTeamFromName( "team_name_here" )
		
		setPlayerTeam(player, g_team)
		setTeamFriendlyFire(g_team, false)
		addPedClothes ( player, "policetr", "policetr", 17 ) 
	end
end
addCommandHandler ( "cloth", team )

Don't forget to define the team name.

You must also have the acl group "Law Enforcement" created; or define an existing one.

Link to comment

>

function team( player )
	local g_team = getTeamFromName( "Law Enforcement" )
		
	setPlayerTeam(player, g_team)
	setTeamFriendlyFire(g_team, false)
	addPedClothes ( player, "policetr", "policetr", 17 )
end
addCommandHandler ( "cloth", team )

 

  • Like 1
Link to comment
function team( player )
  	local team = getPlayerTeam(player)
	local g_team = getTeamFromName(team)
  	if (g_team == "Law Enforcement") then
	addPedClothes ( player, "policetr", "policetr", 17 )
    end
end
addCommandHandler ( "cloth", team )

 

Link to comment
6 hours ago, Gabriel Vasconcelos said:

the problem is that it is working, but for everyone, I want only those who are part of the LAW to use

That's probably what you mean: 


function setTeamCmd( player )
	local team = getPlayerTeam(player)

	if team and getTeamName(team) == "Law Enforcement" then
		addPedClothes ( player, "policetr", "policetr", 17 )
	end
end
addCommandHandler ( "cloth", setTeamCmd )

It's hard to figure out what you want to achieve because you didn't explain it at all.

Next time you ask for help provide some informations, it's not always that someone will give you the full code.

Edited by DNL291
  • Like 1
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...