Jump to content

Need Help


sckatchof

Recommended Posts

hi guys i make a script when i type /criminal i became on the team

this is my script

  
criminalTeam = createTeam ("Criminal", 255, 0, 0) 
  
  
function joinTeam (source) 
   local criminalTeam = getTeamFromName ("Criminal") 
       if (criminalTeam) then 
          setElementData( localPlayer, "Job", "Criminal", true ) 
          setPlayerTeam (source, criminalTeam) 
          setElementModel (source, 29) 
       end 
end 
addCommandHandler ("criminal", joinTeam) 

Link to comment
criminalTeam = createTeam ("Criminal", 255, 0, 0) 
  
function joinTeam (thePlayer) 
    setElementData( thePlayer, "Job", "Criminal", true ) 
    setPlayerTeam (thePlayer, criminalTeam) 
    setElementModel (thePlayer, 29) 
end 
addCommandHandler ("criminal", joinTeam) 

Link to comment
criminalTeam = createTeam ("Criminal", 255, 0, 0) 
  
function joinTeam (thePlayer) 
    setElementData( thePlayer, "Job", "Criminal", true ) 
    setPlayerTeam (thePlayer, criminalTeam) 
    setElementModel (thePlayer, 29) 
end 
addCommandHandler ("criminal", joinTeam) 

work :)

Thank you snake for help

Link to comment

but in this dont work why ?

Bad argument @'setElementData'

    staffTeam = createTeam ("Staff", 255, 255, 255) 
    setTeamFriendlyFire (staffTeam, false) 
  
function joinTeam (source) 
   local accName = getAccountName (getPlayerAccount (source)) 
   if (isObjectInACLGroup ("user." .. accName, aclGetGroup("Admin")) or isObjectInACLGroup ("user." .. accName, aclGetGroup ("Moderator")) or isObjectInACLGroup ("user." .. accName, aclGetGroup ("SuperModerator")) ) then 
       if (staffTeam) then  
          setPlayerTeam (source, staffTeam) 
          setElementData( thePlayer, "Jobn", "Head Staff", true ) 
          outputChatBox ( "You are now Staff.", 0,255, 0 ) 
       end 
    end 
end 
addCommandHandler ("staff", joinTeam) 

Link to comment
staffTeam = createTeam ("Staff", 255, 255, 255) 
setTeamFriendlyFire (staffTeam, false) 
  
function joinTeam (thePlayer) 
   local accName = getAccountName (getPlayerAccount (thePlayer)) 
   if ( isObjectInACLGroup ("user." .. accName, aclGetGroup("Admin")) or isObjectInACLGroup ("user." .. accName, aclGetGroup ("Moderator")) or isObjectInACLGroup ("user." .. accName, aclGetGroup ("SuperModerator")) ) then 
        if (staffTeam) then 
            setPlayerTeam (thePlayer, staffTeam) 
            setElementData( thePlayer, "Occupation", "Head Staff", true ) 
            outputChatBox ( "You are now Staff.", thePlayer, 0,255, 0 ) 
        end 
    end 
end 
addCommandHandler ("staff", joinTeam) 

Link to comment
staffTeam = createTeam ("Staff", 255, 255, 255) 
setTeamFriendlyFire (staffTeam, false) 
  
function joinTeam (thePlayer) 
   local accName = getAccountName (getPlayerAccount (thePlayer)) 
   if ( isObjectInACLGroup ("user." .. accName, aclGetGroup("Admin")) or isObjectInACLGroup ("user." .. accName, aclGetGroup ("Moderator")) or isObjectInACLGroup ("user." .. accName, aclGetGroup ("SuperModerator")) ) then 
        if (staffTeam) then 
            setPlayerTeam (thePlayer, staffTeam) 
            setElementData( thePlayer, "Occupation", "Head Staff", true ) 
            outputChatBox ( "You are now Staff.", thePlayer, 0,255, 0 ) 
        end 
    end 
end 
addCommandHandler ("staff", joinTeam) 

thank you again snake :D

Link to comment

So your code.

outputChatBox ( "You are now Staff.",  0,255, 0 ) 

Correct

outputChatBox ( "You are now Staff.", source, 0,255, 0 ) 

Because in server side 6 arguments , in client side 5 arguments.

And you use not defiend variable thePlayer ( nil ).

here

setElementData( thePlayer, "Jobn", "Head Staff", true ) 

Correct

setElementData( source, "Jobn", "Head Staff", true ) 

Because you add to arguments command handler function first argument 'source'.

staffTeam = createTeam ( "Staff", 255, 255, 255 ) 
setTeamFriendlyFire ( staffTeam, false ) 
  
function joinTeam ( source ) 
   local accName = getAccountName ( getPlayerAccount ( source ) ) 
   if isObjectInACLGroup ( "user." .. accName, aclGetGroup( "Admin" ) ) or  
   isObjectInACLGroup ( "user." .. accName, aclGetGroup ( "Moderator" ) ) or 
   isObjectInACLGroup ( "user." .. accName, aclGetGroup ( "SuperModerator" ) ) then 
        if staffTeam then 
            setPlayerTeam ( source, staffTeam ) 
            setElementData( source, "Occupation", "Head Staff", true ) 
            outputChatBox ( "You are now Staff.", source, 0,255, 0 ) 
        end 
    end 
end 
addCommandHandler ( "staff", joinTeam ) 

Full correct code.

I think you not read my post just copy paste :/

Link to comment

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