[DemoN] Posted June 9, 2011 Posted June 9, 2011 (edited) I was making a script but It says: ERROR: scripts\serverTeams.lua:3: Bad argument @ 'getPlayerAccount' Here is my code; (EDIT: setPlayerTeam" class="kw6">setPlayerTeam( source, memberTeam ) ACTUALLY: setPlayerTeam(source, memberTeam) dunno why it is posting like that ) local memberTeam = createTeam("Member", 0, 255, 0) local vipTeam = createTeam("V.I.P.", 0, 255, 255) local account = getPlayerAccount(source) function setTeams( source ) if isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Admin' ) ) then setPlayerTeam1( source, memberTeam ) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Moderator' ) ) then setPlayerTeam2( source, memberTeam ) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Member' ) ) then setPlayerTeam3( source, memberTeam ) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'V.I.P' ) ) then setPlayerTeam4( source, vipTeam ) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Scripter' ) ) then setPlayerTeam5( source, memberTeam ) else outputChatBox("You have successfully logged in.", source, 255, 0, 0) end end addEventHandler("onPlayerLogin", getRootElement(), setTeams) Edited June 9, 2011 by Guest My in game nick is Lemonade
karlis Posted June 9, 2011 Posted June 9, 2011 replace 1 of the letters for all the setPlayerTeam, for demonstration purposes only. [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
[DemoN] Posted June 9, 2011 Author Posted June 9, 2011 replace 1 of the letters for all the setPlayerTeam, for demonstration purposes only. Do you mean that? local memberTeam = createTeam("Member", 0, 255, 0) local vipTeam = createTeam("V.I.P.", 0, 255, 255) local account = getPlayerAccount(source) function setTeams( source ) if isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Admin' ) ) then setPlayerTeam(source, memberTeam) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Moderator' ) ) then setPlayerTeam(source, memberTeam) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Member' ) ) then setPlayerTeam(source, memberTeam) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'V.I.P' ) ) then setPlayerTeam(source, vipTeam) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Scripter' ) ) then setPlayerTeam(source, memberTeam) else outputChatBox("You have successfully logged in.", source, 255, 0, 0) end end addEventHandler("onPlayerLogin", getRootElement(), setTeams) My in game nick is Lemonade
Castillo Posted June 9, 2011 Posted June 9, 2011 He meant to add just one team, so comment out all the 'elseif' with "--" infront of line, and leave just ONE. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
karlis Posted June 9, 2011 Posted June 9, 2011 no, i meant to add some random letter to the setPlayerTeam ( for instance "setPlayerTeam1"), so the code isn't broken and we can help you fix it. [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
[DemoN] Posted June 9, 2011 Author Posted June 9, 2011 no, i meant to add some random letter to the setPlayerTeam ( for instance "setPlayerTeam1"), so the code isn't broken and we can help you fix it. local memberTeam = createTeam("Member", 0, 255, 0) local vipTeam = createTeam("V.I.P.", 0, 255, 255) local account = getPlayerAccount(source) function setTeams( source ) if isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Admin' ) ) then setPlayerTeam1( source, memberTeam ) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Moderator' ) ) then setPlayerTeam2( source, memberTeam ) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Member' ) ) then setPlayerTeam3( source, memberTeam ) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'V.I.P' ) ) then setPlayerTeam4( source, vipTeam ) elseif isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Scripter' ) ) then setPlayerTeam5( source, memberTeam ) else outputChatBox("You have successfully logged in.", source, 255, 0, 0) end end addEventHandler("onPlayerLogin", getRootElement(), setTeams) ok? My in game nick is Lemonade
karlis Posted June 9, 2011 Posted June 9, 2011 source is not defined outside the function, put it inside.(be sure to put the setPlayerTeam back to normal before testing) also i think you should remove the "else" and put the output for the login after the "if then elseif then end" block. [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
[DemoN] Posted June 9, 2011 Author Posted June 9, 2011 Everything is fine but it still says: WARNING: scripts\serverTeams.lua:2: Bad argument @ 'getPlayerAccount' My in game nick is Lemonade
karlis Posted June 9, 2011 Posted June 9, 2011 1)you were overwritten source parameter by old account parameter. 2)source doesn't exist outside the function. 3)this long elseif expression is very bad way to script. 4)the account variable is already a parameter, you don't need to get account. local memberTeam = createTeam("Member", 0, 255, 0) local vipTeam = createTeam("V.I.P.", 0, 255, 255) local memberGroups={"Admin","Moderator","Member","Scripter"} function setTeams(_,account) objName='user.'..getAccountName( account ) if isObjectInACLGroup( objName, aclGetGroup( 'V.I.P.' ) ) then setPlayerTeam1(source,vipTeam) else for _,v in ipairs(memberGroups) do if isObjectInACLGroup( objName,aclGetGroup(v)) then setPlayerTeam1(source,memberTeam) end end end outputChatBox("You have successfully logged in.", source, 255, 0, 0) end addEventHandler("onPlayerLogin", getRootElement(), setTeams) when running the file remove the "1" from setPlayerTeam [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
[DemoN] Posted June 10, 2011 Author Posted June 10, 2011 1)you were overwritten source parameter by old account parameter.2)source doesn't exist outside the function. 3)this long elseif expression is very bad way to script. 4)the account variable is already a parameter, you don't need to get account. local memberTeam = createTeam("Member", 0, 255, 0) local vipTeam = createTeam("V.I.P.", 0, 255, 255) local memberGroups={"Admin","Moderator","Member","Scripter"} function setTeams(_,account) objName='user.'..getAccountName( account ) if isObjectInACLGroup( objName, aclGetGroup( 'V.I.P.' ) ) then setPlayerTeam1(source,vipTeam) else for _,v in ipairs(memberGroups) do if isObjectInACLGroup( objName,aclGetGroup(v)) then setPlayerTeam1(source,memberTeam) end end end outputChatBox("You have successfully logged in.", source, 255, 0, 0) end addEventHandler("onPlayerLogin", getRootElement(), setTeams) when running the file remove the "1" from setPlayerTeam I don't know how to use tables so i use alot of elseif command... and Thanks for helping.... My in game nick is Lemonade
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now