Jump to content

Job [HELP]


Price.

Recommended Posts

Posted

hello so now after some stuff was added the timer goes infinite loop, keeps counting and doesn't stop little help would be appreciated :\

CLIENT:

local isDx = false 
local sx,sy = guiGetScreenSize ( ) 
remainingTimeK = 15 
l_tick = getTickCount ( ) 
local doCountdown = true 
  
Jobtable = { 
    {228, 1315.4921875, -898.7529296875, 39.578125}, 
    {228, 1178.515625, -2036.8623046875, 69.0078125}, 
    {228, 2432.904296875, -1584.7587890625, 13.753595352173}, 
    {228, 475.8759765625, -1279.939453125, 16.483493804932}, 
    {228, 2491.4052734375, -2499.5556640625, 13.655031204224}, 
} 
  
weps = { 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 38, 16 } 
  
  
function dxInterface ( ) 
    m = remainingTimeK 
    local minutes = 0 
    while tonumber(m) <= 60 do 
        m = m - 60 
        minutes = minutes + 1 
    end 
    if not isDx then 
        addEventHandler ("onClientRender", root, dxInterface ) 
    else end 
    isDx = true 
    dxDrawText ( minutes..":"..m, 0, 0, (sx/1.1)+2, (sy/1.1)+2, tocolor ( 0, 0, 0, 255 ), 2.5, 'default-bold', 'center', 'top' ) 
    dxDrawText ( minutes..":"..m, 0, 0, sx/1.1, sy/1.1, tocolor ( 255, 255, 0, 255 ), 2.5, 'default-bold', 'center', 'top' ) 
    if ( doCountdown and getTickCount ( ) - l_tick >= 1000 ) then 
        remainingTimeK = remainingTimeK - 1 
        l_tick = getTickCount ( ) 
        if ( remainingTimeK == 0 ) then 
            doCountdown = false 
        end 
    end 
end 
  
function fetchRandomOnStart_Handler( ) 
    local skin, x, y, z = unpack ( Jobtable[math.random(#Jobtable)] ) 
    ped = createPed ( skin, x, y, z ) 
    blip = createBlipAttachedTo ( ped, 1, 0, 0, 0, 255 ) 
    countdown = setTimer ( deleteTarget, 180000, 1 ) 
    addEventHandler ("onClientPedWasted", ped, PedMoney ) 
    dxInterface ( ) 
end 
addEvent ( "onAssStart", true ) 
addEventHandler ( "onAssStart", root, fetchRandomOnStart_Handler ) 
  
function deleteTarget ( ) 
    destroyElement ( ped ) 
    destroyElement ( blip ) 
    killTimer ( countdown ) 
    fetchRandomOnStart_Handler ( ) 
    removeEventHandler ( "onClientPedWasted", ped, PedMoney ) 
    removeEventHandler ( "onClientRender", root, dxInterface ) 
end 
  
function PedMoney ( attacker, attackerweapon, bodypart, loss ) 
    local theTeam = getPlayerTeam ( attacker ) 
    local theWL = getPlayerWantedLevel ( attacker ) 
    local theSkin = getElementModel ( attacker ) 
    for _, v in ipairs ( weps ) do 
        if attackerweapon == v  then 
            if  getTeamName( theTeam ) == "Criminal" then 
                deleteTarget ( ) 
                givePlayerMoney ( 100 ) 
            end 
        end 
    end 
end 
  
local pedjob = createPed(249, 1721.1484375, -1121.4775390625, 24.085935592651, 180.0) 
local blipjob = createBlip (1721.1484375, -1121.4775390625, 24.085935592651 , 23, 2, 0, 0, 255, 255, 0, 500) 
  
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        addEventHandler ("onClientMarkerHit", resourceRoot, drawGUIassass) 
    end 
) 
  
function drawGUIassass( ) 
        if getPlayerTeam ( localPlayer ) ~= getTeamFromName ( "Criminal" )  then 
            showCursor(true) 
            assasswindow = guiCreateWindow(542, 220, 493, 475, "Assassinator Job", false) 
            guiWindowSetSizable(assasswindow, false) 
            guiSetAlpha(assasswindow, 0.97) 
  
            titleimage = guiCreateStaticImage(10, 20, 473, 99, "images/assass.png", false, assasswindow) 
            descmemo = guiCreateMemo(44, 135, 402, 291, "Be an assassinator and kill famous persons to get money!\n\nDecide carefully if you want to go this way:\nKilling people is illegal and you will get wanted!\n\nAlso make sure that you have got enought ammo.", false, assasswindow) 
            guiSetAlpha(descmemo, 0.93) 
            guiMemoSetReadOnly(descmemo, true) 
            acceptbutton = guiCreateStaticImage(236, 434, 117, 25, "images/assass_ac.png", false, assasswindow) 
            cancelbutton = guiCreateStaticImage(353, 434, 117, 25, "images/assass_ca.png", false, assasswindow) 
         
            addEventHandler("onClientGUIClick", acceptbutton, startassassjob) 
            addEventHandler("onClientGUIClick", cancelbutton, cancelassassjob) 
        else 
            outputChatBox ( "You are already employed as an Assassinator!" ) 
        end 
end 
addEvent ( "assGuiVisible", true ) 
addEventHandler ( "assGuiVisible", root, drawGUIassass ) 
  
function cancelassassjob() 
        guiSetVisible(assasswindow, false) 
        showCursor(false) 
end 
  
function startassassjob() 
        guiSetVisible(assasswindow, false) 
        showCursor(false) 
        triggerServerEvent ( "AssassStart", localPlayer, "team" ) 
        fetchRandomOnStart_Handler ( ) 
end 
  

YOU HAVE TO TRUST SOMEONE TO BE BETRAYED.I NEVER DID

Posted

And what the debug say?

Edit:

Line 55 you re call the function again that's why you have infinite timer.

CiTLh.png
Posted

i removed @ line 55, no timer , peds doesn't appear after i kill one.

gets aborted , "error aborting, infinite running script"

warning: client.lua : line 55: bad argument @ removeEventHandler expected argument at argument 2.

YOU HAVE TO TRUST SOMEONE TO BE BETRAYED.I NEVER DID

Posted

when i start the script and get the job it works fine, now the timer is the problem iam facing, it just keeps counting all by it self unlimited loop

YOU HAVE TO TRUST SOMEONE TO BE BETRAYED.I NEVER DID

  • Moderators
Posted

Why don't you prevent the job can be executed twice? Or is my answer so not logic..... seriously -_-"

and stop triple bumping, it is annoying.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

yea waiting answer almost a week and no one can help ??????

also i did that and nothing happens.

YOU HAVE TO TRUST SOMEONE TO BE BETRAYED.I NEVER DID

  • Moderators
Posted

2 days have past, not a week, stupid the drama.

If nothing happens then you did it incorrect. An infinity loop can't be infinity when you break it, by putting a statement on it.

Also heard of the isElement function? If you like warnings/errors, then use it not.

https://wiki.multitheftauto.com/wiki/IsElement

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

just corrected some signs.

local isDx = false 
local sx,sy = guiGetScreenSize ( ) 
remainingTimeK = 15 
l_tick = getTickCount ( ) 
local doCountdown = true 
  
Jobtable = { 
    {228, 1315.4921875, -898.7529296875, 39.578125}, 
    {228, 1178.515625, -2036.8623046875, 69.0078125}, 
    {228, 2432.904296875, -1584.7587890625, 13.753595352173}, 
    {228, 475.8759765625, -1279.939453125, 16.483493804932}, 
    {228, 2491.4052734375, -2499.5556640625, 13.655031204224}, 
} 
  
weps = { 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 38, 16 } 
  
  
function dxInterface ( ) 
    m = remainingTimeK 
    local minutes = 0 
    while tonumber(m) > 60 do 
        m = m - 60 
        minutes = minutes + 1 
    end 
    dxDrawText ( minutes..":"..m, 0, 0, (sx/1.1)+2, (sy/1.1)+2, tocolor ( 0, 0, 0, 255 ), 2.5, 'default-bold', 'center', 'top' ) 
    dxDrawText ( minutes..":"..m, 0, 0, sx/1.1, sy/1.1, tocolor ( 255, 255, 0, 255 ), 2.5, 'default-bold', 'center', 'top' ) 
    if ( getTickCount ( ) - l_tick >= 1000 ) then 
        remainingTimeK = remainingTimeK - 1 
        l_tick = getTickCount ( ) 
    end 
end 
  
function fetchRandomOnStart_Handler( ) 
    local skin, x, y, z = unpack ( Jobtable[math.random(#Jobtable)] ) 
    ped = createPed ( skin, x, y, z ) 
    blip = createBlipAttachedTo ( ped, 1, 0, 0, 0, 255 ) 
    countdown = setTimer ( deleteTarget, 180000, 1 ) 
    addEventHandler ("onClientPedWasted", ped, PedMoney ) 
    dxInterface ( ) 
end 
addEvent ( "onAssStart", true ) 
addEventHandler ( "onAssStart", root, fetchRandomOnStart_Handler ) 
  
function deleteTarget ( ) 
    destroyElement ( ped ) 
    destroyElement ( blip ) 
    killTimer ( countdown ) 
    fetchRandomOnStart_Handler ( ) 
    removeEventHandler ( "onClientPedWasted", ped, PedMoney ) 
    removeEventHandler ( "onClientRender", root, dxInterface ) 
end 
  
function PedMoney ( attacker, attackerweapon, bodypart, loss ) 
    local theTeam = getPlayerTeam ( attacker ) 
    local theWL = getPlayerWantedLevel ( attacker ) 
    local theSkin = getElementModel ( attacker ) 
    for _, v in ipairs ( weps ) do 
        if attackerweapon == v  then 
            if  getTeamName( theTeam ) == "Criminal" then 
                deleteTarget ( ) 
                givePlayerMoney ( 100 ) 
            end 
        end 
    end 
end 
  
local pedjob = createPed(249, 1721.1484375, -1121.4775390625, 24.085935592651, 180.0) 
local blipjob = createBlip (1721.1484375, -1121.4775390625, 24.085935592651 , 23, 2, 0, 0, 255, 255, 0, 500) 
function drawGUIassass( ) 
        if getPlayerTeam ( localPlayer ) ~= getTeamFromName ( "Criminal" )  then 
            showCursor(true) 
            assasswindow = guiCreateWindow(542, 220, 493, 475, "Assassinator Job", false) 
            guiWindowSetSizable(assasswindow, false) 
            guiSetAlpha(assasswindow, 0.97) 
  
            titleimage = guiCreateStaticImage(10, 20, 473, 99, "images/assass.png", false, assasswindow) 
            descmemo = guiCreateMemo(44, 135, 402, 291, "Be an assassinator and kill famous persons to get money!\n\nDecide carefully if you want to go this way:\nKilling people is illegal and you will get wanted!\n\nAlso make sure that you have got enought ammo.", false, assasswindow) 
            guiSetAlpha(descmemo, 0.93) 
            guiMemoSetReadOnly(descmemo, true) 
            acceptbutton = guiCreateStaticImage(236, 434, 117, 25, "images/assass_ac.png", false, assasswindow) 
            cancelbutton = guiCreateStaticImage(353, 434, 117, 25, "images/assass_ca.png", false, assasswindow) 
         
            addEventHandler("onClientGUIClick", acceptbutton, startassassjob) 
            addEventHandler("onClientGUIClick", cancelbutton, cancelassassjob) 
        else 
            outputChatBox ( "You are already employed as an Assassinator!" ) 
        end 
end 
addEvent ( "assGuiVisible", true ) 
addEventHandler ( "assGuiVisible", root, drawGUIassass ) 
  
function cancelassassjob() 
        guiSetVisible(assasswindow, false) 
        showCursor(false) 
end 
  
function startassassjob() 
        guiSetVisible(assasswindow, false) 
        showCursor(false) 
        triggerServerEvent ( "AssassStart", localPlayer, "team" ) 
        fetchRandomOnStart_Handler ( ) 
end 
  

YOU HAVE TO TRUST SOMEONE TO BE BETRAYED.I NEVER DID

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