Jump to content

SuperNick Help..#1


justn

Recommended Posts

Hi there, I'm working on a supernick script... and I have a problem with it.. so the problem is.. when i leave the server.. with my supernick.. and i join and login again.. it doesn't set my supernick again.. code:

CODE REMOVED SO PLAYERS CANNOT STEAL

Edited by Guest
Link to comment

Try this:

local setPlayerNewName = setPlayerName 
  
function getPlayerSuperNick( player ) 
        local account = getPlayerAccount( player ) 
        if ( account ) and ( not isGuestAccount( account ) ) then 
            local accountSuperNick = getAccountData(account,"supernick") 
            if ( accountSuperNick ) then 
                local supernick = getElementData(player,"supernick") 
                if ( supernick ) then 
                    setPlayerNewName(player,supernick) 
                    outputChatBox(supercolor.."[supernick]: #FFFFFFYour "..supercolor.."supernick #FFFFFFhas been set to "..supercolor..getElementData(player,"supernick"),player,255,255,255,true) 
                end 
            end 
        end 
end 
  
addEventHandler("onPlayerLogin",getRootElement(),function() 
    getPlayerSuperNick ( source ) 
end ) 
      
    function savePlayerSuperNick( player ) 
        if ( player == source ) then 
            local account = getPlayerAccount( player ) 
            if ( account ) and ( not isGuestAccount( account ) ) then 
                local supernick = getElementData(player,"supernick") 
                    if ( supernick ) then 
                        setAccountData(account,"supernick",supernick) 
                    end 
            end 
        end 
    end 
    addEventHandler("onPlayerQuit",getRootElement(),savePlayerSuperNick) 

Link to comment
addEventHandler('onPlayerLogin',resourceRoot, 
function ( player ) 
       local account = getPlayerAccount (player ) 
       if ( account ) and ( not isGuestAccount ( account )) then 
       local SuperNick = getAccountData ( account, 'supernick' ) 
           if ( SuperNick ) then 
           setPlayerName ( player, SuperNick ) 
           outputChatBox(supercolor.."[supernick]: #FFFFFFYour "..supercolor.."supernick #FFFFFFhas been set to "..supercolor.."", player, 255, 255, 255, true ) 
            end 
          end 
       end 
   ) 
    
   addEventHandler('onPlayerQuit',resourceRoot, 
       function ( player ) 
       local account = getPlayerAccount (player ) 
        if ( account ) and ( not isGuestAccount ( account )) then 
        setAccountData ( account, 'supernick' ) 
      end 
   end 
 ) 

Edited by Guest
Link to comment
I know it's server-sided, there's only a server-side in the entire script and there's No errors and it still doesn't work.. should I just set the account data when the player sets his SuperNick ?

Yeah , i dont think you need to use accountData / elementdata both Select Only One of them ,

And i have Edited My Post , Copy it again .

Link to comment

Try this.

addEventHandler('onPlayerLogin',resourceRoot, function (_,account) 
    local playerAccount = getPlayerAccount( source ) 
    local isAccount = ( playerAccount and not isGuestAccount( playerAccount ) ) and true or false 
    if ( isAccount ) then 
        local SuperNick = getAccountData ( account, 'supernick' ) 
        if ( SuperNick ) then 
            setPlayerName ( player, SuperNick ) 
            outputChatBox(supercolor.."[supernick]: #FFFFFFYour "..supercolor.."supernick #FFFFFFhas been set to "..supercolor..SuperNick, player, 255, 255, 255, true ) 
        end 
    end 
end) 

Link to comment
outputChatBox(supercolor.."[supernick]: #FFFFFFYour "..supercolor.."supernick #FFFFFFhas been set to "..supercolor..SuperNick, player, 255, 255, 255, true ) 

To:

outputChatBox(supercolor.."[supernick]: #FFFFFFYour "..supercolor.."supernick #FFFFFFhas been set to "..supercolor..""..SuperNick, player, 255, 255, 255, true ) 

Link to comment
local setPlayerNewName = setPlayerName 
  
function getPlayerSuperNick( ) 
        local player = source 
        local account = getPlayerAccount( player ) 
        if ( account ) and ( not isGuestAccount( account ) ) then 
            local accountSuperNick = getAccountData(account,"supernick") 
            if ( accountSuperNick ) then 
                local supernick = getElementData(player,"supernick") 
                if ( supernick ) then 
                    setPlayerNewName(player,supernick) 
                    outputChatBox(supercolor.."[supernick]: #FFFFFFYour "..supercolor.."supernick #FFFFFFhas been set to "..supercolor..getElementData(player,"supernick"),player,255,255,255,true) 
                end 
            end 
        end 
end 
addEventHandler("onPlayerLogin",getRootElement(),getPlayerSuperNick) 
  
function savePlayerSuperNick( ) 
        local player = source 
        local account = getPlayerAccount( player ) 
        if ( account ) and ( not isGuestAccount( account ) ) then 
            local supernick = getElementData(player,"supernick") 
                if ( supernick ) then 
                    setAccountData(account,"supernick",supernick) 
                end 
       end 
end 
addEventHandler("onPlayerQuit",getRootElement(),savePlayerSuperNick) 

The first variable that onPlayerLogin returns is the previous account so obviously it will never be the player and onPlayerQuit doesnt return variables.

Link to comment

Too late Sasu I fixed the problem, but ty all. now I need help with 1 more thing.. i tried setting my supernick to this and my name did not change.. is there anyway, i can make those heart faces and stuff appear when i set my super-nick?

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