OskarYT
Mapper MTA
Wiek: 26 Na forum: 4245 dni Posty: 267
Nick w MP: Kaczorek2306
Piwa : 1230
Digital = dxCreateFont ( "Digital.ttf" , 21 ) -- Custom font
local x , y = guiGetScreenSize () -- getScreenSize
local czas = getTickCount ()
isBike = {
[ 509 ]= true , -- Bike
[ 481 ]= true , -- BMX
[ 510 ]= true , -- Mountain bike
}
function naliczPrzebieg ( pojazd )
if getTickCount () - czas > 150 then
czas = getTickCount ()
local przebieg = getElementData ( pojazd , "przebieg" ) or 0
local vx , vy , vz = getElementVelocity ( pojazd )
local spd = (( vx ^ 2 + vy ^ 2 + vz ^ 2 )^( 0.5 )/ 100 )
if spd > 0 then
przebieg = przebieg + spd * 2
setElementData ( pojazd , "przebieg" , przebieg )
end
end
end
addEventHandler ( "onClientRender" , root , function()
local pojazd = getPedOccupiedVehicle ( localPlayer )
if not pojazd then return end
if isBike [ getElementModel ( pojazd )] then return end
if not getVehicleEngineState ( pojazd ) then return end
if getVehicleController ( pojazd ) ~= localPlayer then return end
naliczPrzebieg ( pojazd )
end )
czas2 = getTickCount ()
function naliczPaliwo ( pojazd )
if getTickCount () - czas2 > 150 then
czas2 = getTickCount ()
local paliwo = getElementData ( pojazd , "fuel" ) or 0
local vx , vy , vz = getElementVelocity ( pojazd )
local spd = (( vx ^ 2 + vy ^ 2 + vz ^ 2 )^( 0.5 )/ 500 )
if spd > 0 then
paliwo = paliwo - spd
setElementData ( pojazd , "fuel" , paliwo )
end
end
end
addEventHandler ( "onClientRender" , root , function()
local pojazd = getPedOccupiedVehicle ( localPlayer )
if not pojazd then return end
if isBike [ getElementModel ( pojazd )] then return end
if not getVehicleEngineState ( pojazd ) then return end
if getVehicleController ( pojazd ) ~= localPlayer then return end
naliczPaliwo ( pojazd )
end )
function speed ( )
addEventHandler ( "onClientRender" , root , getspeed )
end
addEventHandler ( "onClientVehicleEnter" , root , speed )
function hideSpeed ( )
removeEventHandler ( "onClientRender" , root , getspeed )
end
addEventHandler ( "onClientVehicleExit" , root , hideSpeed )
function hud ( )
local veh = getPedOccupiedVehicle ( localPlayer )
if ( veh ) then
if isPedInVehicle ( localPlayer ) == false then return end
local sx , sy , sz = getElementVelocity ( getPedOccupiedVehicle ( localPlayer ))
local kmhs = math . ceil ((( sx ^ 2 + sy ^ 2 + sz ^ 2 )^( 0.5 )) * 161 )
local paliwo2 = math . floor ( getElementData ( veh , "fuel" )) -- math . floor usuwa liczby po przecinku zeby nie by ? y one widoczne na ekranie
local przebieg = math . floor ( getElementData ( veh , "przebieg" ))
dxDrawText ( "" .. kmhs .. "" , x * 0.0125 , y * 0.800 , x * 0.9520 , y * 0.606667005 , tocolor ( 255 , 102 , 0 , 255 ), 1.3 , Digital , "right" , "top" , false , false , false )
dxDrawText ( "km/h" , x * 0.95 , y * 0.810 , x * 295.0 , y * 335.0 , tocolor ( 255 , 102 , 0 , 255 ), 1.4 , "default-bold" , "left" , "top" , false , false , false )
dxDrawText ( "Przebieg:" , x * 0.65 , y * 0.860 , x * 295.0 , y * 335.0 , tocolor ( 255 , 102 , 0 , 255 ), 1.4 , "default-bold" , "left" , "top" , false , false , false )
dxDrawText ( "" .. przebieg .. "km" , x * 0.75 , y * 0.860 , x * 295.0 , y * 335.0 , tocolor ( 255 , 102 , 0 , 255 ), 1.4 , "default-bold" , "left" , "top" , false , false , false )
dxDrawText ( "Paliwo:" , x * 0.65 , y * 0.910 , x * 295.0 , y * 335.0 , tocolor ( 255 , 102 , 0 , 255 ), 1.4 , "default-bold" , "left" , "top" , false , false , false )
dxDrawText ( "" .. paliwo2 .. "/100" , x * 0.75 , y * 0.910 , x * 295.0 , y * 335.0 , tocolor ( 255 , 102 , 0 , 255 ), 1.4 , "default-bold" , "left" , "top" , false , false , false )
end
end
addEventHandler ( "onClientRender" , getRootElement (), hud )
Mam licznik pr?dko?ci ale jak wejd? do sklepu z autami i kupie pojazd to jak mnie przeteleportuje do niego to mi wyskakuje ERROR wygl?da on tak:
ERROR: licznik-predkosci\c-licznik.lua:75: bad argument #1 to floor (number expected, got boolean)
Linijka 75:
local paliwo2 = math . floor ( getElementData ( veh , "fuel" ))
a to kod na kupno pojazd?w :
local salonowePojazdy = {}
-- wzor : salonowePojazdy [ id_pojazdu ] = cena
salonowePojazdy [ 404 ] = 1500 -- perek
salonowePojazdy [ 410 ] = 1750 -- manana
salonowePojazdy [ 418 ] = 2040 -- Moonbeam
salonowePojazdy [ 600 ] = 2500 -- Picador
salonowePojazdy [ 543 ] = 2750 -- Sadler
salonowePojazdy [ 478 ] = 2980 -- Walton
salonowePojazdy [ 549 ] = 3441 -- Tampa
salonowePojazdy [ 540 ] = 3944 -- Vincent
salonowePojazdy [ 527 ] = 4500 -- Cadrona
salonowePojazdy [ 547 ] = 5000 -- Primo
salonowePojazdy [ 526 ] = 5320 -- Fortune
salonowePojazdy [ 492 ] = 5780 -- Greenwood
salonowePojazdy [ 517 ] = 6452 -- Majestic
salonowePojazdy [ 405 ] = 7500 -- Sentinel
salonowePojazdy [ 400 ] = 8120 -- Landstalker
salonowePojazdy [ 500 ] = 8992 -- Mesa
salonowePojazdy [ 542 ] = 9750 -- Clover
-- Od 10K
salonowePojazdy [ 555 ] = 13899 -- Windsor
salonowePojazdy [ 561 ] = 14500 -- Stratum
salonowePojazdy [ 533 ] = 15210 -- Feltzer
salonowePojazdy [ 579 ] = 19234 -- Huntley
salonowePojazdy [ 495 ] = 23400 -- Sandking
salonowePojazdy [ 475 ] = 24000 -- Primo
salonowePojazdy [ 426 ] = 5800 -- Premier
salonowePojazdy [ 566 ] = 26615 -- Tahoma
salonowePojazdy [ 576 ] = 27899 -- Torando
salonowePojazdy [ 562 ] = 27912 -- Elegy
salonowePojazdy [ 536 ] = 29455 -- Blade
salonowePojazdy [ 439 ] = 30222 -- Stallion
salonowePojazdy [ 567 ] = 31233 -- Savanna
salonowePojazdy [ 534 ] = 32000 -- Remington
salonowePojazdy [ 535 ] = 35415 -- Slamvan
salonowePojazdy [ 575 ] = 36989 -- Broadway
salonowePojazdy [ 580 ] = 39450 -- Stafford
salonowePojazdy [ 474 ] = 45750 -- Hermes
-- SPORTOWE
salonowePojazdy [ 496 ] = 50140 -- Blista Compact
salonowePojazdy [ 565 ] = 55400 -- Flash
salonowePojazdy [ 603 ] = 61200 -- Phoenix
salonowePojazdy [ 415 ] = 65188 -- Cheetah
salonowePojazdy [ 558 ] = 68991 -- Uranus
salonowePojazdy [ 506 ] = 72344 -- Super GT
salonowePojazdy [ 602 ] = 73455 -- Alpha
salonowePojazdy [ 429 ] = 78112 -- Banshee
salonowePojazdy [ 402 ] = 81234 -- Buffalo
salonowePojazdy [ 587 ] = 82347 -- Euros
salonowePojazdy [ 541 ] = 89400 -- Bullet
salonowePojazdy [ 559 ] = 90001 -- Jester
salonowePojazdy [ 451 ] = 95800 -- Turismo
salonowePojazdy [ 477 ] = 99900 -- ZR - 350
-- Od 1 MLN
salonowePojazdy [ 411 ] = 101233 -- Infernus
salonowePojazdy [ 434 ] = 123444 -- Hotknife
salonowePojazdy [ 545 ] = 145000 -- Hustler
-- Motory
salonowePojazdy [ 462 ] = 1000 -- Faggio
salonowePojazdy [ 461 ] = 3400 -- PCJ - 600
salonowePojazdy [ 581 ] = 8500 -- BF - 400
salonowePojazdy [ 521 ] = 9899 -- FCR900
salonowePojazdy [ 463 ] = 14500 -- Freeway
salonowePojazdy [ 586 ] = 25000 -- Wayfarer
salonowePojazdy [ 571 ] = 23000 -- Quad
salonowePojazdy [ 522 ] = 34520 -- NRG - 500
local salon = createMarker (- 198.0087890625 , 1163.58984375 , 19.59375 - 0.9 , "cylinder" , 1 , 255 , 0 , 0 , 100 )
function onSalonHit ( hitElement , dim )
if getElementType ( hitElement ) == "player" then
triggerClientEvent ( hitElement , "pokazGUISalonu" , root , salonowePojazdy )
end
end
addEventHandler ( "onMarkerHit" , salon , onSalonHit )
addEvent ( "kupPojazdSalon" , true )
addEventHandler ( "kupPojazdSalon" , getRootElement (),
function( id )
local cena = salonowePojazdy [ id ]
if cena then
if getPlayerMoney ( source ) >= cena then
local account = getPlayerAccount ( source )
if account then
local wlasciciel = getAccountName ( account )
if 5 >= getYourVehicleCount ( wlasciciel ) then
takePlayerMoney ( source , cena )
triggerClientEvent ( source , "potwierdzKupnoPojazduPrywatnego" , root )
fadeCamera ( source , false )
setTimer (function( source )
local x , y , z , rot = - 1987.46 , 276.18 , 34.86 , 270
local veh = createVehicle ( id , x , y , z )
setElementData ( pojazd , "fuel" , 50 ) -- na specjalna prosbe ;)
setElementData ( pojazd , "przebieg" , 0 )
local r , g , b = getVehicleColor ( veh , true )
fadeCamera ( source , true )
--<<-->>
local query = dbQuery ( handler , "INSERT INTO pojazdy (wlasciciel, model, x, y, z, rot, ca, cb, cc, przebieg, paliwo) VALUES (?, ?, ?, ?, ?, ?,?,?,?,?,?)" , wlasciciel , id , x , y , z , rot , r , g , b , 50 , 0 )
local result , num_affected_rows , last_insert_id = dbPoll ( query , - 1 )
local r , g , b = getVehicleHeadLightColor ( veh )
dbExec ( handler , "INSERT INTO tuning (id, t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, paintjob, hr, hg, hb) VALUES (?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)" , last_insert_id , "0" , "0" , "0" , "0" , "0" , "0" , "0" , "0" , "0" , "0" , "0" , "0" , "0" , "0" , "0" , "0" , "0" , "3" , r , g , b )
--<<-->>
setElementRotation ( veh , 0 , 0 , rot )
ustawDanePojazdu ( veh , last_insert_id , wlasciciel )
warpPedIntoVehicle ( source , veh )
end , 1500 , 1 , source )
else
outputChatBox ( "Mo?esz posiada? maksymalnie 5 pojazd?w." , source , 255 , 255 , 255 , true )
end
end
else
outputChatBox ( "Potrzebujesz " .. cena .. "$ by kupi? ten pojazd." , source , 255 , 255 , 255 , true )
end
end
end )
-- komenda tworzaca
function stworzPojazdCMD ( player , cmd , id , wlasciciel )
local acc = getAccountName ( getPlayerAccount ( player ))
if acc then
if isObjectInACLGroup ( "user." .. acc , aclGetGroup ( "Admin" )) then
if id and wlasciciel then
local id = tonumber ( id )
if id then
if getVehicleNameFromModel ( id ) then
local x , y , z = getElementPosition ( player )
local _ , _ , rot = getElementRotation ( player )
local veh = createVehicle ( id , x , y , z )
if veh then
setElementData ( pojazd , "fuel" , 50 ) -- na specjalna prosbe ;)
setElementData ( pojazd , "przebieg" , 0 )
local r , g , b = getVehicleColor ( veh , true )
--<<-->>
local query = dbQuery ( handler , "INSERT INTO pojazdy (wlasciciel, model, x, y, z, rot, ca, cb, cc, przebieg, paliwo) VALUES (?, ?, ?, ?, ?, ?,?,?,?,?,?)" , wlasciciel , id , x , y , z , rot , r , g , b , 50 , 0 )
local result , num_affected_rows , last_insert_id = dbPoll ( query , - 1 )
local r , g , b = getVehicleHeadLightColor ( veh )
dbExec ( handler , "INSERT INTO tuning (id, t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, paintjob, hr, hg, hb) VALUES (?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)" , last_insert_id , "0" , "0" , "0" , "0" , "0" , "0" , "0" , "0" , "0" , "0" , "0" , "0" , "0" , "0" , "0" , "0" , "0" , "3" , r , g , b )
--<<-->>
setElementRotation ( veh , 0 , 0 , rot )
ustawDanePojazdu ( veh , last_insert_id , wlasciciel )
else
outputChatBox ( "Podane ID jest niepoprawne." , player , 255 , 255 , 255 , true )
end
else
outputChatBox ( "Podane ID jest niepoprawne." , player , 255 , 255 , 255 , true )
end
end
else
outputChatBox ( "Wpisz /stworz [id-pojazdu] [wlasciciel]" , player , 255 , 255 , 255 , true )
end
end
end
end
addCommandHandler ( "stworz" , stworzPojazdCMD )