botshara
-
Posts
83 -
Joined
-
Last visited
Posts posted by botshara
-
-
Where is the problem ? I dont get message this police car.... and i can eneter in car
addEventHandler( "onVehicleStartEnter", root, function( player, seat ) local id = getElementModel ( theVehicle ) if seat == 0 and id == 596 then outputChatBox( "(( This is police car, you cant drive with it!. ))", player, 255, 0, 0 ) cancelEvent( ) end end )
-
in line 14 change to this
moveObject(policeDoor[1], 3000, 246.36, 72.62, 1002.64, 0, 0, 0)
yeah it work, but one door opens later and dont close
-
local policeDoor = { } function createDoors() policeDoor[1] = createObject ( 1535, 246.36, 72.62, 1002.64, 0, 0, 0 ) policeDoor[2] = createObject ( 1535, 244.84, 72.61, 1002.64, 0, 0, 0 ) for i=1,#policeDoor do setElementInterior(policeDoor[i], 6) setElementDimension(policeDoor[i], 9) end end addEventHandler("onResourceStart", resourceRoot, createDoors) function backDoors() moveObject(policeDoor[1], 3000, 1535, 246.36, 72.62, 1002.64, 0, 0, 0) moveObject(policeDoor[2], 3000, 242.84, 72.61, 1002.64, 0, 0, 0) end function openDoors(thePlayer, command) if ( exports.factions:isPlayerInFaction(thePlayer, 1) ) then outputChatBox("PD doors open.", thePlayer) moveObject(policeDoor[1], 3000, 248.36, 72.62, 1002.64, 0, 0, 0) moveObject(policeDoor[2], 3000, 244.84, 72.61, 1002.64, 0, 0, 0) setTimer(backDoors, 5000, 1) end end addCommandHandler("pddd", openDoors)
The same problem, doors open but dont go back. when i write again /pddd doors close and then open, but dont go back
I FIXED IT, I CHANGED setTimer(bacdoors, 5000, 1) with setTimer(createdoors, 5000, 1) but it doesnt look rp
-
I have a small problem, i created 2 doors and i want them open in one time and after 5 sec moveback. Now i have a problem doors dont open in one time and doors dont moveback after 5 sec
policedoors1 = createObject ( 1535, 246.36, 72.62, 1002.64, 0, 0, 0 ) setElementInterior ( policedoors1, 6) setElementDimension ( policedoors1, 9) policedoors2 = createObject ( 1535, 244.84, 72.61, 1002.64, 0, 0, 0 ) setElementInterior ( policedoors2, 6) setElementDimension ( policedoors2, 9) function doors1police() moveObject ( policedoors1, 3000, 1535, 246.36, 72.62, 1002.64, 0, 0, 0 ) setElementInterior ( policedoors1, 6) setElementDimension ( policedoors1, 9) end function doors2police() moveObject ( policedoors2, 3000, 242.84, 72.61, 1002.64, 0, 0, 0 ) setElementInterior ( policedoors1, 6) setElementDimension ( policedoors1, 9) end function policedoorsx(thePlayer, command) if exports.factions:isPlayerInFaction( thePlayer, 1 ) then outputChatBox("PD doors open.",thePlayer) moveObject ( policedoors1, 3000, 248.36, 72.62, 1002.64, 0, 0, 0 ) setElementInterior ( policedoors1, 6) setElementDimension ( policedoors1, 9) moveObject ( policedoors2, 3000, 244.84, 72.61, 1002.64, 0, 0, 0 ) setTimer (doors1police, 5000, 1) setTimer (doors2police, 5000, 1) end end addCommandHandler("pddd", policedoorsx)
-
number = exports.sql:query_insertid( "INSERT INTO phones VALUES ()" );
you didn't put anything in for 'VALUES.'
nop, it is correct if not number insert nothing.
something here is problem to close while or if's
if not number then number = exports.sql:query_insertid( "INSERT INTO phones VALUES ()" ); else -- we create a row for the one that didn't exist yet but where we have the number for. while true do attempts = attempts + 1 number = math.random(311111, attempts < 20 and 899999 or 8999999) -- no current phones OR the new phone number is the new max. end return createPhone( ) -- we have a phone number that's below the maximum if not exports.sql:query_free( "INSERT INTO phones (phoneNumber) VALUES (" .. number .. ")" ) then -- if this fails, the phone number does exist return false end else -- number is too high, ignore return false else return createPhone( ) end return number -- we don't want to return the MySQL error if that failed end
-
The error is at line 4 'end' expected
-- we need to export a function to generate a new (unused) phone number, really function createPhone( number ) if not number then number = exports.sql:query_insertid( "INSERT INTO phones VALUES ()" ); else -- we create a row for the one that didn't exist yet but where we have the number for. while true do attempts = attempts + 1 number = math.random(311111, attempts < 20 and 899999 or 8999999) -- no current phones OR the new phone number is the new max. end return createPhone( ) -- we have a phone number that's below the maximum if not exports.sql:query_free( "INSERT INTO phones (phoneNumber) VALUES (" .. number .. ")" ) then -- if this fails, the phone number does exist return false end else -- number is too high, ignore return false else return createPhone( ) end return number -- we don't want to return the MySQL error if that failed end
-
Hello, i need make this scipt to work like, i have 2 routes and need make to server choose in random routes. I tryed but didnt worked
server
local vehicles = get( "vehicles" ) or { "Bus" } -- load the civilian vehicles that'll automatically trigger the delivery mission if being entered local max_earnings = tonumber( get( "earnings" ) ) or 7 local delay = tonumber( get( "delay" ) ) or 5 -- put it in a for us better format local vehicles2 = { } for key, value in ipairs( vehicles ) do local model = getVehicleModelFromName( value ) if model then vehicles2[ model ] = true else outputDebugString( "Vehicle '" .. tostring( value ) .. " does not exist." ) end end vehicles = vehicles2 vehicles2 = nil local function isJobVehicle( vehicle ) return vehicle and vehicles[ getElementModel( vehicle ) ] and not exports.vehicles:getOwner( vehicle ) or false end -- local p = { } local function advanceRoute( player, earnings ) if p[ player ] and p[ player ].route and p[ player ].checkpoint then local cp = p[ player ].checkpoint + 1 local c = p[ player ].route[ cp ] local n = p[ player ].route[ cp + 1 ] if c then if p[ player ].route[ p[ player ].checkpoint ] then if p[ player ].route[ p[ player ].checkpoint ].stop and earnings and earnings > 0 then exports.players:giveMoney( player, earnings ) end if p[ player ].route[ p[ player ].checkpoint ].hint then triggerClientEvent( player, "gui:hint", player, "Darbs: Autobusa vadītājs", p[ player ].route[ p[ player ].checkpoint ].hint ) end end if not n then -- last checkpoint triggerClientEvent( player, getResourceName( resource ) .. ":set", player, c.x, c.y, c.z, c.stop and true ) else triggerClientEvent( player, getResourceName( resource ) .. ":set", player, c.x, c.y, c.z, c.stop and true, n.x, n.y, n.z, n.stop and true ) end else if earnings then exports.players:giveMoney( player, earnings * 3 ) end triggerClientEvent( player, getResourceName( resource ) .. ":set", player ) p[ player ] = nil return false end p[ player ].checkpoint = cp return true end end local function newRoute( player ) p[ player ].vehicleOnResourceStart = nil local route = math.random( #routes ) p[ player ].route = routes[ route ] p[ player ].checkpoint = 0 advanceRoute( player ) end addEventHandler( "onVehicleEnter", root, function( player, seat ) if seat == 0 and isJobVehicle( source ) then if not p[ player ] then p[ player ] = { } end if not p[ player ].route then newRoute( player ) else triggerClientEvent( player, getResourceName( resource ) .. ":show", player ) end end end ) -- addEventHandler( "onResourceStart", resourceRoot, function( ) if not routes or routes == 0 then cancelEvent( ) return end -- setElementData( resourceRoot, "delay", delay ) -- for key, value in ipairs( getElementsByType( "player" ) ) do local vehicle = getPedOccupiedVehicle( value ) if vehicle and getPedOccupiedVehicleSeat( value ) == 0 and isJobVehicle( vehicle ) then p[ value ] = { vehicleOnResourceStart = vehicle } end end setTimer( function( ) for key, value in pairs( p ) do p[ key ].vehicleOnResourceStart = nil end end, 10000, 1 ) end ) addEvent( getResourceName( resource ) .. ":ready", true ) addEventHandler( getResourceName( resource ) .. ":ready", root, function( ) if source == client then if p[ source ] and getPedOccupiedVehicle( source ) == p[ source ].vehicleOnResourceStart and getPedOccupiedVehicleSeat( source ) == 0 then newRoute( source ) end end end ) -- addEvent( getResourceName( resource ) .. ":complete", true ) addEventHandler( getResourceName( resource ) .. ":complete", root, function( ) if source == client then local vehicle = getPedOccupiedVehicle( source ) if p[ source ] and p[ source ].route and isJobVehicle( vehicle ) and getPedOccupiedVehicleSeat( source ) == 0 then -- distance check if not p[ source ].route[ p[ source ].checkpoint ].stop or getDistanceBetweenPoints2D( p[ source ].route[ p[ source ].checkpoint ].x, p[ source ].route[ p[ source ].checkpoint ].y, getElementPosition( vehicle ) ) < 5 then local health = math.min( 1000, getElementHealth( vehicle ) ) if health > 350 then -- calculate earnings based on vehicle health local earnings = p[ source ].route[ p[ source ].checkpoint ].stop and math.ceil( ( health - 350 ) / 650 * max_earnings ) or 0 -- get a checkpoint advanceRoute( source, earnings ) end end end end end ) addEventHandler( "onCharacterLogout", root, function( ) if p[ source ] and p[ source ].route then triggerClientEvent( source, getResourceName( resource ) .. ":set", source ) end p[ source ] = nil end ) addEventHandler( "onPlayerQuit", root, function( ) p[ source ] = nil end ) -- addEventHandler( "onVehicleStartEnter", root, function( player, seat ) if seat == 0 and isJobVehicle( source ) and "job-" .. tostring( exports.players:getJob( player ) ) ~= getResourceName( resource ) then outputChatBox( "((Jūs varat dabūt šo darbu domē. ))", player, 255, 0, 0 ) cancelEvent( ) end end ) -- function introduce( player ) triggerClientEvent( player, getResourceName( resource ) .. ":introduce", player ) end
client
local localPlayer = getLocalPlayer( ) local position = nil local marker = nil local blip = nil local blip2 = nil local wait = false local screenX, screenY = guiGetScreenSize( ) function drawWaitingText( ) -- check if we still need to wait local vehicle = getPedOccupiedVehicle( localPlayer ) if vehicle then if getElementHealth( vehicle ) <= 350 then text = "Salabo transportlīdzekli!" elseif wait and wait ~= 0 then local diff = wait - getTickCount( ) if diff >= 0 then text = ( "Lūudzu uzgaidi %.1f sekundes" ):format( diff / 1000 ) else triggerServerEvent( getResourceName( resource ) .. ":complete", localPlayer ) wait = 0 end end -- draw the text dxDrawText( text, 4, 4, screenX, screenY, tocolor( 0, 0, 0, 255 ), 1, "pricedown", "center", "center" ) dxDrawText( text, 0, 0, screenX, screenY, tocolor( 255, 255, 255, 255 ), 1, "pricedown", "center", "center" ) end end -- local function hide( ) if isElement( blip ) then destroyElement( blip ) end blip = nil if isElement( blip2 ) then destroyElement( blip2 ) end blip2 = nil if isElement( marker ) then destroyElement( marker ) end marker = nil if wait then wait = false removeEventHandler( "onClientRender", root, drawWaitingText ) end end local function show( ) hide( ) if position then -- in lack of a more detailed close-location (aka we use the entrance), use large markers marker = createMarker( position.x, position.y, position.z, "checkpoint", 3, position.stop and 0 or 255, 255, 0, 63 ) if marker then blip = createBlipAttachedTo( marker, 0, 2, position.stop and 0 or 255, 255, 0, 255 ) end if position.nx and position.ny and position.nz then blip2 = createBlip( position.nx, position.ny, position.nz, 0, 1, position.nstop and 0 or 255, 255, 0, 255 ) end end end addEvent( getResourceName( resource ) .. ":show", true ) addEventHandler( getResourceName( resource ) .. ":show", localPlayer, show ) addEvent( getResourceName( resource ) .. ":set", true ) addEventHandler( getResourceName( resource ) .. ":set", localPlayer, function( x, y, z, stop, nx, ny, nz, nstop ) if x and y and z then position = { x = x, y = y, z = z, stop = stop, nx = nx, ny = ny, nz = nz, nstop = nstop } show( ) else position = nil hide( ) end end ) addEventHandler( "onClientPlayerVehicleExit", localPlayer, hide ) addEventHandler( "onClientResourceStart", resourceRoot, function( ) triggerServerEvent( getResourceName( resource ) .. ":ready", localPlayer ) end ) addEventHandler( "onClientMarkerHit", resourceRoot, function( element, matching ) if matching and element == localPlayer then if position.stop then if not wait then wait = getTickCount( ) + getElementData( resourceRoot, "delay" ) * 1000 addEventHandler( "onClientRender", root, drawWaitingText ) end else triggerServerEvent( getResourceName( resource ) .. ":complete", localPlayer ) end end end ) addEventHandler( "onClientMarkerLeave", resourceRoot, function( element, matching ) if matching and element == localPlayer then wait = false removeEventHandler( "onClientRender", root, drawWaitingText ) exports.gui:hint( "Darbs: autobusa vadītājs", "Ne tik ātri, visi vadītāji steidzas, bet tomēr jums vajadzētu apstāties pieturā un pagaidit kamēr visi iekāps, labi?", 3 ) end end )
routes
routes = { { points = { { x=1786.4242, y=-1826.6605, z=13.2578, stop = true, hint = "Tas ir vienkārši, Sekojiet maršrutam līdz sasniegsiet pieturu." }, -- Line B - Unity Station { x=1692.6863, y=-1786.1617, z=13.2578 }, { x=1622.8982, y=-1729.7705, z=13.2578 }, { x=1511.22, y=-1730.45, z=13.38, hint = "Piebremzē! Šeit ir pietura, jums vajag mazliet uzgaidīt pieturā. Ja kāds pasažieris iekāps jūs saņemsiet vēl papildus naudu." }, { x=1479.47, y=-1730.19, z=13.43, stop = true }, -- Line B - Dome { x=1386.1307, y=-1790.0061, z=13.2578 }, { x=1315.9840, y=-1813.5928, z=13.2578, stop = true }, -- Line B - DMV Parking lot { x=1314.8202, y=-1612.5717, z=13.2578 }, { x=1311.2075, y=-1393.3401, z=13.1649 }, { x=1172.6312, y=-1391.6152, z=13.2680, stop = true }, -- Line B - Verona Mall & All Saints Hospital { x=1094.3251, y=-1397.5109, z=13.3907 }, { x=1051.4287, y=-1478.5181, z=13.2604 }, { x=945.8153, y=-1569.5757, z=13.2599 }, { x=851.2404, y=-1594.5028, z=13.2656, stop = true }, -- Line B - The Book Emporium, Panopticom Street { x=807.7176, y=-1710.5044, z=13.2578 }, { x=721.8978, y=-1752.9287, z=14.3011 }, { x=497.7910, y=-1713.9375, z=11.7183 }, { x=389.0097, y=-1769.4656, z=5.2738 }, { x=279.3954, y=-1731.9656, z=3.8864 }, { x=166.9234, y=-1732.3812, z=4.3330, stop = true }, -- Line B - Marina { x=129.8073, y=-1590.6311, z=10.6169 }, { x=250.6921, y=-1441.2704, z=13.3181 }, { x=430.0234, y=-1340.8903, z=14.7877 }, { x=566.9686, y=-1243.5836, z=17.1045, stop = true }, -- Line B - LS Bank & Grotti Cars { x=694.3098, y=-1159.7479, z=15.2229 }, { x=793.1010, y=-1087.7249, z=24.2165 }, { x=914.3346, y=-1150.2599, z=23.6295 }, { x=966.4662, y=-1109.5269, z=23.5672, stop = true }, -- Line B - Cemetery, Chinatown { x=1014.1530, y=-1041.9336, z=31.3178 }, { x=1087.7499, y=-985.4448, z=39.8135 }, { x=1123.4528, y=-959.4127, z=42.4109, stop = true }, -- Line B - Towing Company, Vinewood { x=1247.4594, y=-940.7812, z=42.3700 }, { x=1359.0907, y=-962.5912, z=33.5578 }, { x=1338.9242, y=-1257.6052, z=13.2578, stop = true }, -- Line B - Ammunation, St Lawrence Boulevard { x=1378.0623, y=-1408.4714, z=13.2625 }, { x=1446.7334, y=-1488.1488, z=13.2474 }, { x=1491.1194, y=-1595.8290, z=13.2578, stop = true },-- Line B - Pershing Square { x=1641.6776, y=-1595.0366, z=13.3093 }, { x=1824.8560, y=-1589.3691, z=13.2342, stop = true }, -- Line B - Los Santos Prison { x=1853.2986, y=-1435.3317, z=13.2694 }, { x=1898.0497, y=-1263.3184, z=13.2656 }, { x=1997.3551, y=-1263.7026, z=23.6953, stop = true }, -- Line B - Glen Park { x=2073.4783, y=-1153.3698, z=23.5872 }, { x=2156.9390, y=-1120.7407, z=25.2352, stop = true }, -- Line B - Jefferson { x=2275.7930, y=-1150.2113, z=26.6136 }, -- Line B - Checkpoint { x=2367.9003, y=-1198.2988, z=27.4296 }, { x=2424.5244, y=-1259.7255, z=23.8313, stop = true }, -- Line B - Pig Pen, Little Moscow { x=2545.7128, y=-1259.2089, z=41.5131 }, { x=2671.6074, y=-1259.0888, z=52.7319 }, { x=2720.1142, y=-1343.4140, z=46.0086 }, { x=2720.3349, y=-1483.5966, z=30.2812, stop = true }, -- Line B - LST&R { x=2679.4746, y=-1456.6191, z=30.3829 }, { x=2580.1777, y=-1441.6611, z=34.7777 }, { x=2393.9287, y=-1418.9638, z=23.8359 }, { x=2339.9394, y=-1431.5703, z=23.8281 }, { x=2339.8457, y=-1608.7333, z=21.4545 }, { x=2293.0876, y=-1655.1001, z=14.6454, stop = true }, -- Line B - Ten Green Bottles { x=2213.9907, y=-1721.2064, z=13.2413 }, { x=2114.6150, y=-1749.9012, z=13.2812 }, { x=1922.5245, y=-1748.6918, z=13.2578, stop = true }, -- Line B - Idlewood Gas { x=1817.8397, y=-1803.7924, z=13.0905, stop = true } -- Line B - Unity Station (End Of service) } }, { points = { { x=1825.5222, y=-1819.0747, z=13.4037, stop = true }, -- LineA - Unity Station { x=1847.2609, y=-1754.3463, z=13.3751 }, { x=1922.6714, y=-1755.9180, z=13.3752, stop = true}, -- LineA - Idlewood Gas } } }
enter in car
in Scripting
Posted · Edited by Guest
thanks, another problem how to not equal on line 5 ?