Jump to content

setPlayerTeam won't work :/


crismar

Recommended Posts

Posted

Ok I'm having a DayZ Gamemode (legal one) and I have made a couple of systems. One of them is the VIP system, which is adding a text on top of player if his team is VIP. Now, the problem is I have this code:

function createVIPTeam () 
    vipTeam = createTeam ( "VIP", 255, 0, 0 ) 
end 
addEventHandler("onResourceStart", resourceRoot, createVIPTeam) 
  
function setVIPTeam() 
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("VIP")) then 
   setPlayerTeam(source, vipTeam) 
   outputChatBox("#00FF00VIP: Bine ai revenit #FFFFFF"..getPlayerName(source), source, 255, 0, 0, true) 
   end 
end 
addEventHandler("onPlayerLogin", getRootElement(), setVIPTeam) 

And it works, I am in VIP group, when I connect the message shows up, but the team doesn't get set, any ideas why ? :|

Contact me if you are looking for a Web Developer.

3rd of October 2014 - Founder of RomaniaZ

  • Moderators
Posted

Try:

function createVIPTeam () 
    vipTeam = createTeam ( "VIP", 255, 0, 0 ) 
end 
addEventHandler("onResourceStart", resourceRoot, createVIPTeam) 
  

too:

--[[function createVIPTeam ()]] 
    vipTeam = createTeam ( "VIP", 255, 0, 0 ) 
--[[end 
addEventHandler("onResourceStart", resourceRoot, createVIPTeam)]] 

onResourceStart has a delay till all code has been loaded.

I am not sure if that is the problem, but it is possible when players login automatic.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted
Try:

function createVIPTeam () 
    vipTeam = createTeam ( "VIP", 255, 0, 0 ) 
end 
addEventHandler("onResourceStart", resourceRoot, createVIPTeam) 
  

too:

--[[function createVIPTeam ()]] 
    vipTeam = createTeam ( "VIP", 255, 0, 0 ) 
--[[end 
addEventHandler("onResourceStart", resourceRoot, createVIPTeam)]] 

onResourceStart has a delay till all code has been loaded.

I am not sure if that is the problem, but it is possible when players login automatic.

This wouldn't matter, because the "vipTeam" variable is only called when a player is logged in.

Are there any errors in /debugscript 3?

Posted

No, I get no warnings or errors in debugscript. That's what made me ask for help.

Contact me if you are looking for a Web Developer.

3rd of October 2014 - Founder of RomaniaZ

Posted
Try this
setPlayerTeam ( source, getTeamFromName ( "VIP" ) )  

You sir are my hero. It worked hah!

Thank you a lot :P

Contact me if you are looking for a Web Developer.

3rd of October 2014 - Founder of RomaniaZ

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