Jump to content

Bad Arg with GetTeamFromName


Recommended Posts


addEventHandler("onColShapeHit", group,
function (thePlayer)
local team = getPlayerTeam( thePlayer ); -- Here Bad Arg
if getElementType ( thePlayer ) == "player" then 
CN = getElementData(source, "name")
for i = 1, #C do 
if source == C[i] then
if getTeamName(team) == "1" then
outputChatBox ("1", getRootElement(), 255, 0, 0, true )
else
if getTeamName(team) == "2" then
outputChatBox ("2", getRootElement(), 255, 0, 0, true )
end
end
end
end
end
end
end, true)

this Function Start when player hit colshape
i want when hit colshape Check if Player in Team "1"

then outputChatBox "1"

if player in Team "2"

then

outputChatBox "2"

if not 1 or 2

then

ourpurChatBox " 3 "
Thx For @Tekken

Edited by Monument
Link to post

First of all you should move the getPlayetTeam after the getElementType function so you make sure it's a player:

This should do it:

addEventHandler("onColShapeHit", group, function(hitElement)
	if getElementType(hitElement) == "player" then
		local team = getPlayerTeam(hitElement) or false;
		local CN = getElementData(source, "name"); --??
		for i = 1, #C do 
			if source == C[i] then
				if team then
					outputChatBox(getTeamName(team), hitElement, 255, 0, 0, true);
				end
			end
		end
	end
end);

 

Link to post
1 hour ago, Tekken said:

First of all you should move the getPlayetTeam after the getElementType function so you make sure it's a player:

This should do it:


addEventHandler("onColShapeHit", group, function(hitElement)
	if getElementType(hitElement) == "player" then
		local team = getPlayerTeam(hitElement) or false;
		local CN = getElementData(source, "name"); --??
		for i = 1, #C do 
			if source == C[i] then
				if team then
					outputChatBox(getTeamName(team), hitElement, 255, 0, 0, true);
				end
			end
		end
	end
end);

 

Thank you

but i don't know how to make it  for a specific team only

if Team " 1 "
do someting

if Team "2"

do other someting

 

i said outputchatbox for exmaple only

Link to post

It’s simple:

local name = getTeamName(team);
if name == "1" then
-- do something
elseif name == "2" then
-- do something else
else
-- do something else else..
end

And so on and so forth.

This is just an idea you can make it even better with tables and stuff much faster/better.

Link to post

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