Wysłany: 2020-04-29, 01:37
HEATEX
Wiek: 25 Na forum: 2250 dni Posty: 109
Nick w MP: HEATEX
Piwa : 1336
Witam chcialbym zrobic tak aby pobieralo hajs z banku zamiast z gotowki w skrypcie na mk
s.lua
elements = {}
elements [ "positions" ] = {
[ "EZ 1" ]={
marker = { 1249.42 , - 1824.18 , 13.41 },
cuboid = { 1249.42 , - 1824.18 , 13.41 , 5 },
text = "Monta? wzmocnie?"
}
}
local napis = createElement ( "text" )
setElementData ( napis , "name" , "Dost?pne ulepszenia\n(brak mo?liwo??i demonta?u)\n\nUlepszenie silnika - 50kk\nUlepszenie silnika - 99kk\nNitro sta?e - 90kk" )
setElementPosition ( napis , 1249.42 , - 1824.18 , 13.5 )
for i , v in pairs ( elements [ "positions" ]) do
v . cuboid = ColShape . Sphere ( unpack ( v . cuboid ))
v . marker = Marker ( v . marker [ 1 ], v . marker [ 2 ], v . marker [ 3 ]- 0.90 , "cylinder" , 3 , 32 , 64 , 128 , 50 )
end
addEvent ( "mk1" , true )
addEventHandler ( "mk1" , getRootElement (), function()
local hajs = getPlayerMoney ( source )
local ccar = getPedOccupiedVehicle ( source )
local cena = 50000000
if getElementData ( ccar , "vehicle:ownedPlayer" ) == getElementData ( client , "player:sid" ) then
if hajs < cena then triggerClientEvent ( client , "onClientAddNotification" , client , "Nie sta? Ci? aby zakupi? to ulepszenie!" , "error" ) return end
local id = getElementData ( ccar , "vehicle:id" )
if not id then triggerClientEvent ( client , "onClientAddNotification" , client , "To nie jest pojazd prywatny!" , "error" ) return end
local qr = exports [ 'pystories-db' ]: dbGet ( "SELECT * FROM pystories_vehicles WHERE id=? AND mk1=?" , getElementData ( ccar , "vehicle:id" ), "1" )
if #qr == 1 then triggerClientEvent(client, "onClientAddNotification", client, "Posiadasz ju? to ulepszenie!", "error") return end
exports [ "pystories-vehicles" ]: onSaveVehicle ( ccar )
destroyElement ( ccar )
exports [ "pystories-db" ]: dbSet ( "UPDATE pystories_vehicles SET parking=1,tp_to_parking=? WHERE id=?" , "Eazy Workshop - US1" , id )
exports [ "pystories-db" ]: dbSet ( "UPDATE pystories_vehicles SET mk1=1 WHERE id=?" , id )
triggerClientEvent ( client , "onClientAddNotification" , client , "Pomy?lnie zamontowano \n'Ulepszenie Silnika (poz. 1)" , "success" )
takePlayerMoney ( source , cena )
exports [ "pystories-db" ]: dbSet ( "update ez_logi set ile=ile+1 where usluga=? limit 1" , "us1" )
else
triggerClientEvent ( client , "onClientAddNotification" , client , "To nie jest Tw?j pojazd!" , "warning" )
end
end )
addEvent ( "mk2" , true )
addEventHandler ( "mk2" , getRootElement (), function()
local hajs = getPlayerMoney ( source )
local ccar = getPedOccupiedVehicle ( source )
local cena = 99000000
if getElementData ( ccar , "vehicle:ownedPlayer" ) == getElementData ( client , "player:sid" ) then
if hajs < cena then triggerClientEvent ( client , "onClientAddNotification" , client , "Nie sta? Ci? aby zakupi? to ulepszenie!" , "error" ) return end
local id = getElementData ( ccar , "vehicle:id" )
if not id then triggerClientEvent ( client , "onClientAddNotification" , client , "To nie jest pojazd prywatny!" , "error" ) return end
local qr = exports [ 'pystories-db' ]: dbGet ( "SELECT * FROM pystories_vehicles WHERE id=? AND mk2=?" , getElementData ( ccar , "vehicle:id" ), "1" )
if #qr == 1 then triggerClientEvent(client, "onClientAddNotification", client, "Posiadasz ju? to ulepszenie!", "error") return end
exports [ "pystories-vehicles" ]: onSaveVehicle ( ccar )
destroyElement ( ccar )
exports [ "pystories-db" ]: dbSet ( "UPDATE pystories_vehicles SET parking=1,tp_to_parking=? WHERE id=?" , "Eazy Workshop - US2" , id )
exports [ "pystories-db" ]: dbSet ( "UPDATE pystories_vehicles SET mk2=1 WHERE id=?" , id )
triggerClientEvent ( client , "onClientAddNotification" , client , "Pomy?lnie zamontowano 'Ulepszenie Silnika (poz. 2)'" , "success" )
takePlayerMoney ( source , cena )
exports [ "pystories-db" ]: dbSet ( "update ez_logi set ile=ile+1 where usluga=? limit 1" , "us2" )
else
triggerClientEvent ( client , "onClientAddNotification" , client , "To nie jest Tw?j pojazd!" , "warning" )
end
end )
addEvent ( "nitro" , true )
addEventHandler ( "nitro" , getRootElement (), function()
local hajs = getPlayerMoney ( source )
local ccar = getPedOccupiedVehicle ( source )
local tuning = getVehicleUpgradeOnSlot ( ccar , 8 )
local cena = 90000000
if getElementData ( ccar , "vehicle:ownedPlayer" ) == getElementData ( client , "player:sid" ) then
if tuning == 1010 then triggerClientEvent ( client , "onClientAddNotification" , client , "Posiadasz ju? nitro!" , "error" ) return end
if hajs < cena then triggerClientEvent ( client , "onClientAddNotification" , client , "Nie sta? Ci? aby zakupi? to ulepszenie!" , "error" ) return end
local id = getElementData ( ccar , "vehicle:id" )
if not id then triggerClientEvent ( client , "onClientAddNotification" , client , "To nie jest pojazd prywatny!" , "error" ) return end
addVehicleUpgrade ( ccar , 1010 )
takePlayerMoney ( source , cena )
exports [ "pystories-db" ]: dbSet ( "update ez_logi set ile=ile+1 where usluga=? limit 1" , "nitro" )
else
triggerClientEvent ( client , "onClientAddNotification" , client , "To nie jest Tw?j pojazd!" , "warning" )
end
end )
main_c.lua
local screenSize = Vector2 ( guiGetScreenSize ())
local ticks = { alphaTick = getTickCount (), animTick = getTickCount (), upperTick = getTickCount (), gui = { getTickCount (), getTickCount (), getTickCount ()}}
local data = { showed = false , upper = false , upperLock = false , gridlist = false , edits = {}, actual = false , link }
local serials = {}
local function isMouseInPosition ( x , y , width , height )
if not isCursorShowing () then return false end
local cursor = { getCursorPosition ()}
local cx , cy = ( cursor [ 1 ]* screenSize . x ), ( cursor [ 2 ]* screenSize . y )
if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then return true else return false end
end
local function scaleElement ( sx , sy )
return ( screenSize . x - sx )/ 2 , ( screenSize . y - sy )/ 2
end
local icon_x , icon_y = scaleElement ( 128 , 128 )
local function drawGUI ()
local up = interpolateBetween ( 100 , 0 , 0 , 0 , 0 , 0 , ( getTickCount ()- ticks . animTick )/ 2000 , "OutBack" )
if anim == "fadein" then
progress = ( getTickCount ()- ticks . alphaTick )/ 1000
alpha = interpolateBetween ( alpha , 0 , 0 , 255 , 0 , 0 , progress , "Linear" )
if alpha == 255 then
ticks . alphaTick = getTickCount ()
anim = nil
end
elseif anim == "fadeout" then
progress = ( getTickCount ()- ticks . alphaTick )/ 500
alpha = interpolateBetween ( alpha , 0 , 0 , 0 , 0 , 0 , progress , "Linear" )
if alpha == 0 then
removeEventHandler ( "onClientRender" , root , drawGUI )
ticks . alphaTick = nil
anim = nil
end
end
if isMouseInPosition ( icon_x - 150 , icon_y , 128 , 128 ) then color_one_down = { 36 , 175 , 178 } else color_one_down = { 255 , 255 , 255 } end
if isMouseInPosition ( icon_x , icon_y , 128 , 128 ) then color_two_down = { 36 , 175 , 178 } else color_two_down = { 255 , 255 , 255 } end
if isMouseInPosition ( icon_x + 150 , icon_y , 128 , 128 ) then color_three_down = { 36 , 175 , 178 } else color_three_down = { 255 , 255 , 255 } end
if isMouseInPosition ( icon_x - 150 , icon_y - 300 , 128 , 128 ) then color_one_up = { 36 , 175 , 178 } else color_one_up = { 255 , 255 , 255 } end
if isMouseInPosition ( icon_x , icon_y - 300 , 128 , 128 ) then color_two_up = { 36 , 175 , 178 } else color_two_up = { 255 , 255 , 255 } end
if isMouseInPosition ( icon_x + 150 , icon_y - 300 , 128 , 128 ) then color_three_up = { 36 , 175 , 178 } else color_three_up = { 255 , 255 , 255 } end
if not data . upper then
dxDrawImage ( icon_x - 150 , icon_y + up , 128 , 128 , "images/mk1.png" , 0 , 0 , 0 , tocolor ( color_one_down [ 1 ], color_one_down [ 2 ], color_one_down [ 3 ], alpha ), false )
dxDrawImage ( icon_x , icon_y + up , 128 , 128 , "images/mk2.png" , 0 , 0 , 0 , tocolor ( color_two_down [ 1 ], color_two_down [ 2 ], color_two_down [ 3 ], alpha ), false )
dxDrawImage ( icon_x + 150 , icon_y + up , 128 , 128 , "images/nitro.png" , 0 , 0 , 0 , tocolor ( color_three_down [ 1 ], color_three_down [ 2 ], color_three_down [ 3 ], alpha ), false )
else
if not data . upperLock then
progress = ( getTickCount ()- ticks . upperTick )/ 1500
change = interpolateBetween ( 300 , 0 , 0 , 0 , 0 , 0 , progress , "Linear" )
dxDrawImage ( icon_x - 150 , icon_y - 300 + change , 128 , 128 , "images/mk1.png" , 0 , 0 , 0 , tocolor ( color_one_up [ 1 ], color_one_up [ 2 ], color_one_up [ 3 ], alpha ), false )
dxDrawImage ( icon_x , icon_y - 300 + change , 128 , 128 , "images/mk2.png" , 0 , 0 , 0 , tocolor ( color_two_up [ 1 ], color_two_up [ 2 ], color_two_up [ 3 ], alpha ), false )
dxDrawImage ( icon_x + 150 , icon_y - 300 + change , 128 , 128 , "images/nitro.png" , 0 , 0 , 0 , tocolor ( color_three_up [ 1 ], color_three_up [ 2 ], color_three_up [ 3 ], alpha ), false )
else
dxDrawImage ( icon_x - 150 , icon_y - 300 , 128 , 128 , "images/mk1.png" , 0 , 0 , 0 , tocolor ( color_one_up [ 1 ], color_one_up [ 2 ], color_one_up [ 3 ], alpha ), false )
dxDrawImage ( icon_x , icon_y - 300 , 128 , 128 , "images/mk2.png" , 0 , 0 , 0 , tocolor ( color_two_up [ 1 ], color_two_up [ 2 ], color_two_up [ 3 ], alpha ), false )
dxDrawImage ( icon_x + 150 , icon_y - 300 , 128 , 128 , "images/nitro.png" , 0 , 0 , 0 , tocolor ( color_three_up [ 1 ], color_three_up [ 2 ], color_three_up [ 3 ], alpha ), false )
end
end
end
local function closeGUI ()
alpha = 255
showChat ( true )
anim = "fadeout"
showCursor ( false )
ticks . animTick = getTickCount ()
ticks . alphaTick = getTickCount ()
setPlayerHudComponentVisible ( "radar" , true )
localPlayer : setData ( "player:blackwhite" , false )
localPlayer : setData ( "player:hud_visible" , false )
end
addEventHandler ( "onClientMarkerHit" , resourceRoot , function( player , dimension )
if player == localPlayer and dimension then
if player . vehicle then
if player . vehicle . controller == player then
if player . vehicle . health > 800 then
showCursor ( true , false )
-- showChat ( false )
alpha = 0
anim = "fadein"
-- showChat ( false )
showCursor ( true , false )
ticks . animTick = getTickCount ()
ticks . alphaTick = getTickCount ()
player : setData ( "player:blackwhite" , true )
player : setData ( "player:hud_visible" , true )
setPlayerHudComponentVisible ( "radar" , false )
addEventHandler ( "onClientRender" , root , drawGUI )
else
triggerEvent ( "onClientAddNotification" , player , "Tw?j pojazd nie jest jest wystarczaj?co sprawny!" , "error" )
end
end
end
end
end )
addEventHandler ( "onClientMarkerLeave" , resourceRoot , function( player , dimension )
if player == localPlayer and dimension then
showCursor ( false )
-- showChat ( true )
player : setData ( "player:blackwhite" , false )
player : setData ( "player:hud_visible" , false )
setPlayerHudComponentVisible ( "radar" , true )
if isEventHandlerAdded ( "onClientRender" , root , drawGUI ) then removeEventHandler ( "onClientRender" , root , drawGUI ) end
end
end )
local player = getLocalPlayer ()
addEventHandler ( "onClientClick" , root , function( button , state )
if button == "left" and state == "down" then
if isEventHandlerAdded ( "onClientRender" , root , drawGUI ) then
if isMouseInPosition ( icon_x - 150 , icon_y , 128 , 128 ) then
closeGUI ()
triggerServerEvent ( "mk1" , player , player )
elseif isMouseInPosition ( icon_x , icon_y , 128 , 128 ) then
closeGUI ()
triggerServerEvent ( "mk2" , player , player )
elseif isMouseInPosition ( icon_x + 150 , icon_y , 128 , 128 ) then
closeGUI ()
triggerServerEvent ( "nitro" , player , player )
end
end
end
end )
defs_c.lua
function isEventHandlerAdded ( sEventName , pElementAttachedTo , func )
if type ( sEventName ) == 'string' and isElement ( pElementAttachedTo ) and type ( func ) == 'function' then
local aAttachedFunctions = getEventHandlers ( sEventName , pElementAttachedTo )
if type ( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then for i, v in ipairs(aAttachedFunctions) do if v == func then return true end end end
end return false
end
function secondsToClock ( seconds )
seconds = seconds or 0
if seconds <= 0 then
return "00:00:00"
else
hours = string . format ( "%02.f" , math . floor ( seconds / 3600 ))
mins = string . format ( "%02.f" , math . floor ( seconds / 60 - ( hours * 60 )))
secs = string . format ( "%02.f" , math . floor ( seconds - hours * 3600 - mins * 60 ))
return "" .. hours .. " godzin " .. mins
end
end
Wysłany: 2020-04-29, 08:27
Wilq
Wiek: 24 Na forum: 4428 dni Posty: 3410
Piwa : 739
Wysłany: 2020-04-29, 14:29
vAnimo
Zielony w luła
Wiek: 19 Na forum: 2312 dni Posty: 165
Nick w MP: vAnimo
Piwa : 882
Kod: addEvent("mk2", true)
addEventHandler("mk2", getRootElement(), function()
local hajs=exports['DB2']:pobierzWyniki("SELECT bank_money FROM pystories-users WHERE id=?", getElementData(client,"player:sid"))
local ccar = getPedOccupiedVehicle(source)
local cena = 99000000
if getElementData(ccar, "vehicle:ownedPlayer") == getElementData(client, "player:sid") then
if tonumber(hajs.bank_money) < cena then triggerClientEvent(client, "onClientAddNotification", client, "Nie sta? Ci? aby zakupi? to ulepszenie!", "error") return end
local id = getElementData(ccar, "vehicle:id")
if not id then triggerClientEvent(client, "onClientAddNotification", client, "To nie jest pojazd prywatny!", "error") return end
local qr = exports['pystories-db']:dbGet("SELECT * FROM pystories_vehicles WHERE id=? AND mk2=?",getElementData(ccar, "vehicle:id"), "1")
if #qr == 1 then triggerClientEvent(client, "onClientAddNotification", client, "Posiadasz ju? to ulepszenie!", "error") return end
exports["pystories-vehicles"]:onSaveVehicle(ccar)
destroyElement(ccar)
exports["pystories-db"]:dbSet("UPDATE pystories_vehicles SET parking=1,tp_to_parking=? WHERE id=?","Eazy Workshop - US2", id)
exports["pystories-db"]:dbSet("UPDATE pystories_vehicles SET mk2=1 WHERE id=?", id)
triggerClientEvent(client, "onClientAddNotification", client, "Pomy?lnie zamontowano 'Ulepszenie Silnika (poz. 2)'", "success")
--takePlayerMoney(source, cena) # zamiast tego dajesz to
exports['pystories-db']:dbSet("UPDATE pystories_users SET bank_money=bank_money-? WHERE id=?", cena, getElementData(client,"player:sid"))
exports["pystories-db"]:dbSet("update ez_logi set ile=ile+1 where usluga=? limit 1", "us2")
else
triggerClientEvent(client, "onClientAddNotification", client, "To nie jest Tw?j pojazd!", "warning")
end
end)
Licze na zimne
Więcej szczegółów
Wystawiono 1 piw(a):HEATEX
Wysłany: 2020-05-14, 16:26
HEATEX
Wiek: 25 Na forum: 2250 dni Posty: 109
Nick w MP: HEATEX
Piwa : 1336
Dzieki za pomoc zamykam oczywiscie zostawiam
Tagi: ulepszanie :: mki :: bankomat
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: