Jump to content

script not outputting on chat


Recommended Posts

i don't see any event with the command = repair

add this on the bottom

addEventHandler ( 'onPlayerCommand', resourceRoot, blockRepairCmdFunc ) 

you didn't read my whole script.

i am calling that function when needed,not using event handler

@Et-win im sure its repair and g_Me stands for getLocalPlayer() and when i output it,it outputs userdata value

and in debugscript 3 it says expected number at argument 2,got player

Link to comment

"repair" you have to send with. And still, I don't understand that script of you :x The function get's runned 1 time in 250 ms, then it outputs "You need to wait 15 seconds in order to repair your vehicle again!" and then cancel's the event, but no command-handler was added to the function?

Link to comment
if getElementData(g_Me,"repairallowed") == 1 then 
         server.fixVehicle(vehicle) 
         setElementData(g_Me,"repairallowed",0) 
       blockTimer = setTimer(blockRepairCmdFunc,250,0) 
         if blockTimer then 
            returnRepair() 
         end 
      end 

If 'repair' is allowed, then do that. So in other words, you don't have an 'else' in the script. It only continues if the data is '0'.

Link to comment

That's what I am saying:

--You are now going to check or command "repair" is blocked: 
function checkIfRepairAllowed() --Start the function 
local vehicle = getPedOccupiedVehicle(g_Me) --Get the vehicle 
   if vehicle then --If it exists 
      if getElementData(g_Me,"repairallowed") == 1 then --When the data is '1' then: 
         server.fixVehicle(vehicle) --Fix it. 
         setElementData(g_Me,"repairallowed",0) --Set the data to '0' 
       blockTimer = setTimer(blockRepairCmdFunc,250,0) --Give a message that he can't use it. 
         if blockTimer then --If the timer does exists 
            returnRepair() --Start this function 
         end 
      end --End the 'if' from " if getElementData(g_Me,"repairallowed") == 1 then". Wait, how can he output a message, if the data is NOT '1' and there isn't an 'elseif' or 'else' ? The data isn't '1' so he is never going to reach that timer to output it into the chat. 
   end 
end 

To output it when it's disable, replace that 'end' with:

elseif (getElementData(g_Me, "repairallowed") == 0) then 
    blockRepairCmdFunc("repair") 
end 

Link to comment

You didn't do it good.

function checkIfRepairAllowed() 
    local vehicle = getPedOccupiedVehicle(g_Me) 
    if vehicle then 
        if getElementData(g_Me,"repairallowed") == 1 then 
            server.fixVehicle(vehicle) 
            setElementData(g_Me,"repairallowed",0) 
            blockTimer = setTimer(blockRepairCmdFunc,250,0,command) 
            if blockTimer then 
                returnRepair() 
            elseif (getElementData(g_Me, "repairallowed") == 0) then 
                blockRepairCmdFunc("repair") 
                outputChatBox("You need to wait 15 seconds in order to repair your vehicle again!",255,0,0) 
            end 
        end 
    end 
end 

It has to be this:

function checkIfRepairAllowed() 
    local vehicle = getPedOccupiedVehicle(g_Me) 
    if vehicle then 
        if getElementData(g_Me,"repairallowed") == 1 then 
            server.fixVehicle(vehicle) 
            setElementData(g_Me,"repairallowed",0) 
            blockTimer = setTimer(blockRepairCmdFunc,250,0,command) 
            if blockTimer then 
                returnRepair() 
            end 
        elseif (getElementData(g_Me, "repairallowed") == 0) then 
                blockRepairCmdFunc("repair") 
        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...