Deadmau5 Posted January 23, 2012 Share Posted January 23, 2012 I have a big problem... my script always returns error if i use this function putplayerteamneu( ) local serial = getPlayerSerial (source ) if isObjectInACLGroup ( "serial." .. serial, aclGetGroup ( "Member" ) ) then setPlayerTeam ( source, getTeamFromName( "Members" ) ) setElementData( source, "pptts.acl", "Members") else if isObjectInACLGroup ( "serial." .. serial, aclGetGroup ( "Moderator" ) ) then setPlayerTeam ( source, getTeamFromName( "Moderators" ) ) setElementData( source, "pptts.acl", "Moderator") else if isObjectInACLGroup ( "serial." .. serial, aclGetGroup ( "Owner" ) ) then setPlayerTeam ( source, getTeamFromName( "Server Owners" ) ) setElementData( source, "pptts.acl", "Owner") setElementData( source, "pptts.canusemakeadmin", true) else if isObjectInACLGroup ( "serial." .. serial, aclGetGroup ( "Admin" ) ) then setPlayerTeam ( source, getTeamFromName( "Admins" ) ) setElementData( source, "pptts.acl", "Admin") else if isObjectInACLGroup ( "serial." .. serial, aclGetGroup ( "VIP" ) ) then setPlayerTeam ( source, getTeamFromName( "VIP" ) ) setElementData( source, "pptts.acl", "VIP") else setPlayerTeam ( source, getTeamFromName( "Players" ) ) end end addEventHandler ( "onPlayerJoin", getRootElement(), putplayerteamneu ) Because don't i close it with the else if? Pls help with this =( Link to comment
Kenix Posted January 23, 2012 Share Posted January 23, 2012 (edited) http://www.lua.org/manual/5.1/ function putplayerteamneu( ) local serial = getPlayerSerial (source ) if isObjectInACLGroup ( "serial." .. serial, aclGetGroup ( "Member" ) ) then setPlayerTeam ( source, getTeamFromName( "Members" ) ) setElementData( source, "pptts.acl", "Members") elseif isObjectInACLGroup ( "serial." .. serial, aclGetGroup ( "Moderator" ) ) then setPlayerTeam ( source, getTeamFromName( "Moderators" ) ) setElementData( source, "pptts.acl", "Moderator") elseif isObjectInACLGroup ( "serial." .. serial, aclGetGroup ( "Owner" ) ) then setPlayerTeam ( source, getTeamFromName( "Server Owners" ) ) setElementData( source, "pptts.acl", "Owner") setElementData( source, "pptts.canusemakeadmin", true) elseif isObjectInACLGroup ( "serial." .. serial, aclGetGroup ( "Admin" ) ) then setPlayerTeam ( source, getTeamFromName( "Admins" ) ) setElementData( source, "pptts.acl", "Admin") elseif isObjectInACLGroup ( "serial." .. serial, aclGetGroup ( "VIP" ) ) then setPlayerTeam ( source, getTeamFromName( "VIP" ) ) setElementData( source, "pptts.acl", "VIP") else setPlayerTeam ( source, getTeamFromName( "Players" ) ) end end addEventHandler ( "onPlayerJoin", root, putplayerteamneu ) Edited January 23, 2012 by Guest Link to comment
BriGhtx3 Posted January 23, 2012 Share Posted January 23, 2012 function putplayerteamneu( ) local serial = getPlayerSerial (source ) if isObjectInACLGroup ( "serial." .. serial, aclGetGroup ( "Member" ) ) then setPlayerTeam ( source, getTeamFromName( "Members" ) ) setElementData( source, "pptts.acl", "Members") elseif isObjectInACLGroup ( "serial." .. serial, aclGetGroup ( "Moderator" ) ) then setPlayerTeam ( source, getTeamFromName( "Moderators" ) ) setElementData( source, "pptts.acl", "Moderator") elseif isObjectInACLGroup ( "serial." .. serial, aclGetGroup ( "Owner" ) ) then setPlayerTeam ( source, getTeamFromName( "Server Owners" ) ) setElementData( source, "pptts.acl", "Owner") setElementData( source, "pptts.canusemakeadmin", true) elseif isObjectInACLGroup ( "serial." .. serial, aclGetGroup ( "Admin" ) ) then setPlayerTeam ( source, getTeamFromName( "Admins" ) ) setElementData( source, "pptts.acl", "Admin") elseif isObjectInACLGroup ( "serial." .. serial, aclGetGroup ( "VIP" ) ) then setPlayerTeam ( source, getTeamFromName( "VIP" ) ) setElementData( source, "pptts.acl", "VIP") else setPlayerTeam ( source, getTeamFromName( "Players" ) ) end end addEventHandler ( "onPlayerJoin", getRootElement(), putplayerteamneu ) Link to comment
Deadmau5 Posted January 23, 2012 Author Share Posted January 23, 2012 (edited) Muchas gracias //EDIT: Now i need a makeadmin command... But why this dont work? function adminCMD(player, otherplayer, level) if getElementData(player, "pptts.canusemakeadmin") then -- the shared logic if otherplayer then local serial = getPlayerSerial(otherplayer) local thegroup = aclGetGroup(getElementData(otherplayer, "pptts.acl")) local otherplayername = getPlayerName( otherplayer ) local playername = getPlayerName(player) if level == "Nichts" then aclGroupRemoveObject ( thegroup, "serial." ..serial ) outputChatBox(playername.. "hat dir deine Rechte entzogen!", otherplayer) outputChatBox("Du hast" ..otherplayername "die Rechte entzogen!",player) elseif level == "Member" then aclGroupRemoveObject ( thegroup, "serial." ..serial ) setElementData(otherplayer, "pptts.acl", "Member") aclGroupAddObject( aclGetGroup("Member"), "serial."..otherplayername) outputChatBox(playername.. "hat dich zum Member gemacht!", otherplayer) outputChatBox("Du hast" ..otherplayername "zum Member gemacht!",player) elseif level == "Moderator" then aclGroupRemoveObject ( thegroup, "serial." ..serial ) setElementData(otherplayer, "pptts.acl", "Moderator") aclGroupAddObject( aclGetGroup("Moderator"), "serial."..otherplayername) outputChatBox(playername.. "hat dich zum Moderator gemacht!", otherplayer) outputChatBox("Du hast" ..otherplayername "zum Moderator gemacht!",player) elseif level == "Admin" then aclGroupRemoveObject ( thegroup, "serial." ..serial ) setElementData(otherplayer, "pptts.acl", "Admin") aclGroupAddObject( aclGetGroup("Admin"), "serial."..otherplayername) outputChatBox(playername.. "hat dich zum Admin gemacht!", otherplayer) outputChatBox("Du hast" ..otherplayername "zum Admin gemacht!",player) elseif level == "VIP" then aclGroupRemoveObject ( thegroup, "serial." ..serial ) setElementData(otherplayer, "pptts.acl", "VIP") aclGroupAddObject( aclGetGroup("VIP"), "serial."..otherplayername) outputChatBox(playername.. "hat dich zum VIP gemacht!", otherplayer) outputChatBox("Du hast" ..otherplayername "zum VIP gemacht!",player) else outputChatBox("NUTZUNG: /makeadmin [spieler] [Nichts/Member/Moderator/Admin/VIP]", player) end else outputChatBox("NUTZUNG: /makeadmin [spieler] [Nichts/Member/Moderator/Admin/VIP]", player) end end end addCommandHandler("makeadmin", adminCMD) Edited January 23, 2012 by Guest Link to comment
Kenix Posted January 23, 2012 Share Posted January 23, 2012 Try function findPlayer( name ) if type( name ) == 'string' then local matches = { } for _, v in pairs( getElementsByType( "player" ) ) do if getPlayerName( v ) == name then return v end local playerName = getPlayerName( v ):gsub( "#%x%x%x%x%x%x", "" ) playerName = playerName:lower( ) if playerName:find( name:lower( ), 0 ) then table.insert( matches, v ) end end if #matches == 1 then return matches[1] end return false end end function adminCMD( player, _,otherplayer, level ) if getElementData( player, "pptts.canusemakeadmin" ) then -- the shared logic local otherplayer = findPlayer( otherplayer ) if isElement( otherplayer ) then local serial = getPlayerSerial( otherplayer ) local thegroup = aclGetGroup( getElementData( otherplayer, "pptts.acl" ) ) local otherplayername = getPlayerName( otherplayer ) local playername = getPlayerName( player ) if level == "Nichts" then aclGroupRemoveObject ( thegroup, "serial." ..serial ) outputChatBox( playername.. "hat dir deine Rechte entzogen!", otherplayer ) outputChatBox( "Du hast" ..otherplayername "die Rechte entzogen!",player ) elseif level == "Member" then aclGroupRemoveObject ( thegroup, "serial." ..serial ) setElementData( otherplayer, "pptts.acl", "Member") aclGroupAddObject( aclGetGroup("Member"), "serial."..otherplayername ) outputChatBox( playername.. "hat dich zum Member gemacht!", otherplayer ) outputChatBox( "Du hast" ..otherplayername "zum Member gemacht!",player ) elseif level == "Moderator" then aclGroupRemoveObject ( thegroup, "serial." ..serial ) setElementData( otherplayer, "pptts.acl", "Moderator") aclGroupAddObject( aclGetGroup("Moderator"), "serial."..otherplayername ) outputChatBox( playername.. "hat dich zum Moderator gemacht!", otherplayer ) outputChatBox( "Du hast" ..otherplayername "zum Moderator gemacht!",player ) elseif level == "Admin" then aclGroupRemoveObject ( thegroup, "serial." ..serial ) setElementData(otherplayer, "pptts.acl", "Admin") aclGroupAddObject( aclGetGroup("Admin"), "serial."..otherplayername ) outputChatBox( playername.. "hat dich zum Admin gemacht!", otherplayer ) outputChatBox( "Du hast" ..otherplayername "zum Admin gemacht!",player ) elseif level == "VIP" then aclGroupRemoveObject ( thegroup, "serial." ..serial ) setElementData( otherplayer, "pptts.acl", "VIP" ) aclGroupAddObject( aclGetGroup("VIP"), "serial."..otherplayername ) outputChatBox( playername.. "hat dich zum VIP gemacht!", otherplayer ) outputChatBox( "Du hast" ..otherplayername "zum VIP gemacht!",player ) else outputChatBox( "NUTZUNG: /makeadmin [spieler] [Nichts/Member/Moderator/Admin/VIP]", player ) end else outputChatBox( "NUTZUNG: /makeadmin [spieler] [Nichts/Member/Moderator/Admin/VIP]", player ) end end end addCommandHandler( "makeadmin", adminCMD ) And lock in /debugscript 3. Try again i update. Link to comment
Deadmau5 Posted January 23, 2012 Author Share Posted January 23, 2012 Ty for this, ill try //EDIT: Nothing happens... //EDIT2: adding serial.SERIAL to any acl group doesnt work *_* Link to comment
Deadmau5 Posted January 23, 2012 Author Share Posted January 23, 2012 I dont have serial in the dumb acl I try to add an object to the group admin, (serial.MYSERIAL), but it wont work Link to comment
Kenix Posted January 23, 2012 Share Posted January 23, 2012 (edited) You need add ACL rights to resource. And in arguments function https://wiki.multitheftauto.com/wiki/AclGroupAddObject serial can't use you need use resource or user ( see on wiki ). Edited January 23, 2012 by Guest Link to comment
Deadmau5 Posted January 23, 2012 Author Share Posted January 23, 2012 You mean resource.SERIAL? or user.SERIAL? //EDIT: So i need to make an extra mysql table for example where the serials are saved? //EDIT2: Why the f*ck i don't use user.SERIAL ? Thnx at all //EDIT3: Any way to script-connect an user to his account? Like LoginPlayer(player thePlayer, account theAccount)? //EDIT4: Sry for the much edits, but now i have a big problem... It shows me anytime the USAGE text function adminCMD( player, otherplayer, level ) if getElementData( player, "pptts.canusemakeadmin" ) then -- the shared logic local otherplayer = findPlayer( otherplayer ) if otherplayer then local serial = getPlayerSerial( otherplayer ) local thegroup = aclGetGroup( getElementData( otherplayer, "pptts.acl" ) ) --local otherplayername = getPlayerName( otherplayer ) local playername = getPlayerName( player ) if level == "Nichts" then aclGroupRemoveObject ( thegroup, "user." ..serial ) removeAccount( serial ) outputChatBox( playername.. "hat dir deine Rechte entzogen!", otherplayer ) outputChatBox( "Du hast" ..otherplayername "die Rechte entzogen!",player ) elseif level == "Member" then aclGroupRemoveObject ( thegroup, "user." ..serial ) removeAccount( serial ) addAccount( serial, "l0l7h15p455w0rd15uncr4ck4bl3" ) setElementData( otherplayer, "pptts.acl", "Member") aclGroupAddObject( aclGetGroup("Member"), "user."..otherplayername ) outputChatBox( playername.. "hat dich zum Member gemacht!", otherplayer ) outputChatBox( "Du hast" ..otherplayername "zum Member gemacht!",player ) elseif level == "Moderator" then aclGroupRemoveObject ( thegroup, "user." ..serial ) removeAccount( serial ) addAccount( serial, "l0l7h15p455w0rd15uncr4ck4bl3" ) setElementData( otherplayer, "pptts.acl", "Moderator") aclGroupAddObject( aclGetGroup("Moderator"), "user."..otherplayername ) outputChatBox( playername.. "hat dich zum Moderator gemacht!", otherplayer ) outputChatBox( "Du hast" ..otherplayername "zum Moderator gemacht!",player ) elseif level == "Admin" then aclGroupRemoveObject ( thegroup, "user." ..serial ) removeAccount( serial ) addAccount( serial, "l0l7h15p455w0rd15uncr4ck4bl3" ) setElementData(otherplayer, "pptts.acl", "Admin") aclGroupAddObject( aclGetGroup("Admin"), "user."..otherplayername ) outputChatBox( playername.. "hat dich zum Admin gemacht!", otherplayer ) outputChatBox( "Du hast" ..otherplayername "zum Admin gemacht!",player ) elseif level == "VIP" then aclGroupRemoveObject ( thegroup, "user." ..serial ) removeAccount( serial ) addAccount( serial, "l0l7h15p455w0rd15uncr4ck4bl3" ) setElementData( otherplayer, "pptts.acl", "VIP" ) aclGroupAddObject( aclGetGroup("VIP"), "user."..otherplayername ) outputChatBox( playername.. "hat dich zum VIP gemacht!", otherplayer ) outputChatBox( "Du hast" ..otherplayername "zum VIP gemacht!",player ) else outputChatBox( "NUTZUNG: /makeadmin [spieler] [Nichts/Member/Moderator/Admin/VIP]", player ) end else outputChatBox( "NUTZUNG: /makeadmin [spieler] [Nichts/Member/Moderator/Admin/VIP]", player ) end end end addCommandHandler( "makeadmin", adminCMD ) Link to comment
Castillo Posted January 23, 2012 Share Posted January 23, 2012 The second argument of addCommandHandler server-side it's the commandName. function adminCMD( player, commandName, otherplayer, level ) if getElementData( player, "pptts.canusemakeadmin" ) then -- the shared logic local otherplayer = findPlayer( otherplayer ) if otherplayer then local serial = getPlayerSerial( otherplayer ) local thegroup = aclGetGroup( getElementData( otherplayer, "pptts.acl" ) ) --local otherplayername = getPlayerName( otherplayer ) local playername = getPlayerName( player ) if level == "Nichts" then aclGroupRemoveObject ( thegroup, "user." ..serial ) removeAccount( serial ) outputChatBox( playername.. "hat dir deine Rechte entzogen!", otherplayer ) outputChatBox( "Du hast" ..otherplayername "die Rechte entzogen!",player ) elseif level == "Member" then aclGroupRemoveObject ( thegroup, "user." ..serial ) removeAccount( serial ) addAccount( serial, "l0l7h15p455w0rd15uncr4ck4bl3" ) setElementData( otherplayer, "pptts.acl", "Member") aclGroupAddObject( aclGetGroup("Member"), "user."..otherplayername ) outputChatBox( playername.. "hat dich zum Member gemacht!", otherplayer ) outputChatBox( "Du hast" ..otherplayername "zum Member gemacht!",player ) elseif level == "Moderator" then aclGroupRemoveObject ( thegroup, "user." ..serial ) removeAccount( serial ) addAccount( serial, "l0l7h15p455w0rd15uncr4ck4bl3" ) setElementData( otherplayer, "pptts.acl", "Moderator") aclGroupAddObject( aclGetGroup("Moderator"), "user."..otherplayername ) outputChatBox( playername.. "hat dich zum Moderator gemacht!", otherplayer ) outputChatBox( "Du hast" ..otherplayername "zum Moderator gemacht!",player ) elseif level == "Admin" then aclGroupRemoveObject ( thegroup, "user." ..serial ) removeAccount( serial ) addAccount( serial, "l0l7h15p455w0rd15uncr4ck4bl3" ) setElementData(otherplayer, "pptts.acl", "Admin") aclGroupAddObject( aclGetGroup("Admin"), "user."..otherplayername ) outputChatBox( playername.. "hat dich zum Admin gemacht!", otherplayer ) outputChatBox( "Du hast" ..otherplayername "zum Admin gemacht!",player ) elseif level == "VIP" then aclGroupRemoveObject ( thegroup, "user." ..serial ) removeAccount( serial ) addAccount( serial, "l0l7h15p455w0rd15uncr4ck4bl3" ) setElementData( otherplayer, "pptts.acl", "VIP" ) aclGroupAddObject( aclGetGroup("VIP"), "user."..otherplayername ) outputChatBox( playername.. "hat dich zum VIP gemacht!", otherplayer ) outputChatBox( "Du hast" ..otherplayername "zum VIP gemacht!",player ) else outputChatBox( "NUTZUNG: /makeadmin [spieler] [Nichts/Member/Moderator/Admin/VIP]", player ) end else outputChatBox( "NUTZUNG: /makeadmin [spieler] [Nichts/Member/Moderator/Admin/VIP]", player ) end end end addCommandHandler( "makeadmin", adminCMD ) 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