Jump to content

[HELP] Clan Adding Script


Recommended Posts

function create()
FO = createTeam ( "Forever", 255, 0, 0 )
AV = createTeam ( "Avalanche", 255, 255, 255 )
GH = createTeam ( "Ghost", 255, 123, 0 )
end
function addplayer(player, cmd, target, clan)
local recipient = getPlayerFromName(target)
       local accName = getAccountName ( getPlayerAccount ( recipient ) ) -- get his account name
        if isObjectInACLGroup ("user."..accName, aclGetGroup ( clan  ) ) then
		outputChatBox("* " .. recipientName .. " is already in your clan" , player, 255, 0, 0, true)
        else
	  if recipient then
        local r, g, b
     	local recipientName = getPlayerName(recipient)
        local playerName = getPlayerName(player)
        outputChatBox("*" .. recipientName .. " #FFFFFF has been added #FF0000" .. clan .. "#FFFFFF clan" , player, 255, 0, 0, true)
        outputChatBox("*" .. playerName .. " #FFFFFF added you to #FF0000" .. clan .. "#FFFFFF  Clan", recipient, 255, 0, 0, true)
        setPlayerTeam ( recipient, clan )
        r, g, b = getTeamColor (clan)
        setPlayerNametagColor ( recipient, r, g, b )		
        aclGroupAddObject (aclGetGroup(clan), "user."..accName)
	 else
        outputChatBox("Sorry, we got 0 matches to the name" .. recipientName, player, 255, 0, 0)
     end  
   end
end

function kickplayer(player, cmd, target, clan)
       local recipient = getPlayerFromName(target)
       local accName = getAccountName ( getPlayerAccount ( recipient ) ) -- get his account name
       local r,g,b
	   if isObjectInACLGroup ("user."..accName, aclGetGroup ( clan ) ) then
	   setPlayerTeam ( recipient, nil )	
       setPlayerNametagColor ( recipient, 225, 225, 225 )
	   aclGroupRemoveObject (aclGetGroup(clan), "user."..accName)
	   else
      outputChatBox("The Player is Not in" .. clan .. "Clan" .. clan, player, 255, 0, 0)
end
end


addCommandHandler("add", addplayer)
addCommandHandler("ckick", kickplayer)

addEventHandler ( "onResourceStart", getRootElement(), create )

This is a Clan system that i am working on, and when i run the script i get 2 errors , one is from the "setPlayerTeam"  and the other one is from "GetTeamcolor"

First One is :  @ 'setPlayerTeam'  [ Expected team at argument 2, got string 'AV' ]

Second one is :  @ 'getTeamColor' [Expected team at argument, got string 'AV']

Pls help me out , ik what this means but havent found a way to fix this :( 

And since This forum has helped me a lot , i am asking here  , 

And also i would like to know a way to make this script to be able to Run for people In Acl group FOL , AVL and GHL  ( which are clan leaders )

Thanks in Advance :):D 

Edited by TheGrimReaper
Link to comment
function create()
FO = createTeam ( "Forever", 255, 0, 0 )
AV = createTeam ( "Avalanche", 255, 255, 255 )
GH = createTeam ( "Ghost", 255, 123, 0 )
end
function addplayer(player, cmd, target, clan)
local recipient = getPlayerFromName(target)
			 local accName = getAccountName ( getPlayerAccount ( recipient ) ) -- get his account name
				if isObjectInACLGroup ("user."..accName, aclGetGroup ( clan  ) ) then
		outputChatBox("* " .. recipientName .. " is already in your clan" , player, 255, 0, 0, true)
				else
		if recipient then
				local r, g, b
			local recipientName = getPlayerName(recipient)
				local playerName = getPlayerName(player)
				outputChatBox("*" .. recipientName .. " #FFFFFF has been added #FF0000" .. clan .. "#FFFFFF clan" , player, 255, 0, 0, true)
				outputChatBox("*" .. playerName .. " #FFFFFF added you to #FF0000" .. clan .. "#FFFFFF  Clan", recipient, 255, 0, 0, true)

				local team = getTeamFromName(clan) -- Get the actual team from the name provided.
				if (team) then -- If the team exists.
					setPlayerTeam ( recipient, team )
					r, g, b = getTeamColor (team)
					setPlayerNametagColor ( recipient, r, g, b )		
					aclGroupAddObject (aclGetGroup(clan), "user."..accName)
				else -- If the team the player has provided doesn't exist.
					outputChatBox("A clan with the name '" .. clan .. "' does not exist!", player, 255, 0, 0)
				end
	 else
				outputChatBox("Sorry, we got 0 matches to the name" .. recipientName, player, 255, 0, 0)
		 end  
	 end
end

function kickplayer(player, cmd, target, clan)
			 local recipient = getPlayerFromName(target)
			 local accName = getAccountName ( getPlayerAccount ( recipient ) ) -- get his account name
			 local r,g,b
		 if isObjectInACLGroup ("user."..accName, aclGetGroup ( clan ) ) then
		 setPlayerTeam ( recipient, nil )	
			 setPlayerNametagColor ( recipient, 225, 225, 225 )
		 aclGroupRemoveObject (aclGetGroup(clan), "user."..accName)
		 else
			outputChatBox("The Player is Not in" .. clan .. "Clan" .. clan, player, 255, 0, 0)
	end
end

addCommandHandler("add", addplayer)
addCommandHandler("ckick", kickplayer)
addEventHandler("onResourceStart", getRootElement(), create)

This should work fine.

And to only make the command work for those in the ALC group, you'll have to use isObjectInACLGroup and check if they have the group.

  • Like 1
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...