Jump to content

Gang Kick


JanKy

Recommended Posts

Hi guys,

Can someone help me understand what am i doing wrong? I mean, i have a gang resource for my DayZ server and the kick function wont work properly.

I mean, the leave function works fine

Spoiler

if (intention == "leave") then
		local team = getPlayerGang(client);
		local rank = getPlayerGangRank(client);
		if (rank == "Sub Leader") then
			dbExec(db, "UPDATE `teams` SET `subleader`=? WHERE `name`='"..team.."'", "");
		end
		outputTeamChat(getPlayerName(client).." left the team.", team);
		removeElementData(client, "gang");
		removeElementData(client, "gang.rank");
		local acc = getPlayerAccount(client);
		setAccountData(acc, "gang", nil);
		dbExec(db, "DELETE FROM `team_acc` WHERE `username`=?", getAccountName(acc));
		gangUpdate(team);
		triggerClientEvent(client, "gang.close", client);

 

But, when i try to kick a friend, it gets kicked out of the gang but it still remains in tab as in that gang, and can open the gang panel ( F2 ) but it is empty.

Spoiler

elseif (intention == "kick") then
		local team = getPlayerGang(client);
		for _,acc in ipairs(getAccounts()) do
			local accName = getAccountName(acc);
			if (accName == player) then
				local accRank = getAccountGangRank(accName);
				if (accRank ~= "Sub Leader") then
					if (accRank ~= "Leader") then
						setAccountData(acc, "gang", nil);
						outputTeamChat(player.." was kicked from the team by #ffffff"..getPlayerName(client), team);
						dbExec(db, "DELETE FROM `team_acc` WHERE `username`=?", player);
						local accp = getAccountPlayer(player);
						if accp then
							setElementData(accp, "gang", nil);
							setElementData(accp, "gang.rank", nil);
						end
						gangUpdate(team);

 

I even tried to replace nil with "None" because that's the default value for every player which isn't part of any group.

Thanks in advance.

Link to comment

So, i did this

	elseif (intention == "kick") then
		for _,acc in ipairs(getAccounts()) do
			local accName = getAccountName(acc);
			if (accName == player) then
				local accRank = getAccountGangRank(accName);
				if (accRank ~= "Sub Leader") then
					if (accRank ~= "Leader") then
						outputTeamChat(player.." was kicked from the team by #ffffff"..getPlayerName(client), team);
						removeElementData(player, "gang");
						removeElementData(player, "gang.rank");
						local accp = getPlayerAccount(player);
						setAccountData(accp, "gang", nil);
						dbExec(db, "DELETE FROM `team_acc` WHERE `username`=?", getAccountName(accp));
						gangUpdate(team);
					end
				end
			end
		end

Which i think it is very correct, i mean the leave intention, which mentioned before, is pretty close to this one. But that one still works, and this one not. And i get these in debugscript

Bad argument @ 'removeElementData' [Expected element at argument 1, got string 'the name of the player i try to kick']

Bad argument @ 'removeElementData' [Expected element at argument 1, got string 'the name of the player i try to kick']

Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got string 'the name of the player i try to kick']

Bad argument @ 'setAccountData' [Expected element at argument 1, got boolean]

Bad argument @ 'getAccountName' [Expected element at argument 1, got boolean]

Link to comment

I don't think i need to add an element data. I mean, my only question for you all i

why does this work

	if (intention == "leave") then
		local team = getPlayerGang(client);
		local rank = getPlayerGangRank(client);
		if (rank == "Sub Leader") then
			dbExec(db, "UPDATE `teams` SET `subleader`=? WHERE `name`='"..team.."'", "");
		end
		outputTeamChat(getPlayerName(client).." left the team.", team);
		removeElementData(client, "gang");
		removeElementData(client, "gang.rank");
		local acc = getPlayerAccount(client);
		setAccountData(acc, "gang", nil);
		dbExec(db, "DELETE FROM `team_acc` WHERE `username`=?", getAccountName(acc));
		gangUpdate(team);
		triggerClientEvent(client, "gang.close", client);

and this does not work

	elseif (intention == "kick") then
		for _,acc in ipairs(getAccounts()) do
			local accName = getAccountName(acc);
			if (accName == player) then
				local accRank = getAccountGangRank(accName);
				if (accRank ~= "Sub Leader") then
					if (accRank ~= "Leader") then
						outputTeamChat(player.." was kicked from the team by #ffffff"..getPlayerName(client), team);
						removeElementData(player, "gang");
						removeElementData(player, "gang.rank");
						local accp = getPlayerAccount(player);
						setAccountData(accp, "gang", nil);
						dbExec(db, "DELETE FROM `team_acc` WHERE `username`=?", getAccountName(accp));
						
						gangUpdate(team);
					end
				end
			end
		end

*PS : I am sorry, by "the name of the player i try to kick" i mean "the name of the account of the player i try to kick", so that works all fine

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