Jump to content

Help To Problem Script !![PLEASE!!]


QoRaY

Recommended Posts

Posted (edited)

:arrow:

RUNNİNG THE SCRİPT, BUT THE MONEY DOES NOT COME!!! HELP

:!::!::!:

server.lua

local rootElement = getRootElement() 
local busses = {[431] = true, [437] = true, [582] = true, [456] = true, [459] = true, [428] = true, [498] = true, [508] = true, [413] = true} 
local busTable = { 
[1]={1269.98, -1852.29, 13.3828},[2]={1181.87, -1796.36, 13.3984},[3]={1164.47, -1712.17, 13.7231},[4]={1038.74, -1712.84, 13.4254},[5]={1037.64, -1558.29, 13.3862}, 
[6]={1061.46, -1443.02, 13.4006},[7]={1051.46, -1396.45, 13.4565},[8]={825.122, -1395.14, 13.3444},[9]={648.371, -1395.33, 13.3444},[10]={635.96, -1252.67, 17.1576}, 
[11]={554.18, -1122.47, 27.2105},[12]={238.52, -1170.34, 19.5841},[13]={-43.18, -1354.07, 11.2299},[14]={-284.8, -1642.00, 15.5116},[15]={-354.4, -1831.65, 22.2320}, 
[16]={-348.6, -2125.50, 28.3879},[17]={-174.6, -2413.64, 35.6235},[18]={-36.62, -2711.40, 42.0042},[19]={-315.0, -2800.08, 57.5757},[20]={-757.3, -2764.34, 74.7090}, 
[21]={-1141, -2850.020, 67.7570},[22]={-1569, -2742.080, 48.5795},[23]={-1966, -2547.510, 38.2349},[24]={-2191, -2370.410, 30.5065},[25]={-2212, -2264.740, 30.5055}, 
[26]={-2102, -2078.130, 63.1302},[27]={-1820, -1726.650, 29.1070},[28]={-1400, -1648.350, 45.1570},[29]={-1144, -1899.890, 77.5020},[30]={-802.3, -1785.11, 92.2070}, 
[31]={-758.6, -1454.05, 87.8020},[32]={-652.7, -1420.18, 90.4095},[33]={-572.8, -1070.35, 23.5500},[34]={-372.0, -823.054, 28.4015},[35]={-189.6, -938.291, 35.3530}, 
[36]={-55.70, -858.507, 13.7823},[37]={-113.0, -402.609, 1.10380},[38]={-221.9, 187.8397, 8.88888},[39]={-63.88, 551.1700, 9.22222},[40]={323.85, 753.2600, 6.15222}, 
[41]={740.54, 657.1210, 10.7505},[42]={1099.8, 803.8835, 10.7070},[43]={1556.6, 831.4191, 6.80807},[44]={1785.1, 798.4346, 11.2008},[45]={1605.7, 116.6938, 37.2020}, 
[46]={1701.3, -644.311, 41.8010},[47]={1635.6, -884.206, 52.5121},[48]={1798.2, -1037.61, 39.4545},[49]={2223.8, -1137.70, 25.6588},[50]={2269.0, -1209.68, 23.9119}, 
[51]={2196.8, -1382.42, 23.8575},[52]={2110.5, -1427.29, 23.8566},[53]={2002.0, -1459.51, 13.4255},[54]={1842.8, -1508.62, 13.3936},[55]={1819.2, -1865.68, 13.4469}, 
[56]={1779.7, -1917.97, 13.4165},[57]={1811.2, -1890.22, 13.4372},[58]={1798.6, -1830.07, 13.4257},[59]={1680.3, -1859.67, 13.4131},[60]={1468.2, -1869.85, 13.4074}, 
} 
  
createBlip(1256.6, -1812.2, 13.41, 55, 3, 0, 0, 255, 255, 0, 250) 
  
function getNewBusLocation(thePlayer, ID) 
local x, y, z = busTable[ID][1], busTable[ID][2], busTable[ID][3] 
triggerClientEvent(thePlayer,"bus_set_location",thePlayer,x,y,z) 
end 
  
function busJob(thePlayer) 
    local theVehicle = getPedOccupiedVehicle (thePlayer) 
    local id = getElementModel(theVehicle) 
    if id == 431 or id == 437 or id == 582 or id == 556 or id == 459 or id == 428 or id == 498 or id == 508 or id == 413 then 
        local x, y, z = getNewBusLocation(thePlayer, 1) 
        setElementData(thePlayer,"buszp",0) 
        setElementData(thePlayer,"busData",1) 
    else 
    end 
end 
addEventHandler("onVehicleEnter",rootElement,busJob) 
  
function busStart(thePlayer) 
    local theVehicle = getPedOccupiedVehicle (thePlayer) 
    local id = getElementModel(theVehicle) 
    if id == 431 or id == 437 or id == 582 or id == 556 or id == 459 or id == 428 or id == 498 or id == 508 or id == 413 then 
        outputChatBox("Otobus&Minibus gorevini baslatmak icin haritada belirtilen noktaya gidin!", thePlayer, 255, 255, 0) 
    end 
end 
addEventHandler("onVehicleEnter",rootElement,busStart) 
  
addEvent("bus_finish",true) 
addEventHandler("bus_finish",rootElement, 
function (client) 
if not isPedInVehicle(client) then return end 
if not busses[getElementModel(getPedOccupiedVehicle(client))] then return end 
local zarp = getElementData(client, "buszp") 
local money = math.random(10,20) 
setElementData(client, "buszp", zarp + money) 
if #busTable == tonumber(getElementData(client,"busData")) then 
setElementData(client,"busData",1) 
else 
setElementData(client,"busData",tonumber(getElementData(client,"busData"))+1) 
end 
getNewBusLocation(client, tonumber(getElementData(client,"busData"))) 
end) 
  
function giveMoney(thePlayer) 
    local theVehicle = getPedOccupiedVehicle (thePlayer) 
    local id = getElementModel(theVehicle) 
    if id == 431 or id == 437 or id == 582 or id == 556 or id == 459 or id == 428 or id == 498 or id == 508 or id == 413 then 
        local gpm = getElementData(thePlayer, "buszp") 
        if ((gpm) > 0 ) then 
            givePlayerMoney(thePlayer, tonumber(gpm)) 
            outputChatBox("Kazandiginiz miktar " .. gpm .. "$", thePlayer, 0, 140, 240) 
            setElementData(thePlayer, "buszp", 0) 
        end 
    end 
end 
addEventHandler("onVehicleExit", rootElement, giveMoney) 
addEventHandler("onPlayerQuit", rootElement, giveMoney) 

client.lua

local client = getLocalPlayer( ) 
local rootElement = getRootElement() 
local marker = nil 
local blip = nil 
  
addEvent("bus_set_location",true) 
addEventHandler("bus_set_location",rootElement, 
function (x, y, z) 
marker = createMarker(tostring(x), tostring(y), tostring(z)-1, "checkpoint", 4.0, 0, 0, 255, 255) 
blip = createBlipAttachedTo( marker, 41, 3, 0, 0, 255, 255 ) 
addEventHandler("onClientMarkerHit",marker,onBusStopHit) 
end) 
  
function onBusStopHit(hitPlayer) 
if not hitPlayer == client then return end 
triggerServerEvent("bus_finish",client,client) 
if isElement(blip) then destroyElement(blip) end 
if isElement(marker) then 
removeEventHandler("onClientMarkerHit",marker,onBusStopHit) 
destroyElement(marker)  
  end 
end 
  
addEventHandler("onClientVehicleExit",rootElement, 
function () 
if isElement(marker) then 
removeEventHandler("onClientMarkerHit",marker,onBusStopHit) 
destroyElement(marker)  
end 
if isElement(blip) then destroyElement(blip) end 
end) 

meta.xml

    "QoRaY" description="TeM" version="1.0.2" type="misc"/> 
    

Edited by Guest
Posted

thats why we need the output here

so pls post it that we can help you better ok?

if you dont know how to, get admin on the server and write in chatbox: /debugscript 3 or press F8 and write debugscript 3 and enter

Posted (edited)
WARNING: [gameplay]\meslekler\busjob.lua:63: Bad argument @ 'getPedOccupiedVehicle' 
WARNING: [gameplay]\meslekler\busjob.lua:64: Bad argument @ 'getElementModel' [Expected element at argument 1, got boolean] 

Edited by Guest
Posted

server line 74 > use addEventHandler("onVehicleStartExit", rootElement, giveMoney)

instead of addEventHandler("onVehicleExit", rootElement, giveMoney)

tell me then if it works

Posted

It makes no sens at all to give the player money with onPlayerQuit !

And why are you doing this :

function busJob(thePlayer) 
    local theVehicle = getPedOccupiedVehicle (thePlayer) 
    local id = getElementModel(theVehicle) 
    if id == 431 or id == 437 or id == 582 or id == 556 or id == 459 or id == 428 or id == 498 or id == 508 or id == 413 then 
        local x, y, z = getNewBusLocation(thePlayer, 1) 
        setElementData(thePlayer,"buszp",0) 
        setElementData(thePlayer,"busData",1) 
    else 
    end 
end 
addEventHandler("onVehicleEnter",rootElement,busJob) 
  
function busStart(thePlayer) 
    local theVehicle = getPedOccupiedVehicle (thePlayer) 
    local id = getElementModel(theVehicle) 
    if id == 431 or id == 437 or id == 582 or id == 556 or id == 459 or id == 428 or id == 498 or id == 508 or id == 413 then 
        outputChatBox("Otobus&Minibus gorevini baslatmak icin haritada belirtilen noktaya gidin!", thePlayer, 255, 255, 0) 
    end 
end 
addEventHandler("onVehicleEnter",rootElement,busStart) 

Instead of :

function busJob(thePlayer) 
    local id = getElementModel(source) 
    if busses[id] then 
        local x, y, z = getNewBusLocation(thePlayer, 1) 
        setElementData(thePlayer,"buszp",0) 
        setElementData(thePlayer,"busData",1) 
        outputChatBox("Otobus&Minibus gorevini baslatmak icin haritada belirtilen noktaya gidin!", thePlayer, 255, 255, 0) 
    end 
end 
addEventHandler("onVehicleEnter",rootElement,busJob) 

Try this server side :

local rootElement = getRootElement( ) 
local busses = { [431] = true, [437] = true, [582] = true, [456] = true, [459] = true, [428] = true, [498] = true, [508] = true, [413] = true } 
local busTable = { 
    [1]={1269.98, -1852.29, 13.3828},[2]={1181.87, -1796.36, 13.3984},[3]={1164.47, -1712.17, 13.7231},[4]={1038.74, -1712.84, 13.4254},[5]={1037.64, -1558.29, 13.3862}, 
    [6]={1061.46, -1443.02, 13.4006},[7]={1051.46, -1396.45, 13.4565},[8]={825.122, -1395.14, 13.3444},[9]={648.371, -1395.33, 13.3444},[10]={635.96, -1252.67, 17.1576}, 
    [11]={554.18, -1122.47, 27.2105},[12]={238.52, -1170.34, 19.5841},[13]={-43.18, -1354.07, 11.2299},[14]={-284.8, -1642.00, 15.5116},[15]={-354.4, -1831.65, 22.2320}, 
    [16]={-348.6, -2125.50, 28.3879},[17]={-174.6, -2413.64, 35.6235},[18]={-36.62, -2711.40, 42.0042},[19]={-315.0, -2800.08, 57.5757},[20]={-757.3, -2764.34, 74.7090}, 
    [21]={-1141, -2850.020, 67.7570},[22]={-1569, -2742.080, 48.5795},[23]={-1966, -2547.510, 38.2349},[24]={-2191, -2370.410, 30.5065},[25]={-2212, -2264.740, 30.5055}, 
    [26]={-2102, -2078.130, 63.1302},[27]={-1820, -1726.650, 29.1070},[28]={-1400, -1648.350, 45.1570},[29]={-1144, -1899.890, 77.5020},[30]={-802.3, -1785.11, 92.2070}, 
    [31]={-758.6, -1454.05, 87.8020},[32]={-652.7, -1420.18, 90.4095},[33]={-572.8, -1070.35, 23.5500},[34]={-372.0, -823.054, 28.4015},[35]={-189.6, -938.291, 35.3530}, 
    [36]={-55.70, -858.507, 13.7823},[37]={-113.0, -402.609, 1.10380},[38]={-221.9, 187.8397, 8.88888},[39]={-63.88, 551.1700, 9.22222},[40]={323.85, 753.2600, 6.15222}, 
    [41]={740.54, 657.1210, 10.7505},[42]={1099.8, 803.8835, 10.7070},[43]={1556.6, 831.4191, 6.80807},[44]={1785.1, 798.4346, 11.2008},[45]={1605.7, 116.6938, 37.2020}, 
    [46]={1701.3, -644.311, 41.8010},[47]={1635.6, -884.206, 52.5121},[48]={1798.2, -1037.61, 39.4545},[49]={2223.8, -1137.70, 25.6588},[50]={2269.0, -1209.68, 23.9119}, 
    [51]={2196.8, -1382.42, 23.8575},[52]={2110.5, -1427.29, 23.8566},[53]={2002.0, -1459.51, 13.4255},[54]={1842.8, -1508.62, 13.3936},[55]={1819.2, -1865.68, 13.4469}, 
    [56]={1779.7, -1917.97, 13.4165},[57]={1811.2, -1890.22, 13.4372},[58]={1798.6, -1830.07, 13.4257},[59]={1680.3, -1859.67, 13.4131},[60]={1468.2, -1869.85, 13.4074}, 
} 
  
createBlip( 1256.6, -1812.2, 13.41, 55, 3, 0, 0, 255, 255, 0, 250 ) 
  
function getNewBusLocation( thePlayer, ID ) 
    local x, y, z = busTable[ID][1], busTable[ID][2], busTable[ID][3] 
    triggerClientEvent( thePlayer, "bus_set_location", thePlayer, x, y, z ) 
    return x, y, z 
end 
  
function busJob( thePlayer ) 
    local id = getElementModel( source ) 
    if busses[id] then 
        local x, y, z = getNewBusLocation( thePlayer, 1 ) 
        setElementData( thePlayer,"buszp", 0 ) 
        setElementData( thePlayer,"busData", 1 ) 
        outputChatBox( "Otobus&Minibus gorevini baslatmak icin haritada belirtilen noktaya gidin!", thePlayer, 255, 255, 0 ) 
    end 
end 
addEventHandler( "onVehicleEnter", rootElement, busJob ) 
  
addEvent( "bus_finish", true ) 
addEventHandler( "bus_finish", rootElement, 
    function( client ) 
    if not isPedInVehicle( client ) then return end 
    if not busses[getElementModel( getPedOccupiedVehicle( client ) )] then return end 
    local zarp = getElementData( client, "buszp" ) 
    local money = math.random( 10, 20 ) 
    setElementData( client, "buszp", zarp + money ) 
    if #busTable == tonumber( getElementData( client, "busData" ) ) then 
        setElementData( client, "busData", 1 ) 
    else 
        setElementData( client, "busData", tonumber( getElementData( client, "busData" ) ) + 1 ) 
    end 
    getNewBusLocation( client, tonumber( getElementData( client, "busData" ) ) ) 
    end 
) 
  
function giveMoney( thePlayer ) 
    local id = getElementModel( source )  
    if busses[id] then 
        local gpm = getElementData( thePlayer, "buszp" ) 
        if gpm > 0 then 
            givePlayerMoney( thePlayer, tonumber( gpm ) ) 
            outputChatBox( "Kazandiginiz miktar " .. gpm .. " $", thePlayer, 0, 140, 240 ) 
            setElementData( thePlayer, "buszp", 0 ) 
        end 
    end 
end 
addEventHandler( "onVehicleExit", rootElement, giveMoney ) 

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