Jump to content

Help gang system


Dimos7

Recommended Posts

local xmlFileName = "account.xml"
function appendSavedData(parameter, value)
    local xmlFile = xmlLoadFile(xmlFileName)
    if not (xmlFile) then
       xmlFile = xmlCreateFile(xmlFileName, "gang")
    end
	local xmlNode = xmlFindChild(xmlFile, parameter, 0)
	if not (xmlNode) then
	   xmlNode = xmlCreateChild(xmlFile, parameter)
	end
	xmlNodeSetValue(xmlNode, value)
	xmlSaveFile(xmlFile)
	xmlUnloadFile(xmlFile)
end

function loadSavedData(parameter, value)
    local xmlRoot = xmlLoadFile(xmlFileName)
	if (xmlRoot) then
	    local xmlNode = xmlFindChild(xmlRoot, parameter, 0)
		if (xmlNode) then
		   return xmlNodeGetValue(xmlNode)
		end
	end
end

function createGang(player,name, r, g, b)
   local money = getPlayerMoney(player)
   local color = loadSavedData("Color", r..g..b)
   if money >= 250000 then
      if type(name) ~= "string" then
	     if not color then
	        if tonumber(r) >= 0 or <= 255  and tonumber(g) >= 0 or <=255 and  tonumber(b)  >= 0 or <= 255 then
		        takePlayerMoney(player, 250000)
			    gang = createTeam(name ,r ,g, b)
			    setPlayerTeam(player gang)
			    nick = getPlayerName(player)
			    appendSavedData("Name", tostring(name))
			    appendSavedData("Color", r..g..b)
			    appendSavedData("Rank", "Leader")
			    appendSavedData("Founder", nick)
			    appendSavedData("XP", 0)
			else
			  outputChatBox("The r, g, b must be 0 to 255!", player, 255, 0, 0)
			end
		 else
		   outputChatBox("That color already exist to a gang choose another color!", player, 255,0, 0)
		 end
	  else
	    outputChatBox("Use : /create name , r, g, b for create a gang!", player, 255, 0, 0)
	  end
	else
	   outputChatBox("You don't have enough money for this (250000$) required!", player, 255, 0, 0) 
	end
end
addCommandHandler("create", createGang)

the error is on line 32 unexpected simpole near <= 

Edited by Dimos7
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...