Adde Posted March 5, 2013 Share Posted March 5, 2013 Hello I have problem with a script. The script wont start and it says " lua:3: expected near ´(´ " in debug. I tried to change many different things but could not figure it out. A little help would be nice server side: exports.scoreboard:addScoreboardColumn('SALA') function() local playerTeam = getPlayerTeam ( source ) local account = getPlayerAccount(source) local zombiekills = getAccountData(account, "Zombie kills") if isObjectInACLGroup ("user."..accName1, aclGetGroup ( "Owner" ) ) then setAccountData ( account, "SALA", "Owner" ) elseif isObjectInACLGroup ("user."..accName1, aclGetGroup ( "Admin" ) ) then setAccountData ( account, "SALA", "Admin" ) elseif isObjectInACLGroup ("user."..accName1, aclGetGroup ( "SuperModerator" ) ) then setAccountData ( account, "SALA", "SuperModerator" ) elseif isObjectInACLGroup ("user."..accName1, aclGetGroup ( "Moderator" ) ) then setAccountData ( account, "SALA", "Moderator" ) elseif isObjectInACLGroup ("user."..accName1, aclGetGroup ( "TrialModerator" ) ) then setAccountData ( account, "SALA", "TrialModerator" ) elseif if ( playerTeam(SWAT) ) then setAccountData ( account, "SALA", "Player" ) elseif if ( playerTeam(Military) ) then setAccountData ( account, "SALA", "Player" ) elseif if ( playerTeam(Army) ) then setAccountData ( account, "SALA", "Player" ) end end ) addEventHandler("onPlayerSpawn",root, function () local Guest = getPlayerAccount(source) if isGuestAccount(Guest) then return end local sala = getAccountData(Guest,"SALA") if sala then setElementData(source,"SALA", sala) end end ) Link to comment
50p Posted March 5, 2013 Share Posted March 5, 2013 You have to give function a name. You can't define function the way you did it, unless you assign it to a variable. So, you can change the line 3 to one of the following: myFunction = function( ) -- OR function myFunction( ) Link to comment
Adde Posted March 5, 2013 Author Share Posted March 5, 2013 oh, hah ofc -.-´ Now I fixed some other things to but it says " lua:25: unexpected symbol near ´)´ ". When I remove that there´s nothing in debug but it doesn´t work. But when I look for unexpected symbols there I can´t find anything It looks like this now exports.scoreboard:addScoreboardColumn('SALA') function thesala() local playerTeam = getPlayerTeam ( source ) local account = getPlayerAccount(source) local zombiekills = getAccountData(account, "Zombie kills") if isObjectInACLGroup ("user."..accName1, aclGetGroup ( "Owner" ) ) then setAccountData ( account, "SALA", "Owner" ) elseif isObjectInACLGroup ("user."..accName1, aclGetGroup ( "Admin" ) ) then setAccountData ( account, "SALA", "Admin" ) elseif isObjectInACLGroup ("user."..accName1, aclGetGroup ( "SuperModerator" ) ) then setAccountData ( account, "SALA", "SuperModerator" ) elseif isObjectInACLGroup ("user."..accName1, aclGetGroup ( "Moderator" ) ) then setAccountData ( account, "SALA", "Moderator" ) elseif isObjectInACLGroup ("user."..accName1, aclGetGroup ( "TrialModerator" ) ) then setAccountData ( account, "SALA", "TrialModerator" ) elseif ( playerTeam(SWAT) ) then setAccountData ( account, "SALA", "Player" ) elseif ( playerTeam(Military) ) then setAccountData ( account, "SALA", "Player" ) elseif ( playerTeam(Army) ) then setAccountData ( account, "SALA", "Player" ) end end ) addEventHandler("onPlayerSpawn",root, function () local Guest = getPlayerAccount(source) if isGuestAccount(Guest) then return end local sala = getAccountData(Guest,"SALA") if sala then setElementData(source,"SALA", sala) end end ) Link to comment
Adde Posted March 5, 2013 Author Share Posted March 5, 2013 Remove the ")" at line 25. But then it doesn´t show the word/meaning on any players. I tried to restart and reconnect but nope. Link to comment
Castillo Posted March 5, 2013 Share Posted March 5, 2013 You aren't executing the function: "thesala" at all. Link to comment
Adde Posted March 5, 2013 Author Share Posted March 5, 2013 You mean like "it´s totaly wrong and not executing it" or like "I should add something. Or something else? Fuck, I forgot one thing -.- the 6th line... Link to comment
Castillo Posted March 5, 2013 Share Posted March 5, 2013 I don't know when you want to execute it, is your script. Link to comment
50p Posted March 5, 2013 Share Posted March 5, 2013 Line 17, wtf? playerTeam is a variable (team element or false) not a function... You can't use variables like if they were functions. You need to get the team's name and compare it with team names. You also need to call thesala function in your onPlayerSpawn callback. Link to comment
Adde Posted March 5, 2013 Author Share Posted March 5, 2013 I´ve got "local playerTeam = getPlayerTeam ( source )". This function gets the current team a player is on. Then "if playerTeam(SWAT) then *what to do* ". I looked through this https://community.multitheftauto.com/index.php?p=resources&s=details&id=5236 and thought that I could make it show the name of the acl group youré in or "player" if the player is not in any acl group. It was a test for myself but when the problems came I decided to talk about it here on forum. Link to comment
Sasu Posted March 6, 2013 Share Posted March 6, 2013 accName1 is not defined. exports.scoreboard:addScoreboardColumn('SALA') function thesala() local playerTeam = getPlayerTeam ( source ) local account = getPlayerAccount(source) local accName1 = getAccountName(account) local zombiekills = getAccountData(account, "Zombie kills") if isObjectInACLGroup ("user."..accName1, aclGetGroup ( "Owner" ) ) then setAccountData ( account, "SALA", "Owner" ) elseif isObjectInACLGroup ("user."..accName1, aclGetGroup ( "Admin" ) ) then setAccountData ( account, "SALA", "Admin" ) elseif isObjectInACLGroup ("user."..accName1, aclGetGroup ( "SuperModerator" ) ) then setAccountData ( account, "SALA", "SuperModerator" ) elseif isObjectInACLGroup ("user."..accName1, aclGetGroup ( "Moderator" ) ) then setAccountData ( account, "SALA", "Moderator" ) elseif isObjectInACLGroup ("user."..accName1, aclGetGroup ( "TrialModerator" ) ) then setAccountData ( account, "SALA", "TrialModerator" ) elseif ( playerTeam == "SWAT" ) then setAccountData ( account, "SALA", "Player" ) elseif ( playerTeam == "Military" ) then setAccountData ( account, "SALA", "Player" ) elseif ( playerTeam == "Army" ) then setAccountData ( account, "SALA", "Player" ) end end addEventHandler("onPlayerLogin", getRootElement(), thesala) addEventHandler("onPlayerLogin",root, function () local Guest = getPlayerAccount(source) if isGuestAccount(Guest) then return end local sala = getAccountData(Guest,"SALA") if sala then setElementData(source,"SALA", sala) end end ) Try this. Link to comment
Adde Posted March 6, 2013 Author Share Posted March 6, 2013 ah I see. Now it works thx! But not on Players, just those in acl groups. btw, can remove zombiekillsrow. It´s for nothing. Link to comment
Sasu Posted March 6, 2013 Share Posted March 6, 2013 ah I see. Now it works thx!But not on Players, just those in acl groups. btw, can remove zombiekillsrow. It´s for nothing. Yes, of course. exports.scoreboard:addScoreboardColumn('SALA') function thesala() local playerTeam = getPlayerTeam ( source ) local account = getPlayerAccount(source) local accName1 = getAccountName(account) if isObjectInACLGroup ("user."..accName1, aclGetGroup ( "Owner" ) ) then setAccountData ( account, "SALA", "Owner" ) elseif isObjectInACLGroup ("user."..accName1, aclGetGroup ( "Admin" ) ) then setAccountData ( account, "SALA", "Admin" ) elseif isObjectInACLGroup ("user."..accName1, aclGetGroup ( "SuperModerator" ) ) then setAccountData ( account, "SALA", "SuperModerator" ) elseif isObjectInACLGroup ("user."..accName1, aclGetGroup ( "Moderator" ) ) then setAccountData ( account, "SALA", "Moderator" ) elseif isObjectInACLGroup ("user."..accName1, aclGetGroup ( "TrialModerator" ) ) then setAccountData ( account, "SALA", "TrialModerator" ) elseif isObjectInACLGroup ("user."..accName1, aclGetGroup ( "Everyone" ) ) then setAccountData ( account, "SALA", "Player" ) elseif ( playerTeam == "SWAT" ) then setAccountData ( account, "SALA", "Player" ) elseif ( playerTeam == "Military" ) then setAccountData ( account, "SALA", "Player" ) elseif ( playerTeam == "Army" ) then setAccountData ( account, "SALA", "Player" ) end end addEventHandler("onPlayerLogin", getRootElement(), thesala) addEventHandler("onPlayerLogin",root, function () local Guest = getPlayerAccount(source) if isGuestAccount(Guest) then return end local sala = getAccountData(Guest,"SALA") if sala then setElementData(source,"SALA", sala) end end ) Now its works with players too. Link to comment
50p Posted March 7, 2013 Share Posted March 7, 2013 People should read more carefully... "playerTeam" will be TEAM ELEMENT not a string representing team's name. You need to get team name to compare it to string. You will get warning messages otherwise. Also, lines from 19 to 25 will never be reached. Every player is in "Everyone" group so this is where the code will ignore other statements. One more thing, there is no point having 2 different onPlayerLogin handlers, especially when you're setting and getting account data. Event handlers are triggered asynchronously that means the order of the handlers being triggered is not always the same. For example, if you call cancelEvent function in the top handler, this doesn't necessarily mean that the handler below will not be triggered because it may have been triggered before the top one. https://wiki.multitheftauto.com/wiki/CancelEvent Link to comment
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