Jump to content

Teams problem.


nik3231

Recommended Posts

I'm stuck on setting teams problem. I tried to make a special advances for dWa team. I want to make their car colors seted (i don't really mind the color, it's easy to modify it anyway). And setting their text color to red (same as for car color). About setting dWa member to a group works but this two doesn't. Maybe some of you can help me out? Thanks.

Names={} 
Tags={} 
Colors={} 
ACL={} 
  
local names ={"[dWa]Member","[dWa]Member","[dWa]Member"} 
local tags  ={"","",""} 
local colors ={"#FF0000","#2B60DE","#2B60DE"} 
local acls={"Admin","Moderator","SuperModerator"} 
  
function loadTeams() 
 for i,name in pairs(names) do 
  Names[i]=name 
 end 
 for i,tag in pairs(tags) do 
  Tags[i]=tag 
 end 
 for i,color in pairs(colors) do 
  Colors[i] = color 
 end 
 for i,acl in pairs(acls) do 
  ACL[i] = acl 
 end 
end 
addEventHandler("onResourceStart",getRootElement(),loadTeams) 
  
function moveOnStart() 
 for i,player in pairs(getElementsByType("player")) do 
  check(player) 
 end 
end 
addEventHandler("onResourceStart",getRootElement(),moveOnStart) 
  
function check (player) 
setPlayerTeam(player,nil) 
 for i,tag in pairs(tags) do 
  if tag == "" then 
    local account=getPlayerAccount(player) 
    if ACL[i]=="none"  then 
     local name = Names[i] 
     local color = Colors[i] 
     if not getTeamFromName(name) then 
      createTeam(name,getColorFromString(color)) 
     end 
     local team = getTeamFromName(name) 
     setPlayerTeam(player,team) 
    elseif isObjectInACLGroup ( "user." ..getAccountName(account) , aclGetGroup ( ACL[i] ) ) then 
     local name = Names[i] 
     local color = Colors[i] 
     if not getTeamFromName(name) then 
      createTeam(name,getColorFromString(color)) 
     end 
     local team = getTeamFromName(name) 
     setPlayerTeam(player,team) 
    end 
  else 
   if string.find(getPlayerName(player),tag) then 
    local account=getPlayerAccount(player) 
    if ACL[i]=="none"  then 
     local name = Names[i] 
     local color = Colors[i] 
     if not getTeamFromName(name) then 
      createTeam(name,getColorFromString(color)) 
     end 
     local team = getTeamFromName(name) 
     setPlayerTeam(player,team) 
    elseif isObjectInACLGroup ( "user." ..getAccountName(account) , aclGetGroup ( ACL[i] ) ) then 
     local name = Names[i] 
     local color = Colors[i] 
     if not getTeamFromName(name) then 
      createTeam(name,getColorFromString(color)) 
     end 
     local team = getTeamFromName(name) 
     setPlayerTeam(player,team) 
    end 
   end 
  end 
 end 
end 
  
function remove() 
 for t,teams in pairs(names) do 
  local team = getTeamFromName(teams) 
  if team then 
   if  countPlayersInTeam ( team )==0 then 
    destroyElement(team) 
   end 
  end 
 end 
end 
  
function nick(old,new) 
 setTimer(check,1000,1,source) 
 setTimer(remove,1500,1) 
end 
addEventHandler("onPlayerChangeNick",getRootElement(),nick) 
  
function join() 
 setTimer(check,4000,1,source) 
end 
addEventHandler("onPlayerJoin",getRootElement(),join) 
  
function quit(player) 
 setTimer(remove,1000,1) 
end 
addEventHandler("onPlayerQuit",getRootElement(),quit) 
  
function login() 
 setTimer(check,1000,1,source) 
 setTimer(remove,1500,1) 
end 
addEventHandler("onPlayerLogin",getRootElement(),login) 
  
function logout() 
 setTimer(check,1000,1,source) 
 setTimer(remove,1500,1) 
end  
addEventHandler("onPlayerLogout",getRootElement(),logout) 
  
function blip(player) 
 local team = getPlayerTeam(player) 
 if team then 
  for v,blip in pairs(getAttachedElements(player)) do 
   if getElementType(blip)=="blip" then 
    local r,g,b =getTeamColor(team) 
    setBlipColor(blip,r,g,b,255) 
   end 
  end 
 end  
end 
  
function timer() 
 setTimer(blip,3000,1,source) 
end 
addEventHandler("onPlayerSpawn",getRootElement(),timer) 
  
function checkPlayerCars() 
 for No,player in ipairs(getElementsByType("player")) do 
  if isPedInVehicle(player) then 
   playerVehicle = getPedOccupiedVehicle(player) 
   if getPlayerTeam(player) and getTeamName(getPlayerTeam(player)) == "[dWa]Member" then 
    setVehicleColor(playerVehicle,0,0,0,0) 
    setVehicleOverrideLights ( playerVehicle , 2 ) 
    setVehicleHeadLightColor ( playerVehicle , 255, 0, 0) 
    else 
    setVehicleColor(playerVehicle,1,1,1,1) 
    setVehicleOverrideLights ( playerVehicle , 2 ) 
    setVehicleHeadLightColor ( playerVehicle , 255, 0, 0) 
    end 
  end 
 end 
end 
  
  
function ChatColor( message, messageType ) 
 if message ~= "" and messageType == 0 then 
  cancelEvent() 
  if getTeamName(getPlayerTeam(source)) == "[dWa] Member" then 
   outputChatBox(getPlayerName(source).. ": #FF0000" ..message, getRootElement(), 255, 0, 0, true) 
  else 
   outputChatBox(getPlayerName(source).. ": #FFFFFF" ..message, getRootElement(), 255, 255, 255, true) 
   end 
 elseif message ~= "" and messageType == 2 then 
  if getPlayerTeam(source) then 
   team = getPlayersInTeam(getPlayerTeam(source)) 
   r, g, b = getTeamColor(getPlayerTeam(source)) 
   for playerKey, playerValue in ipairs ( team ) do 
    outputChatBox("(TEAM) " ..getPlayerName(source).. ": #FF0000" ..message, playerValue, r, g, b, true) 
   end 
  end 
 end 
end 
addEventHandler( "onPlayerChat", getRootElement(), ChatColor) 

Edit: another problem...if i want to make a Donator group, and let's say that with a name SnakeBite is a donator. How can i say in scirpt that's he's a donator. For dWa i just said "if dWa member then.." but for this i don't know...help please.

Link to comment
I'm stuck on setting teams problem. I tried to make a special advances for dWa team. I want to make their car colors seted (i don't really mind the color, it's easy to modify it anyway). And setting their text color to red (same as for car color). About setting dWa member to a group works but this two doesn't. Maybe some of you can help me out? Thanks.
Names={} 
Tags={} 
Colors={} 
ACL={} 
  
local names ={"[dWa]Member","[dWa]Member","[dWa]Member"} 
local tags  ={"","",""} 
local colors ={"#FF0000","#2B60DE","#2B60DE"} 
local acls={"Admin","Moderator","SuperModerator"} 
  
function loadTeams() 
 for i,name in pairs(names) do 
  Names[i]=name 
 end 
 for i,tag in pairs(tags) do 
  Tags[i]=tag 
 end 
 for i,color in pairs(colors) do 
  Colors[i] = color 
 end 
 for i,acl in pairs(acls) do 
  ACL[i] = acl 
 end 
end 
addEventHandler("onResourceStart",getRootElement(),loadTeams) 
  
function moveOnStart() 
 for i,player in pairs(getElementsByType("player")) do 
  check(player) 
 end 
end 
addEventHandler("onResourceStart",getRootElement(),moveOnStart) 
  
function check (player) 
setPlayerTeam(player,nil) 
 for i,tag in pairs(tags) do 
  if tag == "" then 
    local account=getPlayerAccount(player) 
    if ACL[i]=="none"  then 
     local name = Names[i] 
     local color = Colors[i] 
     if not getTeamFromName(name) then 
      createTeam(name,getColorFromString(color)) 
     end 
     local team = getTeamFromName(name) 
     setPlayerTeam(player,team) 
    elseif isObjectInACLGroup ( "user." ..getAccountName(account) , aclGetGroup ( ACL[i] ) ) then 
     local name = Names[i] 
     local color = Colors[i] 
     if not getTeamFromName(name) then 
      createTeam(name,getColorFromString(color)) 
     end 
     local team = getTeamFromName(name) 
     setPlayerTeam(player,team) 
    end 
  else 
   if string.find(getPlayerName(player),tag) then 
    local account=getPlayerAccount(player) 
    if ACL[i]=="none"  then 
     local name = Names[i] 
     local color = Colors[i] 
     if not getTeamFromName(name) then 
      createTeam(name,getColorFromString(color)) 
     end 
     local team = getTeamFromName(name) 
     setPlayerTeam(player,team) 
    elseif isObjectInACLGroup ( "user." ..getAccountName(account) , aclGetGroup ( ACL[i] ) ) then 
     local name = Names[i] 
     local color = Colors[i] 
     if not getTeamFromName(name) then 
      createTeam(name,getColorFromString(color)) 
     end 
     local team = getTeamFromName(name) 
     setPlayerTeam(player,team) 
    end 
   end 
  end 
 end 
end 
  
function remove() 
 for t,teams in pairs(names) do 
  local team = getTeamFromName(teams) 
  if team then 
   if  countPlayersInTeam ( team )==0 then 
    destroyElement(team) 
   end 
  end 
 end 
end 
  
function nick(old,new) 
 setTimer(check,1000,1,source) 
 setTimer(remove,1500,1) 
end 
addEventHandler("onPlayerChangeNick",getRootElement(),nick) 
  
function join() 
 setTimer(check,4000,1,source) 
end 
addEventHandler("onPlayerJoin",getRootElement(),join) 
  
function quit(player) 
 setTimer(remove,1000,1) 
end 
addEventHandler("onPlayerQuit",getRootElement(),quit) 
  
function login() 
 setTimer(check,1000,1,source) 
 setTimer(remove,1500,1) 
end 
addEventHandler("onPlayerLogin",getRootElement(),login) 
  
function logout() 
 setTimer(check,1000,1,source) 
 setTimer(remove,1500,1) 
end  
addEventHandler("onPlayerLogout",getRootElement(),logout) 
  
function blip(player) 
 local team = getPlayerTeam(player) 
 if team then 
  for v,blip in pairs(getAttachedElements(player)) do 
   if getElementType(blip)=="blip" then 
    local r,g,b =getTeamColor(team) 
    setBlipColor(blip,r,g,b,255) 
   end 
  end 
 end  
end 
  
function timer() 
 setTimer(blip,3000,1,source) 
end 
addEventHandler("onPlayerSpawn",getRootElement(),timer) 
  
function checkPlayerCars() 
 for No,player in ipairs(getElementsByType("player")) do 
  if isPedInVehicle(player) then 
   playerVehicle = getPedOccupiedVehicle(player) 
   if getPlayerTeam(player) and getTeamName(getPlayerTeam(player)) == "[dWa]Member" then 
    setVehicleColor(playerVehicle,0,0,0,0) 
    setVehicleOverrideLights ( playerVehicle , 2 ) 
    setVehicleHeadLightColor ( playerVehicle , 255, 0, 0) 
    else 
    setVehicleColor(playerVehicle,1,1,1,1) 
    setVehicleOverrideLights ( playerVehicle , 2 ) 
    setVehicleHeadLightColor ( playerVehicle , 255, 0, 0) 
    end 
  end 
 end 
end 
  
  
function ChatColor( message, messageType ) 
 if message ~= "" and messageType == 0 then 
  cancelEvent() 
  if getTeamName(getPlayerTeam(source)) == "[dWa] Member" then 
   outputChatBox(getPlayerName(source).. ": #FF0000" ..message, getRootElement(), 255, 0, 0, true) 
  else 
   outputChatBox(getPlayerName(source).. ": #FFFFFF" ..message, getRootElement(), 255, 255, 255, true) 
   end 
 elseif message ~= "" and messageType == 2 then 
  if getPlayerTeam(source) then 
   team = getPlayersInTeam(getPlayerTeam(source)) 
   r, g, b = getTeamColor(getPlayerTeam(source)) 
   for playerKey, playerValue in ipairs ( team ) do 
    outputChatBox("(TEAM) " ..getPlayerName(source).. ": #FF0000" ..message, playerValue, r, g, b, true) 
   end 
  end 
 end 
end 
addEventHandler( "onPlayerChat", getRootElement(), ChatColor) 

Edit: another problem...if i want to make a Donator group, and let's say that with a name SnakeBite is a donator. How can i say in scirpt that's he's a donator. For dWa i just said "if dWa member then.." but for this i don't know...help please.

What do you here ? you copy my autoteam and you are trying to modify it good luck! and you " I tried to make a special advances for dWa team" https://community.multitheftauto.com/index.php?p=resources&s=details&id=2833

Link to comment
Is not more easy using getElementData() ?

Its more effective than this, you will set the team, put them on it, when player quit and joins again, it returns to the team, i was made that.

Could you please post an example? Ty.

Stolen? Not once did he mention that he had made the script himself..

Maybe the original resource wasn't suiting his needs so he wants to alter it and you're like "oh no thief!"

Tnx for posting this. I never said it was my script, i just wanted to modify it cuz it wasn't suiting my needs.

Link to comment
Some Help guys please..

EDIT:Instead of dWa i would like to have a group for ADMINS and DONATORS anyone can help me with solving that?

Lol, I gotta hand it to you there.. Pretty smart

Deleting your own post and reposting avoids double-posting and bumps the topic at the same time. Seriously that's more or less genius

Sorry for the offtopic

Link to comment
Some Help guys please..

EDIT:Instead of dWa i would like to have a group for ADMINS and DONATORS anyone can help me with solving that?

All you have to do is write /create team [team name] on the desktop! It's simple as that!

Not sure what you really mean with "destkop"

Link to comment

... your problem is that this is my autoteam and you don't know how to use it .... read the info :

1. you can't let Tags={"",""} that is a nil value and my autoteam don't work whit no tag so you put a tag or edit the code .... to check if the tag is "" and then check the ACL ... my autoteam first check the tag and you put a nil value to tag and then it's not working.... add a check if is tag or not ...

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