Wysłany: 2016-06-11, 16:49
Aski
Wiek: 30 Na forum: 4123 dni Posty: 10
Witam mam ma?y problem a mianowicie chcia? bym aby pojazd o ID wyznaczonym wje?d?aj?c w ostatni marker o numerze [22], niszczy? pojazd.
local rootElement = getRootElement ()
local busses = {[ 431 ] = true , [ 437 ] = true }
local busTable = {
[ 1 ]={- 2090.950 , 1277.275 , 14.45 },[ 2 ]={- 2289.29980 , 1179.61316 , 54.51567 },[ 3 ]={- 2477.30005 , 1200.80847 , 36.08991 },[ 4 ]={- 2661.65088 , 1173.08032 , 55.85931 },[ 5 ]={- 2458.84766 , 1089.95142 , 56.03101 },
[ 6 ]={- 2279.13623 , 1051.48096 , 55.98920 },[ 7 ]={- 2006.67566 , 1027.52869 , 56.00063 },[ 8 ]={- 2007.32776 , 819.93933 , 45.71822 },[ 9 ]={- 2006.00781 , 575.79053 , 35.46132 },[ 10 ]={- 2108.33936 , 568.45959 , 35.45186 },
[ 11 ]={- 2228.92725 , 548.65088 , 35.44595 },[ 12 ]={- 2235.86646 , 447.24005 , 35.41224 },[ 13 ]={- 2256.37109 , 348.16998 , 33.39291 },[ 14 ]={- 2236.14771 , 318.40176 , 35.60799 },[ 15 ]={- 2018.66406 , 318.24945 , 35.44624 },
[ 16 ]={- 1926.19385 , 340.26917 , 31.87311 },[ 17 ]={- 1846.91760 , 403.69186 , 17.43918 },[ 18 ]={- 1726.76489 , 323.27530 , 7.46830 },[ 19 ]={- 1548.17590 , 718.31506 , 7.47321 },[ 20 ]={- 1525.62781 , 908.49677 , 7.47321 },
[ 21 ]={- 1637.18433 , 1253.72144 , 7.46522 },[ 22 ]={- 1988.39563 , 1312.31409 , 7.48742 },}
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 bustpr ( thePlayer )
local theVehicle = getPedOccupiedVehicle ( thePlayer )
local id = getElementModel ( theVehicle )
if id == 431 or id == 437 then
local x , y , z = getNewBusLocation ( thePlayer , 1 )
setElementData ( thePlayer , "buszp" , 0 )
setElementData ( thePlayer , "busData" , 1 )
else
end
end
addEventHandler ( "onVehicleEnter" , rootElement , bustpr )
function busStart ( thePlayer )
local theVehicle = getPedOccupiedVehicle ( thePlayer )
local id = getElementModel ( theVehicle )
if id == 431 or id == 437 then
outputChatBox ( "Zaczynasz prac? kierow!cy Bus/Tpr" , 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 437 then
local gpm = getElementData ( thePlayer , "buszp" )
if (( gpm ) > 0 ) then
givePlayerMoney ( thePlayer , tonumber ( gpm ))
outputChatBox ( "Za ten przejazd zarobi?e?: " .. gpm .. "$" , thePlayer , 0 , 140 , 240 )
setElementData ( thePlayer , "buszp" , 0 )
end
end
end
addEventHandler ( "onVehicleExit" , rootElement , giveMoney )
addEventHandler ( "onPlayerQuit" , rootElement , giveMoney )
Wysłany: 2016-06-11, 22:20
Jurandovsky
Kurdebele
Wiek: 17 Na forum: 4838 dni Posty: 915
Piwa : 2697
Dodaj w evencie onMarkerHit czy tam onClientMarkerHit, zale?y na kt?rej stronie to robisz
if getElementData(plejer, "busData") == 22 then
destroyElement(getPedOccupiedVehicle(plejer))
end
Podpis
Jedyny kontakt ze mną to PW forum
Kod:
local noobs = getElementsByTitle("player", "Programista LUA")
for k, v in ipairs(noobs) do
outputChatBox("Bez mózgu jest użytkownik o nicku: "..getPlayerName(v), root)
destroyElement(v)
end
Wysłany: 2016-06-12, 17:26
Aski
Wiek: 30 Na forum: 4123 dni Posty: 10
TAK>?
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 )
if getElementData ( plejer , "busData" ) == 22 then
destroyElement ( getPedOccupiedVehicle ( player ))
end
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 )
Tagi: kończący :: marker :: destroyveh
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: