Jump to content

setElementHealth not work when player join server


iiv03

Recommended Posts

hey everyone i make that code and it didn't work with me

function checkjoin()
local players = getElementsByType("players")
for k,v in ipairs(players) do
if getElementData(v, "state") =="alive" then
setElementHealth(v,0)
		end
	end
end
addEventHandler("onPlayerJoin",getRootElement(), checkjoin)
addEventHandler("onRaceStateChanging",getRootElement(), checkjoin)

 

Link to comment
9 hours ago, komal said:

your problem here


local players = getElementsByType("players")

 

 

replace it to:


 
  1.  
  1.  
  1. local players = getElementsByType ( "player" )

i try with this when player join didn't work it's tell me Failed in chat :/ where problem?

function checkjoin()
local players = getElementType("player")
	setPlayerTeam(players, team[3])
	if not players then
	outputChatBox("Failed")
	end
end
addEventHandler("onPlayerJoin",getRootElement(), checkjoin)

btw when i use addCommandHandler in this a function and worked get me in the team but why that doesn't worked when join player?

and x2 try

 

function checkjoin(player)
	setPlayerTeam(player, team[3])
	if not player then
	outputChatBox("Failed")
	end
end
addEventHandler("onPlayerJoin",getRootElement(), checkjoin)

i think problem ("I did not use getTeamName?")

Edited by xFabel
Link to comment
1 hour ago, Dimos7 said:

where is your team table first

bro everything work but only when join server didn't warp me into team

team = {}
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()),
function(startedRes)
	team.syncElement = createElement("clanwar_syncElement", "clanwar_syncElement")
	setElementData(source,"16091976AntiStealScriptbyShimu01022009ReadingSecretCode","Passed")
	if getResourceName(getThisResource()) == getResourceName(startedRes) then
		team[3] = createTeam ( "Spectators", 255, 255, 255 )
				
--etc
	end
end
)

 

Edited by xFabel
Link to comment
16091976AntiStealScriptbyShimu01022009ReadingSecretCode

Stop using my scripts without my permission. Was a mistake to upload an uncopiled' version  with the ''security code some years ago.

However, Im glad that I didnt know a lot of stuffs about scripting and I made a dirty code that for beginners might is confuse.

Topic reported and regards. :)

Link to comment
  • IIYAMA locked this topic
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...