Jump to content

Find the mistake


tim260

Recommended Posts

Hello people can you find my mistake on the followingg its not showing like your not in this team in the chat

addEvent ( "onPlayerChooseTeam" , true ) 
addEventHandler ( "onPlayerChooseTeam" , root , 
function ( teamName ) 
local team = getTeamFromName ( teamName ) 
if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "getTeamFromName" ) ) then 
setPlayerTeam ( source , team ) 
outputChatBox("You have successfully been moved to "..getTeamName(team).." Team.", resPlayer, root, 0, 255, 0) 
else ) 
outputChatBox ( "Your not in this team") 
end  
end ) 

Link to comment

Check if the team is created , there must be a team named : teamName

EDIT : I remade it simple ( BTW , idk if it will work )

  
addEvent ( "onPlayerChooseTeam" , true ) 
addEventHandler ( "onPlayerChooseTeam" , root , 
function teamName () 
local team = getTeamFromName ( "Example 1" ) 
if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Example 1" ) ) then 
setPlayerTeam ( thePlayer , team ) 
outputChatBox("You have successfully been moved to Example 1 Team.", thePlayer, root, 0, 255, 0) 
else 
outputChatBox ( "Your not in this team") 
end  
end) 

Edited by Guest
Link to comment

Can you show us how you trigger the "onPlayerChooseTeam" event?

addEvent ( "onPlayerChooseTeam" , true ) 
addEventHandler ( "onPlayerChooseTeam" , root , 
function ( teamName ) 
local team = getTeamFromName ( teamName ) 
local account = getPlayerAccount(source) 
local accountName = getAccountName(account) 
if isObjectInACLGroup ( "user."..tostring(accountName), aclGetGroup ( teamName ) ) then 
    setPlayerTeam ( source, team ) 
    outputChatBox("You have successfully been moved to "..getTeamName(team).." Team.", source, root, 0, 255, 0) 
else 
    outputChatBox ( "Your not in this team",source) 
    end 
end) 

Link to comment
Can you show us how you trigger the "onPlayerChooseTeam" event?
addEvent ( "onPlayerChooseTeam" , true ) 
addEventHandler ( "onPlayerChooseTeam" , root , 
function ( teamName ) 
local team = getTeamFromName ( teamName ) 
local account = getPlayerAccount(source) 
local accountName = getAccountName(account) 
if isObjectInACLGroup ( "user."..tostring(accountName), aclGetGroup ( "getTeamFromName" ) ) then 
    setPlayerTeam ( source, team ) 
    outputChatBox("You have successfully been moved to "..getTeamName(team).." Team.", source, root, 0, 255, 0) 
else 
    outputChatBox ( "Your not in this team",source) 
    end 
end) 

its from this resource https://community.multitheftauto.com/index.php?p= ... ls&id=2685

Link to comment

Change the code from "teamspawn.lua" with this:

local teamsTable = { 
    [ "Police" ] = { 1553.0385742188 , -1675.7225341797 , 16.1953125 } , 
    [ "Robber" ] = { 2249.8801269531 , -1908.4437255859 , 13.546875 } , 
    [ "Mechanics" ] = { 1011.7614746094 , -1005.9530639648 , 32.1015625 } , 
    [ "Whores" ] = { 1833.8845214844 , -1682.6907958984 , 13.454662322998 } , 
    [ "Pilot" ] = { 2001.0803222656 , -2366.482910563 , 13.546875 } , 
    [ "Trucker" ] = { -83.053352355957 , -1136.3688964844 , 1.078125 }  
} 
  
addEvent ( "onPlayerChooseTeam" , true ) 
addEventHandler ( "onPlayerChooseTeam" , root , 
function ( teamName ) 
    local team = getTeamFromName ( teamName ) 
    local account = getPlayerAccount(source) 
    local accountName = getAccountName(account) 
    if isObjectInACLGroup ( "user."..tostring(accountName), aclGetGroup ( teamName ) ) then  
        setPlayerTeam ( source, team ) 
        local spawnX, spawnY, spawnZ = unpack ( teamsTable [ teamName ] ) 
        spawnPlayer ( source, spawnX, spawnY, spawnZ ) 
    else 
        outputChatBox ( "Your not in this team",source) 
    end 
end 
) 

Link to comment
Change the code from "teamspawn.lua" with this:
local teamsTable = { 
    [ "Police" ] = { 1553.0385742188 , -1675.7225341797 , 16.1953125 } , 
    [ "Robber" ] = { 2249.8801269531 , -1908.4437255859 , 13.546875 } , 
    [ "Mechanics" ] = { 1011.7614746094 , -1005.9530639648 , 32.1015625 } , 
    [ "Whores" ] = { 1833.8845214844 , -1682.6907958984 , 13.454662322998 } , 
    [ "Pilot" ] = { 2001.0803222656 , -2366.482910563 , 13.546875 } , 
    [ "Trucker" ] = { -83.053352355957 , -1136.3688964844 , 1.078125 }  
} 
  
addEvent ( "onPlayerChooseTeam" , true ) 
addEventHandler ( "onPlayerChooseTeam" , root , 
function ( teamName ) 
    local team = getTeamFromName ( teamName ) 
    local account = getPlayerAccount(source) 
    local accountName = getAccountName(account) 
    if isObjectInACLGroup ( "user."..tostring(accountName), aclGetGroup ( teamName ) ) then  
        setPlayerTeam ( source, team ) 
        local spawnX, spawnY, spawnZ = unpack ( teamsTable [ teamName ] ) 
        spawnPlayer ( source, spawnX, spawnY, spawnZ ) 
    else 
        outputChatBox ( "Your not in this team",source) 
    end 
end 
) 

im stil getting the message your moved but im not so i can edit this my own

EDIT : i got it right thank you very much

Edited by Guest
Link to comment
Hello people can you find my mistake on the followingg its not showing like your not in this team in the chat
addEvent ( "onPlayerChooseTeam" , true ) 
addEventHandler ( "onPlayerChooseTeam" , root , 
function ( teamName ) 
local team = getTeamFromName ( teamName ) 
if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "getTeamFromName" ) ) then 
setPlayerTeam ( source , team ) 
outputChatBox("You have successfully been moved to "..getTeamName(team).." Team.", resPlayer, root, 0, 255, 0) 
else ) 
outputChatBox ( "Your not in this team") 
end  
end ) 

The only mistake I can see is "getTeamFromName" should be teamName in 5th line and delete bracket in 8th line.Make sure you are triggering the event correctly

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