Jump to content

Need help with a staff team command please.


Baingo

Recommended Posts

Ok im just trying to make a basic script new to scripting and so everything works fine for it so far except when i type the command, the player will move into the staff team for 1-2 seconds then go back to not being in a team, cant quite work it out. All help will be very appreciated Thank you.

function setStaffSkin (thePlayer) 
    if (isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(thePlayer)),aclGetGroup("Admin", "Moderator", "SuperModerator"))) then 
        setPedSkin ( thePlayer, 217 ) 
        outputChatBox ( "You are now on the Staff Team.", thePlayer, 255, 0, 0 ) 
         
    else 
        outputChatBox ("You must be a Staff to use this command!",thePlayer,255,0,0) 
  
    end 
end 
addCommandHandler ( "staff", setStaffSkin) 
  
function assignNewTeam ( thePlayer, commandName, Staff ) 
  local theTeam = createTeam ("Staff")  -- create a new team with the specified name 
  if theTeam then                          -- if it was successfully created 
    setPlayerTeam ( thePlayer, theTeam )    -- add the player to the new team 
  end 
end 
addCommandHandler ( "staff", assignNewTeam ) 
 ------------ From here down was something i added after was just trying to see if it fixed it not sure if its necessary or not. 
function setTeam(thePlayer) 
    local account = getPlayerAccount(thePlayer) 
    local theTeam = getAccountData (account, "Staff") 
        if theTeam and getTeamFromName(theTeam) then 
              setPlayerTeam(thePlayer, getTeamFromName(theTeam)) 
    end 
end 
addEventHandler("onPlayerLogin",getRootElement(),setTeam) 
  
function saveTeam(thePlayer) 
    local theTeam = getPlayerTeam(thePlayer) 
    local account = getPlayerAccount(thePlayer) 
       if (theTeam) and not isGuestAccount(account) then 
          setAccountData(account, "Staff", getTeamName(theTeam)) 
    end 
end 
addEventHandler("onPlayerQuit",getRootElement(),saveTeam) 

Link to post

Yea another script was the problem, Thanks. except one problem i have now is that when i reconnect after using staff command it wont have the team there, have to retype the command the join the team this is there error i get

WARNING: staff\staff.lua:22: Bad argument @ 'getPlayerAccount' [Expected element at argument 1]

WARNING: staff\staff.lua:23: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean]

not sure what i have to change on this:

function setTeam(thePlayer) 
    local account = getPlayerAccount(thePlayer) 
    local theTeam = getAccountData (account, "Staff") 
        if theTeam and getTeamFromName(theTeam) then 
              setPlayerTeam(thePlayer, getTeamFromName(theTeam)) 
    end 
end 
addEventHandler("onPlayerLogin",getRootElement(),setTeam) 
  
function saveTeam(thePlayer) 
    local theTeam = getPlayerTeam(thePlayer) 
    local account = getPlayerAccount(thePlayer) 
       if (theTeam) and not isGuestAccount(account) then 
          setAccountData(account, "Staff", getTeamName(theTeam)) 
    end 
end 
addEventHandler("onPlayerQuit",getRootElement(),saveTeam) 

Link to post
function setTeam() 
    local account = getPlayerAccount(source) 
    local theTeam = getAccountData (account, "Staff") 
        if theTeam and getTeamFromName(theTeam) then 
              setPlayerTeam(source, getTeamFromName(theTeam)) 
    end 
end 
addEventHandler("onPlayerLogin",getRootElement(),setTeam) 
  
function saveTeam() 
    local theTeam = getPlayerTeam(source) 
    local account = getPlayerAccount(source) 
       if (theTeam) and not isGuestAccount(account) then 
          setAccountData(account, "Staff", getTeamName(theTeam)) 
    end 
end 
addEventHandler("onPlayerQuit",getRootElement(),saveTeam) 

Link to post

That fixed the error, but it still doesnt come up when i reconnect. Have to use the command again to join the team. is there a function im missing maybe? EDIT: ok i changed it around a bit now instead of the command making a team i have the team start up on resource start, i just still have the problem that it wont be in the team when i reconnect.

Link to post

Are you talking about when you join or login?

This would only work if you logged in, because it save the player team in the databaase, but if the player join and just goes on any team, then there's no way that it could be saved that the person was every on that team.

Link to post

Yea I'm talkin about when u login I can get the staff team to stay there just when I reconnect with my account then log back in with admin account it won't put me on staff team, I have a downloaded save_system from the community which also won't save weapons not sure why error @getweapons, butif there is nothing wrong with team save function, could that cause a problem?

Link to post

EDIT: Ok sorted the problem, another script =\ thanks heaps for your help everyone. except now what im trying to do right, is have it so when they type /staff it will change their skin and whatever else, then the type a command to go to a normal team non admin related how can i get it to change back to the skin that they had previously? :D

This is what i have: Staff script ^^^^^

function assignCivTeam ( source, commandName, teamName ) 
    if (isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(source)),aclGetGroup("Everyone"))) then 
    local theTeam = getTeamFromName ("Civilians")  -- add to team 
        if theTeam then 
            setPlayerTeam ( source, theTeam ) 
            setPlayerNametagColor ( source, 255, 255, 0 ) 
            outputChatBox ( "You are now on the Civilians Team.", source, 255, 255, 0 ) 
     
        end 
    end 
end 
addCommandHandler ( "civ", assignCivTeam ) 

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