Jump to content

[SOLVED]Need help give money for driving


rublisk19

Recommended Posts

I need help to make script that gives money to player for driving.Like job system!!!!

it need to check if player are [example: policeman skin before giving money for delay time!!

like ::::

  
function enterVehicle ( theVehicle, seat, jacked) 
if ( policeVehicles[getElementModel ( theVehicle )] ) and (policeSkins[getElementModel ( source )] ) then 
>>Wait for 1min<<<<   
setElementData(player, "MONEY",tonumber(getElementData(player, "MONEY"))+180) 
elseif ( policeVehicles[getElementModel ( theVehicle )] ) and (not policeSkins[getElementModel ( source )] ) then 
removePedFromVehicle ( source ) -- force the player out of the vehicle 
outputChatBox ( "Tu ne gaisrininkas!", source ) --  
      end 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), enterVehicle ) --  
  

Okey Thanks for help!!! Waiting replies   :roll::roll::roll::D:D:D:D:P

Edited by Guest
Link to comment
function enterVehicle ( theVehicle, seat, jacked) 
    if ( policeVehicles[getElementModel ( theVehicle )] ) and (policeSkins[getElementModel ( source )] ) then 
        setTimer(setElementData,5000,1,source, "MONEY",tonumber(getElementData(source, "MONEY"))+180) 
    else 
        removePedFromVehicle ( source ) -- force the player out of the vehicle 
        outputChatBox ( "Tu ne gaisrininkas!", source ) -- 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), enterVehicle ) -- 

Not sure if it'll work.

Edited by Guest
Link to comment
You're welcome ;).

Just a little problem it gives me money just 1 time

i set

setTimer(setElementData,6000,10, << to 10 

but it just gives me 1 time no error anything

and other little problem then i sit to car text pop up

outputChatBox ( "Jus gavote alga 180Lt!", source ) -  

but i didn't drived 1min i know function start on player enter car is there any way to make text pop up after 1min ?

Link to comment

That's because I set it to only run the timer once.

And also I set it to 5 seconds, not 1 minute.

function enterVehicle ( theVehicle, seat, jacked) 
    if ( policeVehicles[getElementModel ( theVehicle )] ) and (policeSkins[getElementModel ( source )] ) then 
        setTimer(payThePlayer,60000,0,source) 
    else 
        removePedFromVehicle ( source ) -- force the player out of the vehicle 
        outputChatBox ( "Tu ne gaisrininkas!", source ) -- 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), enterVehicle ) -- 
  
function payThePlayer(thePlayer) 
    if (not thePlayer) then return end 
    setElementData(thePlayer,"MONEY",tonumber(getElementData(thePlayer, "MONEY"))+180) 
    outputChatBox ( "Jus gavote alga 180Lt!", thePlayer ) 
end 

Link to comment

Try this:

local timers = {} 
  
function enterVehicle ( theVehicle, seat, jacked) 
    if ( policeVehicles[getElementModel ( theVehicle )] ) and (policeSkins[getElementModel ( source )] ) then 
        timers[source] = setTimer(payThePlayer,60000,0,source) 
    else 
        removePedFromVehicle ( source ) -- force the player out of the vehicle 
        outputChatBox ( "Tu ne gaisrininkas!", source ) -- 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), enterVehicle ) 
  
addEventHandler("onPlayerQuit",root, 
function () 
    if isTimer(timers[source]) then  
        killTimer(timers[source])  
    end 
end) 
  
function payThePlayer(thePlayer) 
    if (not thePlayer) then  
        if isTimer(timers[thePlayer]) then  
            killTimer(timers[thePlayer])  
        end 
        return 
    end 
    setElementData(thePlayer,"MONEY",tonumber(getElementData(thePlayer, "MONEY"))+180) 
    outputChatBox ( "Jus gavote alga 180Lt!", thePlayer ) 
end 

Link to comment
Try this:
local timers = {} 
  
function enterVehicle ( theVehicle, seat, jacked) 
    if ( policeVehicles[getElementModel ( theVehicle )] ) and (policeSkins[getElementModel ( source )] ) then 
        timers[source] = setTimer(payThePlayer,60000,0,source) 
    else 
        removePedFromVehicle ( source ) -- force the player out of the vehicle 
        outputChatBox ( "Tu ne gaisrininkas!", source ) -- 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), enterVehicle ) 
  
addEventHandler("onPlayerQuit",root, 
function () 
    if isTimer(timers[source]) then  
        killTimer(timers[source])  
    end 
end) 
  
function payThePlayer(thePlayer) 
    if (not thePlayer) then  
        if isTimer(timers[thePlayer]) then  
            killTimer(timers[thePlayer])  
        end 
        return 
    end 
    setElementData(thePlayer,"MONEY",tonumber(getElementData(thePlayer, "MONEY"))+180) 
    outputChatBox ( "Jus gavote alga 180Lt!", thePlayer ) 
end 

Thanks problem solved

Edit:

function enterVehicle ( theVehicle, seat, jacked) 
        if ( policeVehicles[getElementModel ( theVehicle )] ) and (policeSkins[getElementModel ( source )] ) then 
            timers[source] = setTimer(payThePlayer,60000,0,source) 
        else 
            removePedFromVehicle ( source ) -- force the player out of the vehicle 
            outputChatBox ( "Jus ne policininkas!", source ) -- 
        end 
        elseif ( FireCars[getElementModel ( theVehicle )] ) and (FireSkins[getElementModel ( source )] ) then 
            timers[source] = setTimer(payThePlayer1,60000,0,source) 
        else 
            removePedFromVehicle ( source ) -- force the player out of the vehicle 
            outputChatBox ( "Just ne gaisrininkas!", source ) -- 
        end 
        elseif ( medicCars[getElementModel ( theVehicle )] ) and (medicSkins[getElementModel ( source )] ) then 
            timers[source] = setTimer(payThePlayer2,60000,0,source) 
        else 
            removePedFromVehicle ( source ) -- force the player out of the vehicle 
            outputChatBox ( "Just ne medikas!", source ) -- 
        end 
    end 
    addEventHandler ( "onPlayerVehicleEnter", getRootElement(), enterVehicle ) 

i maked this but i get error end expected to close function at line 11 near elseif

Link to comment

Try this:

function enterVehicle ( theVehicle, seat, jacked) 
    if ( policeVehicles[getElementModel ( theVehicle )] ) and (policeSkins[getElementModel ( source )] ) then 
        timers[source] = setTimer(payThePlayer,60000,0,source) 
    else 
        removePedFromVehicle ( source ) -- force the player out of the vehicle 
        outputChatBox ( "Jus ne policininkas!", source ) -- 
    end 
    if ( FireCars[getElementModel ( theVehicle )] ) and (FireSkins[getElementModel ( source )] ) then 
        timers[source] = setTimer(payThePlayer1,60000,0,source) 
    else 
        removePedFromVehicle ( source ) -- force the player out of the vehicle 
        outputChatBox ( "Just ne gaisrininkas!", source ) -- 
    end 
    if ( medicCars[getElementModel ( theVehicle )] ) and (medicSkins[getElementModel ( source )] ) then 
        timers[source] = setTimer(payThePlayer2,60000,0,source) 
    else 
        removePedFromVehicle ( source ) -- force the player out of the vehicle 
        outputChatBox ( "Just ne medikas!", source ) -- 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), enterVehicle ) 

Link to comment
Try this:
function enterVehicle ( theVehicle, seat, jacked) 
    if ( policeVehicles[getElementModel ( theVehicle )] ) and (policeSkins[getElementModel ( source )] ) then 
        timers[source] = setTimer(payThePlayer,60000,0,source) 
    else 
        removePedFromVehicle ( source ) -- force the player out of the vehicle 
        outputChatBox ( "Jus ne policininkas!", source ) -- 
    end 
    if ( FireCars[getElementModel ( theVehicle )] ) and (FireSkins[getElementModel ( source )] ) then 
        timers[source] = setTimer(payThePlayer1,60000,0,source) 
    else 
        removePedFromVehicle ( source ) -- force the player out of the vehicle 
        outputChatBox ( "Just ne gaisrininkas!", source ) -- 
    end 
    if ( medicCars[getElementModel ( theVehicle )] ) and (medicSkins[getElementModel ( source )] ) then 
        timers[source] = setTimer(payThePlayer2,60000,0,source) 
    else 
        removePedFromVehicle ( source ) -- force the player out of the vehicle 
        outputChatBox ( "Just ne medikas!", source ) -- 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), enterVehicle ) 

not work kicks me from car :D P.S. elseif doesn't kicked me from car but i get error

Link to comment

Try this:

function enterVehicle ( theVehicle, seat, jacked) 
    if ( policeVehicles[getElementModel ( theVehicle )] ) and (policeSkins[getElementModel ( source )] ) then 
        timers[source] = setTimer(payThePlayer,60000,0,source) 
    elseif ( FireCars[getElementModel ( theVehicle )] ) and (FireSkins[getElementModel ( source )] ) then 
        timers[source] = setTimer(payThePlayer1,60000,0,source) 
    elseif ( medicCars[getElementModel ( theVehicle )] ) and (medicSkins[getElementModel ( source )] ) then 
        timers[source] = setTimer(payThePlayer2,60000,0,source) 
    else 
        removePedFromVehicle ( source ) -- force the player out of the vehicle 
        outputChatBox("You're not allowed to use this vehicle", source) 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), enterVehicle ) 

Link to comment
Try this:
function enterVehicle ( theVehicle, seat, jacked) 
    if ( policeVehicles[getElementModel ( theVehicle )] ) and (policeSkins[getElementModel ( source )] ) then 
        timers[source] = setTimer(payThePlayer,60000,0,source) 
    elseif ( FireCars[getElementModel ( theVehicle )] ) and (FireSkins[getElementModel ( source )] ) then 
        timers[source] = setTimer(payThePlayer1,60000,0,source) 
    elseif ( medicCars[getElementModel ( theVehicle )] ) and (medicSkins[getElementModel ( source )] ) then 
        timers[source] = setTimer(payThePlayer2,60000,0,source) 
    else 
        removePedFromVehicle ( source ) -- force the player out of the vehicle 
        outputChatBox("You're not allowed to use this vehicle", source) 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), enterVehicle ) 

Not work error

attempt to index global 'timers' a nil value 

P.S. in game i get pay for anything i don't need to be in car

Link to comment

the problem is that when the timer is finished and the 'player gets paid', there is no check that he is actually in a vehicle, while he could have gotten in one, then the setTimer would be triggered within 60 secs, but the player could have also gotten out of the vehicle while nothing stops him from doing so

Link to comment

Full code server:

local timers = { } 
  
local policeSkins = {  
    [280] = true,  
    [281] = true,  
    [282] = true,  
    [283] = true,  
    [284] = true,  
    [285] = true,  
    [286] = true  
} 
  
local FireSkins = { 
    [277] = true, 
    [278] = true, 
    [279] = true 
} 
  
local medicSkins = { 
    [274] = true, 
    [275] = true, 
    [276] = true 
} 
  
local policeVehicles = { 
    [598] = true, 
    [596] = true, 
    [597] = true, 
    [599] = true 
} 
  
local FireCars = { 
    [407] = true, 
    [544] = true 
} 
  
local medicCars = { 
    [416] = true 
} 
  
  
function enterVehicle ( theVehicle, seat, jacked ) 
    if ( policeVehicles[ getElementModel ( theVehicle ) ] ) and ( policeSkins[ getElementModel ( source ) ] ) then 
        timers[source] = setTimer( payThePlayer,60000,0,source ) 
    elseif ( FireCars[ getElementModel ( theVehicle ) ] ) and ( FireSkins[ getElementModel ( source ) ] ) then 
        timers[source] = setTimer( payThePlayer1,60000,0,source ) 
    elseif ( medicCars [getElementModel ( theVehicle ) ] ) and ( medicSkins[ getElementModel ( source  ) ] ) then 
        timers[source] = setTimer( payThePlayer2,60000,0,source ) 
    else 
        removePedFromVehicle ( source ) -- force the player out of the vehicle 
        outputChatBox("You're not allowed to use this vehicle", source) 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", root, enterVehicle ) 
  
  
addEventHandler("onPlayerQuit",root, 
    function( ) 
        if isTimer( timers[source] ) then  
            killTimer( timers[source] )  
        end 
        timers[source] = nil 
    end 
) 
  
function payThePlayer( thePlayer ) 
    if not thePlayer then  
        if isTimer( timers[thePlayer] ) then  
            killTimer( timers[thePlayer] )  
        end 
        return 
    end 
    setElementData( thePlayer,"MONEY",tonumber( getElementData(thePlayer, "MONEY" ) )+180 ) 
    outputChatBox ( "Jus gavote alga 180Lt!", thePlayer ) 
end 
  
function payThePlayer1( thePlayer ) 
    if not thePlayer then  
        if isTimer( timers[thePlayer] ) then  
            killTimer( timers[thePlayer] )  
        end 
        return 
    end 
    setElementData( thePlayer,"MONEY",tonumber( getElementData( thePlayer, "MONEY" ) )+380 ) 
    outputChatBox ( "Jus gavote alga 380Lt!", thePlayer ) 
end 
  
function payThePlayer2( thePlayer ) 
    if not thePlayer then  
        if isTimer( timers[thePlayer] ) then  
            killTimer( timers[thePlayer] )  
        end 
        return 
    end 
    setElementData( thePlayer,"MONEY",tonumber( getElementData( thePlayer, "MONEY" ) )+580 ) 
    outputChatBox ( "Jus gavote alga 580Lt!", thePlayer ) 
end 

Link to comment

Try this:

local timers = { } 
  
local policeSkins = { 
    [280] = true, 
    [281] = true, 
    [282] = true, 
    [283] = true, 
    [284] = true, 
    [285] = true, 
    [286] = true 
} 
  
local FireSkins = { 
    [277] = true, 
    [278] = true, 
    [279] = true 
} 
  
local medicSkins = { 
    [274] = true, 
    [275] = true, 
    [276] = true 
} 
  
local policeVehicles = { 
    [598] = true, 
    [596] = true, 
    [597] = true, 
    [599] = true 
} 
  
local FireCars = { 
    [407] = true, 
    [544] = true 
} 
  
local medicCars = { 
    [416] = true 
} 
  
  
function enterVehicle ( theVehicle, seat, jacked ) 
    if ( not policeVehicles[ getElementModel ( theVehicle ) ] and not FireCars[ getElementModel ( theVehicle ) ] and not medicCars[ getElementModel ( theVehicle ) ] ) then return end 
    if ( policeVehicles[ getElementModel ( theVehicle ) ] ) and ( policeSkins[ getElementModel ( source ) ] ) then 
        timers[source] = setTimer( payThePlayer,60000,0,source ) 
    elseif ( FireCars[ getElementModel ( theVehicle ) ] ) and ( FireSkins[ getElementModel ( source ) ] ) then 
        timers[source] = setTimer( payThePlayer1,60000,0,source ) 
    elseif ( medicCars [getElementModel ( theVehicle ) ] ) and ( medicSkins[ getElementModel ( source  ) ] ) then 
        timers[source] = setTimer( payThePlayer2,60000,0,source ) 
    else 
        removePedFromVehicle ( source ) -- force the player out of the vehicle 
        outputChatBox("You're not allowed to use this vehicle", source) 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", root, enterVehicle ) 
  
addEventHandler("onPlayerQuit",root, 
    function( ) 
        if isTimer( timers[source] ) then 
            killTimer( timers[source] ) 
        end 
        timers[source] = nil 
    end 
) 
  
function exitVehicle() 
    if isTimer( timers[source] ) then 
        killTimer( timers[source] ) 
    end 
    timers[source] = nil 
end 
addEventHandler ( "onPlayerVehicleExit", root, exitVehicle ) 
  
function payThePlayer( thePlayer ) 
    if not thePlayer then 
        if isTimer( timers[thePlayer] ) then 
            killTimer( timers[thePlayer] ) 
        end 
        return 
    end 
    setElementData( thePlayer,"MONEY",tonumber( getElementData(thePlayer, "MONEY" ) )+180 ) 
    outputChatBox ( "Jus gavote alga 180Lt!", thePlayer ) 
end 
  
function payThePlayer1( thePlayer ) 
    if not thePlayer then 
        if isTimer( timers[thePlayer] ) then 
            killTimer( timers[thePlayer] ) 
        end 
        return 
    end 
    setElementData( thePlayer,"MONEY",tonumber( getElementData( thePlayer, "MONEY" ) )+380 ) 
    outputChatBox ( "Jus gavote alga 380Lt!", thePlayer ) 
end 
  
function payThePlayer2( thePlayer ) 
    if not thePlayer then 
        if isTimer( timers[thePlayer] ) then 
            killTimer( timers[thePlayer] ) 
        end 
        return 
    end 
    setElementData( thePlayer,"MONEY",tonumber( getElementData( thePlayer, "MONEY" ) )+580 ) 
    outputChatBox ( "Jus gavote alga 580Lt!", thePlayer ) 
end 

Link to comment

Try and write what output.

local timers = { } 
  
local policeSkins = { 
    [280] = true, 
    [281] = true, 
    [282] = true, 
    [283] = true, 
    [284] = true, 
    [285] = true, 
    [286] = true 
} 
  
local FireSkins = { 
    [277] = true, 
    [278] = true, 
    [279] = true 
} 
  
local medicSkins = { 
    [274] = true, 
    [275] = true, 
    [276] = true 
} 
  
local policeVehicles = { 
    [598] = true, 
    [596] = true, 
    [597] = true, 
    [599] = true 
} 
  
local FireCars = { 
    [407] = true, 
    [544] = true 
} 
  
local medicCars = { 
    [416] = true 
} 
  
  
function enterVehicle ( theVehicle, seat, jacked ) 
    if ( not policeVehicles[ getElementModel ( theVehicle ) ] and not FireCars[ getElementModel ( theVehicle ) ] and not medicCars[ getElementModel ( theVehicle ) ] ) then  
        removePedFromVehicle ( source ) 
        return 
    end 
    if ( policeVehicles[ getElementModel ( theVehicle ) ] ) and ( policeSkins[ getElementModel ( source ) ] ) then 
        timers[source] = setTimer( payThePlayer,60000,0,source ) 
    elseif ( FireCars[ getElementModel ( theVehicle ) ] ) and ( FireSkins[ getElementModel ( source ) ] ) then 
        timers[source] = setTimer( payThePlayer1,60000,0,source ) 
    elseif ( medicCars [getElementModel ( theVehicle ) ] ) and ( medicSkins[ getElementModel ( source  ) ] ) then 
        timers[source] = setTimer( payThePlayer2,60000,0,source ) 
    else 
        removePedFromVehicle ( source ) -- force the player out of the vehicle 
        outputChatBox("You're not allowed to use this vehicle", source) 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", root, enterVehicle ) 
  
addEventHandler("onPlayerQuit",root, 
    function( ) 
        if isTimer( timers[source] ) then 
            killTimer( timers[source] ) 
        end 
        timers[source] = nil 
    end 
) 
  
function exitVehicle() 
    if isTimer( timers[source] ) then 
        killTimer( timers[source] ) 
    end 
    timers[source] = nil 
end 
addEventHandler ( "onPlayerVehicleExit", root, exitVehicle ) 
  
function payThePlayer( thePlayer ) 
    if not isElement( thePlayer ) then 
        if isTimer( timers[thePlayer] ) then 
            killTimer( timers[thePlayer] ) 
        end 
        return 
    end 
    setElementData( thePlayer,"MONEY",tonumber( getElementData(thePlayer, "MONEY" ) )+180 ) 
    outputChatBox ( "Jus gavote alga 180Lt!", thePlayer ) 
end 
  
function payThePlayer1( thePlayer ) 
    if not isElement( thePlayer ) then 
        if isTimer( timers[thePlayer] ) then 
            killTimer( timers[thePlayer] ) 
        end 
        return 
    end 
    setElementData( thePlayer,"MONEY",tonumber( getElementData( thePlayer, "MONEY" ) )+380 ) 
    outputChatBox ( "Jus gavote alga 380Lt!", thePlayer ) 
end 
  
function payThePlayer2( thePlayer ) 
    if not isElement( thePlayer ) then 
        if isTimer( timers[thePlayer] ) then 
            killTimer( timers[thePlayer] ) 
        end 
        return 
    end 
    setElementData( thePlayer,"MONEY",tonumber( getElementData( thePlayer, "MONEY" ) )+580 ) 
    outputChatBox ( "Jus gavote alga 580Lt!", thePlayer ) 
end 

p.s idk why it not work for you..

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