Jump to content

[HELP] wont work


Clydian

Recommended Posts

function setLevel(playerS,cmd,name,amount) 
    local player = getPlayerFromName(PlayerS) 
    local account = getPlayerAccount(playerS) 
    local accName = getAccountName(account) 
        if isObjectInACLGroup("user."..accName,aclGetGroup("Admin")) then 
        if getElementType(player) == "player" and tonumber(amount) then 
            setElementData(player,"Level",getElementData(player,"Level") + amount) 
            outputChatBox("Your level was increased by "..getPlayerName(playerS).." ("..amount.."%)",player,0,255,0) 
            outputChatBox(getPlayerName(player).."'s level was increased.",playerS,0,255,0) 
        else 
            outputChatBox("Failed to give because the player/amount was wrong.",playerS,255,255,0) 
        end 
    end 
end 
addCommandHandler("setLevel",setLevel,false,false) 

any ideas why it wont work?

DebugScript3 says" WARNING" DG_Levels/server.lua"70" Bad argument @ 'getPlayerFromName' [Expected string at argument 1, got nil]

Link to comment
function setLevel(playerS,cmd,name,amount) 
    local player = getPlayerFromName(PlayerS) 
    local account = getPlayerAccount(playerS) 
    local accName = getAccountName(account) 
        if isObjectInACLGroup("user."..accName,aclGetGroup("Admin")) then 
        if getElementType(player) == "player" and tonumber(amount) then 
            setElementData(player,"Level",getElementData(player,"Level") + amount) 
            outputChatBox("Your level was increased by "..getPlayerName(playerS).." ("..amount.."%)",player,0,255,0) 
            outputChatBox(getPlayerName(player).."'s level was increased.",playerS,0,255,0) 
        else 
            outputChatBox("Failed to give because the player/amount was wrong.",playerS,255,255,0) 
        end 
    end 
end 
addCommandHandler("setLevel",setLevel,false,false) 

any ideas why it wont work?

DebugScript3 says" WARNING" DG_Levels/server.lua"70" Bad argument @ 'getPlayerFromName' [Expected string at argument 1, got nil]

Because of the small and capital letters

function setLevel(playerS,cmd,name,amount)

    local player = getPlayerFromName(PlayerS)

Link to comment
function setLevel(playerS,cmd,name,amount) 
    local player = getPlayerFromName(PlayerS) 
    local account = getPlayerAccount(playerS) 
    local accName = getAccountName(account) 
        if isObjectInACLGroup("user."..accName,aclGetGroup("Admin")) then 
        if getElementType(player) == "player" and tonumber(amount) then 
            setElementData(player,"Level",getElementData(player,"Level") + amount) 
            outputChatBox("Your level was increased by "..getPlayerName(playerS).." ("..amount.."%)",player,0,255,0) 
            outputChatBox(getPlayerName(player).."'s level was increased.",playerS,0,255,0) 
        else 
            outputChatBox("Failed to give because the player/amount was wrong.",playerS,255,255,0) 
        end 
    end 
end 
addCommandHandler("setLevel",setLevel,false,false) 

any ideas why it wont work?

DebugScript3 says" WARNING" DG_Levels/server.lua"70" Bad argument @ 'getPlayerFromName' [Expected string at argument 1, got nil]

Because of the small and capital letters

function setLevel(playerS,cmd,name,amount)

    local player = getPlayerFromName(PlayerS)

Didnt fix it

Link to comment

This should work, you messed everything.

function setLevel(thePlayer,cmd,toPlayer,amount) 
    local toPlayer = getPlayerFromName(toPlayer) 
    local account = getPlayerAccount(thePlayer) 
    local accName = getAccountName(account) 
    if isObjectInACLGroup("user."..accName,aclGetGroup("Admin")) then 
        if getElementType(toPlayer) == "player" and tonumber(amount) then 
            setElementData(toPlayer,"Level",getElementData(toPlayer,"Level") + amount) 
            outputChatBox("Your level was increased by "..getPlayerName(thePlayer).." ("..amount.."%)",toPlayer,0,255,0) 
            outputChatBox(getPlayerName(thePlayer).."'s level was increased.",thePlayer,0,255,0) 
        else 
            outputChatBox("Failed to give because the player/amount was wrong.",thePlayer,255,255,0) 
        end 
    end 
end 
addCommandHandler("setLevel",setLevel,false,false) 

Also to set a level to the player you need to use his full nick (including color code if there is).

So you should use getPlayerFromPartialName and replace getPlayerFromName[/with] with [wiki]getPlayerFromPartialName.

Link to comment
This should work, you messed everything.
function setLevel(thePlayer,cmd,toPlayer,amount) 
    local toPlayer = getPlayerFromName(toPlayer) 
    local account = getPlayerAccount(thePlayer) 
    local accName = getAccountName(account) 
    if isObjectInACLGroup("user."..accName,aclGetGroup("Admin")) then 
        if getElementType(toPlayer) == "player" and tonumber(amount) then 
            setElementData(toPlayer,"Level",getElementData(toPlayer,"Level") + amount) 
            outputChatBox("Your level was increased by "..getPlayerName(thePlayer).." ("..amount.."%)",toPlayer,0,255,0) 
            outputChatBox(getPlayerName(thePlayer).."'s level was increased.",thePlayer,0,255,0) 
        else 
            outputChatBox("Failed to give because the player/amount was wrong.",thePlayer,255,255,0) 
        end 
    end 
end 
addCommandHandler("setLevel",setLevel,false,false) 

Also to set a level to the player you need to use his full nick (including color code if there is).

So you should use getPlayerFromPartialName and replace getPlayerFromName[/with] with [wiki]getPlayerFromPartialName.

Thank you very much, and i will try to change it, see how it works :)

Link to comment
This should work, you messed everything.
function setLevel(thePlayer,cmd,toPlayer,amount) 
    local toPlayer = getPlayerFromName(toPlayer) 
    local account = getPlayerAccount(thePlayer) 
    local accName = getAccountName(account) 
    if isObjectInACLGroup("user."..accName,aclGetGroup("Admin")) then 
        if getElementType(toPlayer) == "player" and tonumber(amount) then 
            setElementData(toPlayer,"Level",getElementData(toPlayer,"Level") + amount) 
            outputChatBox("Your level was increased by "..getPlayerName(thePlayer).." ("..amount.."%)",toPlayer,0,255,0) 
            outputChatBox(getPlayerName(thePlayer).."'s level was increased.",thePlayer,0,255,0) 
        else 
            outputChatBox("Failed to give because the player/amount was wrong.",thePlayer,255,255,0) 
        end 
    end 
end 
addCommandHandler("setLevel",setLevel,false,false) 

Also to set a level to the player you need to use his full nick (including color code if there is).

So you should use getPlayerFromPartialName and replace getPlayerFromName[/with] with [wiki]getPlayerFromPartialName.

acually just tested it and still wont work

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