Jump to content

Hoursplayed problem


Unique

Recommended Posts

Code: 

Spoiler

   local hoursplayed = getElementData(localPlayer, "hoursplayed")
            
            if (jobtext=="RS Haul Delivery") then
                   elseif (getElementData(localPlayer, "hoursplayed") or 0) < 50 then
                         outputChatBox("You must play at least 50 hours to work as a RS haul delivery driver", 255, 0,0)
                   return true
            end

 

Somebody?! did you see where is the problem? i don't get it.. i can take the job if i got < 50 hours

Link to comment

Have you tried rudimentaly debugging steps? Have you checked /debugscript 3? Have you checked whether hoursplayed has a value and if it's numeric? You can check that with runcode (that is, make sure the runcode resource is running when attempting the following command) using /crun getElementData(localPlayer, "hoursplayed")

If you're not getting debug errors in debugscript, I'd bet that hoursplayed element data is nil, and gets coalesced to 0 on this line

elseif (getElementData(localPlayer, "hoursplayed") or 0) < 50 then

and compared against 50, 0 is less than 50, so entire condition evaluates as false and the conditional code does not get executed.

Edited by Addlibs
Link to comment

You put 'elseif' as in if the job wasn't  the 'RS Haul Delivery' then it would check if the hours played is below 50, which is why you were able to get the job regardless of how many hours played. Here you go though.
 

local hoursplayed = tonumber(getElementData(localPlayer, "hoursplayed")) or 0
   
if (jobtext=="RS Haul Delivery") then
    if hoursplayed < 50 then
        outputChatBox("You must play at least 50 hours to work as a RS haul delivery driver", 255, 0,0)
        return true
    end
end

 

  • Thanks 1
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...