Jump to content

Some troubles with teams


JAY.ANN

Recommended Posts

Posted

I can't add a player to team or get a team element/name. What's wrong with my code?

First of all, In "spawnOnLogin()" function we can see that I want to force a player into a "Props" team. But it doesn't work like that.

addEventHandler("onResourceStart", resourceRoot, function()
propTeam = createTeam( "Props", 150, 200, 255 )
seekTeam = createTeam( "Seekers", 255, 0, 0 )
end)

function setTeamBinds( player )
	if isPlayerInTeam( player, "Props" ) then
	toggleControl( player, "fire", false )
	toggleControl( player, "aim_weapon", false )
	toggleControl( player, "next_weapon", false )
	toggleControl( player, "previous_weapon", false )
	toggleControl( player, "enter_exit", false )
	toggleControl( player, "jump", false )
	toggleControl( player, "crouch", false )
	end
end
addEvent( "setTeamBinds", true )
addEventHandler( "setTeamBinds", getRootElement(), setTeamBinds )

function spawnOnLogin()
spawnPlayer( source, 0, 0, 5, 0, math.random( 0, 288 ), 0, 0 )
fadeCamera( source, true )
setCameraTarget( source, source )
setPlayerTeam( source, propTeam )
setTeamBinds( source )
end
addEventHandler( "onPlayerLogin", root, spawnOnLogin )

 

Posted
Just now, Burak5312 said:

I don't see any problem in your code maybe you can check meta.xml make sure the file is on the server side

I've already did that - It's on the server side. I also have OOP turned on.

Posted (edited)

I tested your code now, it works perfectly no errors creating teams seamlessly and puts player in props team

Edited by Burak5312
Posted (edited)

Can you show the meta.xml and is there any other script running besides this script? If so, you can try turning them off.

Edited by Burak5312
Posted
2 minutes ago, Burak5312 said:

Can you show the meta.xml and is there any other script running besides this script? If so, you can try turning them off.

There's only one script on my server.
Here's the meta.xml (I don't know why, but I can't send it as a code):
 

<meta>

<oop>true</oop>

<script src="server.lua" type="server" cache="false"/>
<script src="shared.lua" type="shared" cache="false"/>
<script src="client.lua" type="client" cache="false"/>

</meta>

Posted (edited)

In which file are these codes stored client, server, shared? if shared just write them on server side and try to delete the oop line

Edited by Burak5312
Posted
Just now, Burak5312 said:

In which file are these codes stored client, server, shared? if shared just write them on server side and try to delete the oop line

This code is in the "server.lua". And it doesn't matter if I have OOP turned on - I've already tested that.

Posted

As I said, the codes are working fine for me, you are doing something wrong, maybe you can try to remove the cache=false part for the server, if it doesn't happen again, I don't know.

Posted
Just now, Burak5312 said:

As I said, the codes are working fine for me, you are doing something wrong, maybe you can try to remove the cache=false part for the server, if it doesn't happen again, I don't know.

I hope so?

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