Jump to content

Admin name


Zsoltisz

Recommended Posts

Hello guys! I have this script. So, when i go in adminduty my name is changed to my account name. That's good.

BUT. When i go out in adminduty my name is not changed to my character name. Please help for me!

//Sorry for bad english.

function adminDuty(thePlayer, commandName) 
    if exports.global:isPlayerAdmin(thePlayer) then 
        local id = getElementData(thePlayer, "playerid") 
        local adminduty = getElementData(thePlayer, "adminduty") 
        local username = getPlayerName(thePlayer) 
        local adminnev = getElementData(thePlayer, "gameaccountusername") 
        local karinev =  mysql:query("SELECT charactername FROM characters WHERE charactername=") 
         
        if (adminduty==0) then 
            exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "adminduty", 1, false) 
            setPlayerName (thePlayer, adminnev) 
            outputChatBox("#66FF66[starMTA]#32C8FF " .. adminnev .. " #FFFFFFadminszolgálatba #66FF66lépett! #FFFFFFHasználd a #32C8FF/pm " .. id .." #FFFFFFparancsot, hogy írj neki!",getRootElement(),  255, 255, 255, true) 
        elseif (adminduty==1) then 
            local adminlevel = getElementData(thePlayer, "adminlevel") 
            if (adminlevel == 2) then 
                outputChatBox("#66FF66[starMTA-Admin]#FFFFFF1-es Admin nem léphet ki szolgálatból.", thePlayer, 255, 0, 0, true) 
                return 
            end 
            exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "adminduty", 0, false) 
            setPlayerName (thePlayer, karinev) 
            outputChatBox("#66FF66[starMTA]#32C8FF " .. adminnev .. " #FF6666kilépett #FFFFFFaz adminszolgálatból!", getRootElement(), 255, 0, 0, true) 
        end 
        mysql:query_free("UPDATE accounts SET adminduty=" .. mysql:escape_string(getElementData(thePlayer, "adminduty")) .. " WHERE id = '" .. mysql:escape_string(getElementData(thePlayer, "gameaccountid")).."'" ) 
        exports.global:updateNametagColor(thePlayer) 
    end 
end 
addCommandHandler("adminduty", adminDuty, false, false) 

Link to comment
function adminDuty(thePlayer, commandName) 
    if exports.global:isPlayerAdmin(thePlayer) then 
        local id = getElementData(thePlayer, "playerid") 
        local adminduty = getElementData(thePlayer, "adminduty") 
        local username = getPlayerName(thePlayer) 
        local adminnev = getElementData(thePlayer, "gameaccountusername") 
        local karinev =  mysql:query("SELECT * FROM characters WHERE charactername=?") 
        
        if (adminduty==0) then 
            exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "adminduty", 1, false) 
            setPlayerName (thePlayer, adminnev) 
            outputChatBox("#66FF66[starMTA]#32C8FF " .. adminnev .. " #FFFFFFadminszolgálatba #66FF66lépett! #FFFFFFHasználd a #32C8FF/pm " .. id .." #FFFFFFparancsot, hogy írj neki!",getRootElement(),  255, 255, 255, true) 
        elseif (adminduty==1) then 
            local adminlevel = getElementData(thePlayer, "adminlevel") 
            if (adminlevel == 2) then 
                outputChatBox("#66FF66[starMTA-Admin]#FFFFFF1-es Admin nem léphet ki szolgálatból.", thePlayer, 255, 0, 0, true) 
                return 
            end 
            exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "adminduty", 0, false) 
            setPlayerName (thePlayer, karinev) 
            outputChatBox("#66FF66[starMTA]#32C8FF " .. adminnev .. " #FF6666kilépett #FFFFFFaz adminszolgálatból!", getRootElement(), 255, 0, 0, true) 
        end 
        mysql:query_free("UPDATE accounts SET adminduty=" .. mysql:escape_string(getElementData(thePlayer, "adminduty")) .. " WHERE id = '" .. mysql:escape_string(getElementData(thePlayer, "gameaccountid")).."'" ) 
        exports.global:updateNametagColor(thePlayer) 
    end 
end 
addCommandHandler("adminduty", adminDuty, false, false) 

Link to comment

Dont working :?

[2016-03-10 13:37:24] INFO: MYSQL ERROR 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1 
[2016-03-10 13:37:24] WARNING: admin-system/Player/s_player_commands.lua:793: Bad argument @ 'setPlayerName' [Expected string at argument 2, got boolean] 

Link to comment
function adminDuty(thePlayer, commandName) 
    if exports.global:isPlayerAdmin(thePlayer) then 
        local id = getElementData(thePlayer, "playerid") 
        local adminduty = getElementData(thePlayer, "adminduty") 
        local username = getPlayerName(thePlayer) 
        local adminnev = getElementData(thePlayer, "gameaccountusername") 
        local karinev = getPlayerName(thePlayer) 
        
        if (adminduty==0) then 
            exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "adminduty", 1, false) 
            setPlayerName (thePlayer, adminnev) 
            outputChatBox("#66FF66[starMTA]#32C8FF " .. adminnev .. " #FFFFFFadminszolgálatba #66FF66lépett! #FFFFFFHasználd a #32C8FF/pm " .. id .." #FFFFFFparancsot, hogy írj neki!",getRootElement(),  255, 255, 255, true) 
        elseif (adminduty==1) then 
            local adminlevel = getElementData(thePlayer, "adminlevel") 
            if (adminlevel == 2) then 
                outputChatBox("#66FF66[starMTA-Admin]#FFFFFF1-es Admin nem léphet ki szolgálatból.", thePlayer, 255, 0, 0, true) 
                return 
            end 
            exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "adminduty", 0, false) 
            setPlayerName (thePlayer, karinev) 
            outputChatBox("#66FF66[starMTA]#32C8FF " .. adminnev .. " #FF6666kilépett #FFFFFFaz adminszolgálatból!", getRootElement(), 255, 0, 0, true) 
        end 
        mysql:query_free("UPDATE accounts SET adminduty=" .. mysql:escape_string(getElementData(thePlayer, "adminduty")) .. " WHERE id = '" .. mysql:escape_string(getElementData(thePlayer, "gameaccountid")).."'" ) 
        exports.global:updateNametagColor(thePlayer) 
    end 
end 
addCommandHandler("adminduty", adminDuty, false, false) 

Link to comment
function adminDuty(thePlayer, commandName) 
    if exports.global:isPlayerAdmin(thePlayer) then 
        local id = getElementData(thePlayer, "playerid") 
        local adminduty = getElementData(thePlayer, "adminduty") 
        local username = getPlayerName(thePlayer) 
        local adminnev = getElementData(thePlayer, "gameaccountusername") 
        local karinev =  mysql:query("SELECT * FROM characters WHERE charactername=") 
        
        if (adminduty==0) then 
            exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "adminduty", 1, false) 
            setPlayerName (thePlayer, adminnev) 
            outputChatBox("#66FF66[starMTA]#32C8FF " .. adminnev .. " #FFFFFFadminszolgálatba #66FF66lépett! #FFFFFFHasználd a #32C8FF/pm " .. id .." #FFFFFFparancsot, hogy írj neki!",getRootElement(),  255, 255, 255, true) 
        elseif (adminduty==1) then 
            local adminlevel = getElementData(thePlayer, "adminlevel") 
            if (adminlevel == 2) then 
                outputChatBox("#66FF66[starMTA-Admin]#FFFFFF1-es Admin nem léphet ki szolgálatból.", thePlayer, 255, 0, 0, true) 
                return 
            end 
            exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "adminduty", 0, false) 
            setPlayerName (thePlayer, karinev) 
            outputChatBox("#66FF66[starMTA]#32C8FF " .. adminnev .. " #FF6666kilépett #FFFFFFaz adminszolgálatból!", getRootElement(), 255, 0, 0, true) 
        end 
        mysql:query_free("UPDATE accounts SET adminduty=" .. mysql:escape_string(getElementData(thePlayer, "adminduty")) .. " WHERE id = '" .. mysql:escape_string(getElementData(thePlayer, "gameaccountid")).."'" ) 
        exports.global:updateNametagColor(thePlayer) 
    end 
end 
addCommandHandler("adminduty", adminDuty, false, false) 

Link to comment

Again error :/

    [2016-03-21 16:39:20] INFO: MYSQL ERROR 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near " at line 1 
    [2016-03-21 16:39:20] WARNING: admin-system/Player/s_player_commands.lua:793: Bad argument @ 'setPlayerName' [Expected string at argument 2, got boolean] 

Link to comment
function adminDuty(thePlayer, commandName) 
    if exports.global:isPlayerAdmin(thePlayer) then 
        local id = getElementData(thePlayer, "playerid") 
        local adminduty = getElementData(thePlayer, "adminduty") 
        local username = getPlayerName(thePlayer) 
        local adminnev = getElementData(thePlayer, "gameaccountusername") 
        local karinev =  mysql:query("SELECT * FROM characters WHERE charactername=?") 
        
        if (adminduty==0) then 
            exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "adminduty", 1, false) 
            setPlayerName (thePlayer, adminnev) 
            outputChatBox("#66FF66[starMTA]#32C8FF " .. adminnev .. " #FFFFFFadminszolgálatba #66FF66lépett! #FFFFFFHasználd a #32C8FF/pm " .. id .." #FFFFFFparancsot, hogy írj neki!",getRootElement(),  255, 255, 255, true) 
        elseif (adminduty==1) then 
            local adminlevel = getElementData(thePlayer, "adminlevel") 
            if (adminlevel == 2) then 
                outputChatBox("#66FF66[starMTA-Admin]#FFFFFF1-es Admin nem léphet ki szolgálatból.", thePlayer, 255, 0, 0, true) 
                return 
            end 
            exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "adminduty", 0, false) 
            setPlayerName (thePlayer, karinev) 
            outputChatBox("#66FF66[starMTA]#32C8FF " .. adminnev .. " #FF6666kilépett #FFFFFFaz adminszolgálatból!", getRootElement(), 255, 0, 0, true) 
        end 
        mysql:query_free("UPDATE accounts SET adminduty=" .. mysql:escape_string(getElementData(thePlayer, "adminduty")) .. " WHERE id = '" .. mysql:escape_string(getElementData(thePlayer, "gameaccountid")).."'" ) 
        exports.global:updateNametagColor(thePlayer) 
    end 
end 
addCommandHandler("adminduty", adminDuty, false, false) 

Link to comment
function adminDuty(thePlayer, commandName) 
    if exports.global:isPlayerAdmin(thePlayer) then 
        local id = getElementData(thePlayer, "playerid") 
        local adminduty = getElementData(thePlayer, "adminduty") 
        local username = getPlayerName(thePlayer) 
        local adminnev = getElementData(thePlayer, "gameaccountusername") 
        local karinev =  mysql:query("SELECT * FROM characters WHERE charactername=?", charactername) 
        
        if (adminduty==0) then 
            exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "adminduty", 1, false) 
            setPlayerName (thePlayer, adminnev) 
            outputChatBox("#66FF66[starMTA]#32C8FF " .. adminnev .. " #FFFFFFadminszolgálatba #66FF66lépett! #FFFFFFHasználd a #32C8FF/pm " .. id .." #FFFFFFparancsot, hogy írj neki!",getRootElement(),  255, 255, 255, true) 
        elseif (adminduty==1) then 
            local adminlevel = getElementData(thePlayer, "adminlevel") 
            if (adminlevel == 2) then 
                outputChatBox("#66FF66[starMTA-Admin]#FFFFFF1-es Admin nem léphet ki szolgálatból.", thePlayer, 255, 0, 0, true) 
                return 
            end 
            exports['anticheat-system']:changeProtectedElementDataEx(thePlayer, "adminduty", 0, false) 
            setPlayerName (thePlayer, karinev) 
            outputChatBox("#66FF66[starMTA]#32C8FF " .. adminnev .. " #FF6666kilépett #FFFFFFaz adminszolgálatból!", getRootElement(), 255, 0, 0, true) 
        end 
        mysql:query_free("UPDATE accounts SET adminduty=" .. mysql:escape_string(getElementData(thePlayer, "adminduty")) .. " WHERE id = '" .. mysql:escape_string(getElementData(thePlayer, "gameaccountid")).."'" ) 
        exports.global:updateNametagColor(thePlayer) 
    end 
end 
addCommandHandler("adminduty", adminDuty, false, false) 

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