Jump to content

Pickpocketing


Wei

Recommended Posts

Whats the problem ?

addCommandHandler( "steal",  
    function( thePlayer, commandName, otherPlayer, amount ) 
        local amount = math.random(1,500) 
        local chance = math.random(1,3) 
        if otherPlayer and amount and math.ceil( amount ) == amount and amount > 0 then          
        if getElementModel(thePlayer) == 29 then 
        local other = getPlayerFromNick( otherPlayer ) 
            if other then 
                if player ~= other then 
            local x, y, z = getElementPosition( thePlayer ) 
            local x2, y2, z2 = getElementPosition( other ) 
            if(getDistanceBetweenPoints3D( x, y, z, x2, y2, z2 ) < 5) then 
            if(chance == 3) then 
            takePlayerMoney( other, amount ) 
            givePlayerMoney( thePlayer, amount ) 
            outputChatBox( "" .. getPlayerName ( thePlayer ) .. " stole $" .. amount .. " from you.", other, 255, 0, 0 ) 
                        outputChatBox( "You stole $" .. amount .. " from " .. name .. ". ", thePlayer, 0, 255, 0 ) 
            else outputChatBox( "" .. name .. " escaped.", thePlayer, 255, 0, 0 ) 
            end 
            else outputChatBox( "" .. name .. " noticed that you tried to steal money.", thePlayer, 255, 0, 0 ) 
            outputChatBox( "" .. getPlayerName ( thePlayer ) .. " tried to steal money from you, but failed.", other, 255, 0, 0 ) 
        end 
        else outputChatBox( "" .. name .. " is too far away.", thePlayer, 255, 0, 0 ) 
        end 
    end 
end 
end 
end 
) 

error:

attempt to call global 'addCommandHandler' (a nil value)

Link to comment
same error

/debugscript 3 ?

no errors

Script now:

addCommandHandler( "steal",  
    function( thePlayer, commandName, otherPlayer, amount ) 
        local amount = math.random(1,500) 
        local chance = math.random(1,3) 
        if otherPlayer and amount and math.ceil( amount ) == amount and amount > 0 then          
        if getElementModel(thePlayer) == 29 then 
        local other = getPlayerFromNick( otherPlayer ) 
            if other then 
            local x, y, z = getElementPosition( thePlayer ) 
            local x2, y2, z2 = getElementPosition( other ) 
            if(getDistanceBetweenPoints3D( x, y, z, x2, y2, z2 ) < 5) then 
            if(chance == 3) then 
            takePlayerMoney( other, amount ) 
            givePlayerMoney( thePlayer, amount ) 
            outputChatBox( "" .. getPlayerName ( thePlayer ) .. " stole $" .. amount .. " from you.", other, 255, 0, 0 ) 
                        outputChatBox( "You stole $" .. amount .. " from " .. name .. ". ", thePlayer, 0, 255, 0 ) 
            else outputChatBox( "" .. name .. " escaped.", thePlayer, 255, 0, 0 ) 
            end 
            else outputChatBox( "" .. name .. " noticed that you tried to steal money.", thePlayer, 255, 0, 0 ) 
            outputChatBox( "" .. getPlayerName ( thePlayer ) .. " tried to steal money from you, but failed.", other, 255, 0, 0 ) 
        end 
        else outputChatBox( "" .. name .. " is too far away.", thePlayer, 255, 0, 0 ) 
        end 
    end 
end 
end 
) 

Link to comment
Guest Guest4401

Try

addCommandHandler( "steal", 
    function( thePlayer, commandName, otherPlayer, amount ) 
        local amount = math.random(1,500) 
        local chance = math.random(1,3) 
        if otherPlayer and amount and math.ceil( amount ) == amount and amount > 0 then 
            if getElementModel(thePlayer) == 29 then 
                local other = getPlayerFromName( otherPlayer ) 
                local name = getPlayerName(other) 
                if other then 
                    local x, y, z = getElementPosition( thePlayer ) 
                    local x2, y2, z2 = getElementPosition( other ) 
                    if(getDistanceBetweenPoints3D( x, y, z, x2, y2, z2 ) < 5) then 
                        if(chance == 3) then 
                            takePlayerMoney( other, amount ) 
                            givePlayerMoney( thePlayer, amount ) 
                            outputChatBox( "" .. getPlayerName ( thePlayer ) .. " stole $" .. amount .. " from you.", other, 255, 0, 0 ) 
                            outputChatBox( "You stole $" .. amount .. " from " .. name .. ". ", thePlayer, 0, 255, 0 ) 
                        else  
                            outputChatBox( "" .. name .. " escaped.", thePlayer, 255, 0, 0 ) 
                        end 
                    else  
                        outputChatBox( "" .. name .. " noticed that you tried to steal money.", thePlayer, 255, 0, 0 ) 
                        outputChatBox( "" .. getPlayerName ( thePlayer ) .. " tried to steal money from you, but failed.", other, 255, 0, 0 ) 
                    end 
                else  
                    outputChatBox( "" .. name .. " is too far away.", thePlayer, 255, 0, 0 ) 
                end 
            end 
        end 
    end 
) 

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