Jump to content

how to save teams


vXHazE

Recommended Posts

Hey guys i im making teams on my server and ive managed to find a script where it saves the teams but how to save the players that are in the teams because when i put myself into the admin team and the reconnect to the server im no longer in that team can anyone help or maybe know a good script?

Link to comment
  • 4 years later...
11 hours ago, zRodrigoMM said:

how i add team on xml file sr ?

There are some ways, but i use this :

function AddTeamToXML(...)
	local xmlNode = xmlLoadFile("Teams.xml");
	if not xmlNode then
		xmlNode = xmlCreateFile("Teams.xml","Teams"); 
	end
	local valuesNumber = 0;
	while xmlFindChild(xmlNode,"Team",valuesNumber) do
		valuesNumber=valuesNumber+1;
	end
	local newNode = xmlCreateChild(xmlNode,"Team");
	local foundNode = xmlFindChild(xmlNode,"Team",valuesNumber);
	local boolean;
	if xmlNodeGetAttribute(foundNode,"name")~= arg[1] then
		xmlNodeSetAttribute(foundNode,"name",arg[1]);
		xmlNodeSetAttribute(foundNode,"color",arg[2]);
		boolean=true;
	else 
		boolean=false;
	end
	xmlSaveFile(xmlNode);
	xmlUnloadFile(xmlNode);
	return boolean
end

AddTeamToXML("Team1","0,0,0");
AddTeamToXML("Team2","255,0,0");
AddTeamToXML("Team3","0,255,0");
AddTeamToXML("Team4","0,0,255");

function GetTeamDetails(TeamName)
	local xmlNode = xmlLoadFile("Teams.xml");
	local TeamDetails = {};
	local counter = 0;
	while xmlFindChild(xmlNode,"Team",counter) do
		local xml = xmlFindChild(xmlNode,"Team",counter);
		local name = xmlNodeGetAttribute(xml,"name");
		if name == TeamName then
			local info = xmlNodeGetAttributes(xml)
			for key,value in pairs(info) do
				TeamDetails[key] = value;
			end
			return TeamDetails;
		end
		counter = counter+1;
	end
	if #TeamDetails < 1 then
		TeamDetails = nil;
		return false;
	end
end

for k, v in pairs (GetTeamDetails("Team3")) do
	print(v);
end
Edited by VenomNX
  • Thanks 1
Link to comment
7 hours ago, VenomNX said:

There are some ways, but i use this :


function AddTeamToXML(...)
	local xmlNode = xmlLoadFile("Teams.xml");
	if not xmlNode then
		xmlNode = xmlCreateFile("Teams.xml","Teams"); 
	end
	local valuesNumber = 0;
	while xmlFindChild(xmlNode,"Team",valuesNumber) do
		valuesNumber=valuesNumber+1;
	end
	local newNode = xmlCreateChild(xmlNode,"Team");
	local foundNode = xmlFindChild(xmlNode,"Team",valuesNumber);
	local boolean;
	if xmlNodeGetAttribute(foundNode,"name")~= arg[1] then
		xmlNodeSetAttribute(foundNode,"name",arg[1]);
		xmlNodeSetAttribute(foundNode,"color",arg[2]);
		boolean=true;
	else 
		boolean=false;
	end
	xmlSaveFile(xmlNode);
	xmlUnloadFile(xmlNode);
	return boolean
end

AddTeamToXML("Team1","0,0,0");
AddTeamToXML("Team2","255,0,0");
AddTeamToXML("Team3","0,255,0");
AddTeamToXML("Team4","0,0,255");

function GetTeamDetails(TeamName)
	local xmlNode = xmlLoadFile("Teams.xml");
	local TeamDetails = {};
	local counter = 0;
	while xmlFindChild(xmlNode,"Team",counter) do
		local xml = xmlFindChild(xmlNode,"Team",counter);
		local name = xmlNodeGetAttribute(xml,"name");
		if name == TeamName then
			local info = xmlNodeGetAttributes(xml)
			for key,value in pairs(info) do
				TeamDetails[key] = value;
			end
			return TeamDetails;
		end
		counter = counter+1;
	end
	if #TeamDetails < 1 then
		TeamDetails = nil;
		return false;
	end
end

for k, v in pairs (GetTeamDetails("Team3")) do
	print(v);
end

I'm trying with this script posted earlier, but I can't create the teams.

Config.xml empty:

<teams></teams>

 

 

Link to comment
  • 3 weeks later...

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