Jump to content

I am getting this (Expected element at arguement 1 got nil) help me


Recommended Posts

-- 1352 , -1769 , 14
function storerob()
    --if x <= 1356 and x >= 1348 then
        --if y <= -1773 and y >= -1765 then
            --outputChatBox("you are here   ", player, 0, 0, 0)
            function announce()
            ---------------------------------------------------------------------------------------------
            outputChatBox("   ", root, 0, 0, 0)
            outputChatBox("-----------------------------------------------------", root, 255, 0, 0)
            outputChatBox("[ALERT] Someone has breaked the Locker in Store !!", root, 255, 0, 0)
            outputChatBox("-----------------------------------------------------", root, 255, 0, 0)
            outputChatBox("   ", root, 0, 0, 0)
            ---------------------------------------------------------------------------------------------
            end
            function loope()
                    outputChatBox("Robbing the money ...", player, 0, 255, 0)
            end
            ---------------------------------------------------------------------------------------------
            function money2()
                
                money = math.random(200000, 400000)
                givePlayerMoney( player, money )
                outputChatBox("   ", player, 0, 0, 0)
                outputChatBox("------------------------------------------------------", player, 0, 255, 0)
                outputChatBox("You got $"..money.." by robbing a Store !! ", player, 0, 255, 0)
                outputChatBox("------------------------------------------------------", player, 0, 255, 0)
                outputChatBox("   ", player, 0, 0, 0)              
                givePlayerMoney( player, money )
                
            end
            ---------------------------------------------------------------------------------------------
            announce()
            loope()
            money2()
            
            
        --else
            --outputChatBox("You are not Near the Locker !!", player, 255, 0, 0)
        --end
    --else
        --outputChatBox("You are not Near the Locker !!", player, 255, 0, 0)
    --end
    
end
addCommandHandler("robstore", storerob)

 

Link to comment

May I see the updated script?

Correct form:

function storerob(player commandName) -- define player in function!
	-- no need to create 50+ functions, everything can be done in the same function.
	local money = math.random(200000, 400000);
	outputChatBox("   ", root);
	outputChatBox("-----------------------------------------------------", root, 255, 0, 0);
	outputChatBox("[ALERT] Someone has breaked the Locker in Store !!", root, 255, 0, 0);
	outputChatBox("-----------------------------------------------------", root, 255, 0, 0);
	outputChatBox("   ", root);
	outputChatBox("Robbing the money ...", player, 0, 255, 0);
	outputChatBox("   ", player);
	outputChatBox("------------------------------------------------------", player, 0, 255, 0);
	outputChatBox("You got $"..money.." by robbing a Store !! ", player, 0, 255, 0);
	outputChatBox("------------------------------------------------------", player, 0, 255, 0);
	outputChatBox("   ", player);
	givePlayerMoney(player, money);
end

addCommandHandler("robstore", storerob);

 

Link to comment

I need to make it a 5 min delay with settimer and loop the "Robbing the Money"

here is the script which i modified

-- 1352 , -1769 , 14
function storerob()
    --if x <= 1356 and x >= 1348 then
        --if y <= -1773 and y >= -1765 then
            --outputChatBox("you are here   ", player, 0, 0, 0)
            ---------------------------------------------------------------------------------------------
            outputChatBox("   ", root, 000)
            outputChatBox("-----------------------------------------------------", root, 25500)
            outputChatBox("[ALERT] Someone has breaked the Locker in Store !!", root, 25500)
            outputChatBox("-----------------------------------------------------", root, 25500)
            outputChatBox("   ", root, 000)
            ---------------------------------------------------------------------------------------------
            
            function loope(player)
                
                    outputChatBox("Robbing the money ...", player, 02550)
                
            end
            
            setTimer(loope, 100029)
            
            ---------------------------------------------------------------------------------------------
            function money2(player)               
                money = math.random(200000400000)
                givePlayerMoney( player, money )
                outputChatBox("   ", player, 000)
                outputChatBox("------------------------------------------------------", player, 02550)
                outputChatBox("You got $"..money.." by robbing a Store !! ", player, 02550)
                outputChatBox("------------------------------------------------------", player, 02550)
                outputChatBox("   ", player, 000)              
                givePlayerMoney( player, money )
                
            end
            ---------------------------------------------------------------------------------------------
            
            setTimer( money2, 300001 )
            
        --else
            --outputChatBox("You are not Near the Locker !!", player, 255, 0, 0)
        --end
    --else
        --outputChatBox("You are not Near the Locker !!", player, 255, 0, 0)
    --end
    
end
addCommandHandler("robstore", storerob)
Link to comment

I need to make it a 5 min delay with settimer and loop the "Robbing the Money"

here is the script which i modified

-- 1352 , -1769 , 14
function storerob()
    --if x <= 1356 and x >= 1348 then
        --if y <= -1773 and y >= -1765 then
            --outputChatBox("you are here   ", player, 0, 0, 0)
            ---------------------------------------------------------------------------------------------
            outputChatBox("   ", root, 000)
            outputChatBox("-----------------------------------------------------", root, 25500)
            outputChatBox("[ALERT] Someone has breaked the Locker in Store !!", root, 25500)
            outputChatBox("-----------------------------------------------------", root, 25500)
            outputChatBox("   ", root, 000)
            ---------------------------------------------------------------------------------------------
            
            function loope(player)
                
                    outputChatBox("Robbing the money ...", player, 02550)
                
            end
            
            setTimer(loope, 100029)
            
            ---------------------------------------------------------------------------------------------
            function money2(player)               
                money = math.random(200000400000)
                givePlayerMoney( player, money )
                outputChatBox("   ", player, 000)
                outputChatBox("------------------------------------------------------", player, 02550)
                outputChatBox("You got $"..money.." by robbing a Store !! ", player, 02550)
                outputChatBox("------------------------------------------------------", player, 02550)
                outputChatBox("   ", player, 000)              
                givePlayerMoney( player, money )
                
            end
            ---------------------------------------------------------------------------------------------
            
            setTimer( money2, 300001 )
            
        --else
            --outputChatBox("You are not Near the Locker !!", player, 255, 0, 0)
        --end
    --else
        --outputChatBox("You are not Near the Locker !!", player, 255, 0, 0)
    --end
    
end
addCommandHandler("robstore", storerob)
Link to comment

Maybe you didn't take a close look on what @Tekken posted. You are missing the argument "player" in the function storerob().
Also to make those timers work you will need to pass them the player element as well - as an optional argument (check setTimer documentation).

It should be something like this:

-- 1352 , -1769 , 14
function storerob(player)
    --if x <= 1356 and x >= 1348 then
        --if y <= -1773 and y >= -1765 then
            --outputChatBox("you are here   ", player, 0, 0, 0)
            ---------------------------------------------------------------------------------------------
            outputChatBox("   ", root, 0, 0, 0)
            outputChatBox("-----------------------------------------------------", root, 255, 0, 0)
            outputChatBox("[ALERT] Someone has breaked the Locker in Store !!", root, 255, 0, 0)
            outputChatBox("-----------------------------------------------------", root, 255, 0, 0)
            outputChatBox("   ", root, 0, 0, 0)
            ---------------------------------------------------------------------------------------------
            
            function loope(player)
                    outputChatBox("Robbing the money ...", player, 0, 255, 0)
            end
            
            setTimer(loope, 1000, 29, player)
            
            ---------------------------------------------------------------------------------------------
            function money2(player)               
                money = math.random(200000, 400000)
                givePlayerMoney( player, money )
                outputChatBox("   ", player, 0, 0, 0)
                outputChatBox("------------------------------------------------------", player, 0, 255, 0)
                outputChatBox("You got $"..money.." by robbing a Store !! ", player, 0, 255, 0)
                outputChatBox("------------------------------------------------------", player, 0, 255, 0)
                outputChatBox("   ", player, 0, 0, 0)              
                givePlayerMoney( player, money )
            end
            ---------------------------------------------------------------------------------------------
            
            setTimer(money2, 30000, 1, player)
            
        --else
            --outputChatBox("You are not Near the Locker !!", player, 255, 0, 0)
        --end
    --else
        --outputChatBox("You are not Near the Locker !!", player, 255, 0, 0)
    --end
    
end
addCommandHandler("robstore", storerob)

*PS: Please, use the "code" tool in the text editor when you paste Lua code.
Js6eCDI.png

Edited by SpecT
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...