Jump to content

help on autoteam


bandi94

Recommended Posts

this 1.1 whit team is f******** o.O:shock:

no autoteams for 1.1 so i start to make my own but when i see this simpel script not work then o.O the 1.1

the script make's the team and output in chat box the "ok" but to set player team no! no debug error or something

Teams={{"Demonic God's Team","|DGT|","#0000ff"}, 
  
} 
  
function ResourceStart(p) 
  
  
for i,data in pairs(Teams) do                                                                             
 if not isElement(data[1]) or getElementType(data[1]) ~= "team" then 
local team =  createTeam(data[1], getColorFromString(data[3])) 
end 
if string.find ( getPlayerName(p),data[2]) then 
 setPlayerTeam(p,team) 
outputChatBox("ok") 
end 
end 
end 
addCommandHandler("teama",ResourceStart) 

Link to comment
Teams={ 
    {"Demonic God's Team", "|DGT|", "#0000ff"}, 
} 
  
function ResourceStart(p) 
for i,data in pairs(Teams) do                                                                             
    if not isElement(data[1]) then 
        team =  createTeam(data[1], getColorFromString(data[3])) 
    end 
    if string.find ( getPlayerName(p),data[2]) then 
        setPlayerTeam(p,team) 
        outputChatBox("ok") 
        end 
    end 
end 
addCommandHandler("teama",ResourceStart) 

I think your main error was that you we're checking if the team name string was a "team", which is impossible because it was not an element.

Link to comment

ok now i edited and gaian i am :shock:

here is the par of script what not work the v returns the player from difrent function like on nickchange join quit ...

now no error but again he don't set the team i put after setPlayeTeam output getTeamName(team) to see if he get the team and yes it output the team name so again the setPlayerTeam function gets stuck

thx

function check(v) 
for o,data in pairs(Teams) do 
 if string.find(getPlayerName(v),data[2]) then 
 if not isElement(data[1]) then  
 createTeam(data[1], getColorFromString(data[3])) 
end 
local team = getTeamFromName(data[1]) 
setPlayerTeam( v , team) 
for p,b in pairs(getAttachedElements(v)) do 
if  getElementType(b)=="blip" then 
setBlipColor ( b, getColorFromString(data[3])) 
end 
 end 
else 
setPlayerTeam(v , nil) 
end 
end 
end  

Link to comment
function check(player) 
for o, data in pairs(Teams) do 
    if not getTeamFromName(data[1]) then 
        createTeam(data[1], getColorFromString(data[3])) 
    end 
if string.find(getPlayerName(player), data[2]) then 
    local team = getTeamFromName(data[1]) 
    setPlayerTeam( player, team) 
    for p,b in pairs(getAttachedElements(player)) do 
        if getElementType(b)=="blip" then 
            setBlipColor ( b, getColorFromString(data[3])) 
        end 
    end 
else 
    setPlayerTeam(player, nil) 
end 
    end 
end 

Link to comment

ok its working fine whit 1 team like

Teams={

{"Demonic God's Team", "|DGT|", "#0000ff"},

}

but when i add 2 team or not working or make just 1 team and put 60% player in it it miss up how can i fix it ?

2 teams like

Teams={

{"Demonic God's Team", "|DGT|", "#0000ff"},

{"THQ", "|THQ|", "#ee00ff"},

}

thx for all

Link to comment

i mean when in Teams i put this

Teams={{"Demonic God's Team", "|DGT|", "#0000ff"}}

this is 1 team and works fine when i put 2 teams like this

Teams={{"Demonic God's Team", "|DGT|", "#0000ff"},

{"THQ", "|THQ|", "#ee00ff"},}

its stop working not creating the team's or creates only the secound THQ and put 60% if player on server but they haven't the tag in name i think now you got me xD

Link to comment

Dude, add this line:

  
function onChangeRaceState(newStateName) 
    if newStateName == "Running" then 
        for _,player in ipairs(getElementsByType("player")) do 
            checkPlayerTeam(player) 
        end 
    end 
end 
addEvent("onRaceStateChanging", true) 
addEventHandler( "onRaceStateChanging", getRootElement(), onChangeRaceState) 
  

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