Pyrek24
Wiek: 25 Na forum: 3438 dni Posty: 546
Nick w MP: Pyrek
Piwa : 10
Witam ot??, gdy rozpoczynam prac? nie daje mi kosiarki, oto b??d
db3
https://imgur.com/ba0wH0z
c.lua
--[[
Autor : Malentas
]]
local sx , sy = guiGetScreenSize ()
local okno1 = false
local ulepszenia = false
local dostal_powiadomienie = false ;
local pracodawca = createPed ( 16 , 773.27 , - 1305.94 , 13.56 , 0 )
setElementData ( pracodawca , "name" , "Pracodawca" )
setElementDimension ( pracodawca , 0 )
setElementFrozen ( pracodawca , true )
local rozpoczecie = createMarker ( 773.18 , - 1304.66 , 13.56 - .95 , "cylinder" , 1 , 255 , 255 , 255 )
setElementData ( rozpoczecie , "praca" , true )
setElementDimension ( rozpoczecie , 0 )
addEventHandler ( "onClientMarkerHit" , rozpoczecie , function( gracz )
if gracz ~= localPlayer then return end
if getPedOccupiedVehicle ( localPlayer ) then return end
if getElementData ( localPlayer , "pracuje" ) then
if getElementData ( localPlayer , "pracuje" ) ~= "kosiarki" then exports [ "np-notyfikacje" ]: noti ( "Posiadasz inn? aktywn? prace!" , "error" ) return end
end
addEventHandler ( "onClientRender" , root , guistart )
okno1 = true
showCursor ( true )
triggerServerEvent ( "pokazTopke:kosiarki:source" , localPlayer )
end )
local font = dxCreateFont ( "cz.ttf" , 10 )
local font2 = dxCreateFont ( "cz.ttf" , 12 )
local font = dxCreateFont ( "cz.ttf" , 10 )
local font2 = dxCreateFont ( "cz.ttf" , 12 )
local pracownicy = { }
local listaulepszen = {
{ "Pojemniejsza kosiarka" , "Dzi?ki temu twoja kosiarka ma wieksz? pojemno?? kosza" , 500 , "dolar.png" },
{ "Zarobek +5%" , "Dzi?ki temu ulepszeniu zarabiasz wi?cej o 5%" , 700 , "dolar.png" },
}
function guistart ()
dxDrawImage ( scale_x ( 402 ), scale_y ( 251 ), scale_x ( 637 ), scale_y ( 399 ), ":np-gui/grafiki/tlo.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
if ulepszenia == false then
local punkty = getElementData ( localPlayer , "kospunkty" ) or 0
local zlecenia = getElementData ( localPlayer , "koszlecenia" ) or 0
shadowText ( "Praca piel?gnowania trawnika" , scale_x ( 401 ), scale_y ( 251 ), scale_x ( 1039 ), scale_y ( 295 ), tocolor ( 255 , 255 , 255 , 255 ), 1.00 , font2 , "center" , "center" , false , false , false , false , false )
-- shadowText ( "Wymagania:\nBRAK" , scale_x ( 401 ), scale_y ( 295 ), scale_x ( 719 ), scale_y ( 449 ), tocolor ( 255 , 255 , 255 , 255 ), 1.00 , font2 , "center" , "center" , false , false , false , false , false )
shadowText ( "Wykonane zlecenia: " .. zlecenia .. "\nPunkty: " .. punkty .. "" , scale_x ( 402 ), scale_y ( 510 ), scale_x ( 719 ), scale_y ( 646 ), tocolor ( 255 , 255 , 255 , 255 ), 1.00 , font2 , "center" , "center" , false , false , false , false , false )
shadowText ( "Top pracownicy:" , scale_x ( 719 ), scale_y ( 295 ), scale_x ( 1036 ), scale_y ( 329 ), tocolor ( 255 , 255 , 255 , 255 ), 1.00 , font2 , "center" , "center" , false , false , false , false , false )
dxDrawImage ( scale_x ( 415 ), scale_y ( 310 ), scale_x ( 304 ), scale_y ( 175 ), ":np-magazynier/grafiki/bg4.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
shadowText ( "Wymagania: brak" , scale_x ( 415 ), scale_y ( 500 ), scale_x ( 719 ), scale_y ( 548 ), tocolor ( 255 , 255 , 255 , 255 ), 1.00 , font2 , "center" , "center" , false , false , false , false , false )
if mysz ( scale_x ( 889 ), scale_y ( 592 ), scale_x ( 139 ), scale_y ( 44 )) then
dxDrawImage ( scale_x ( 889 ), scale_y ( 592 ), scale_x ( 139 ), scale_y ( 44 ), ":np-gui/grafiki/button_on.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
else
dxDrawImage ( scale_x ( 889 ), scale_y ( 592 ), scale_x ( 139 ), scale_y ( 44 ), ":np-gui/grafiki/button_off.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
end
if mysz ( scale_x ( 729 ), scale_y ( 592 ), scale_x ( 139 ), scale_y ( 44 )) then
dxDrawImage ( scale_x ( 729 ), scale_y ( 592 ), scale_x ( 139 ), scale_y ( 44 ), ":np-gui/grafiki/button_on.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
else
dxDrawImage ( scale_x ( 729 ), scale_y ( 592 ), scale_x ( 139 ), scale_y ( 44 ), ":np-gui/grafiki/button_off.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
end
if getElementData ( localPlayer , "pracuje" ) == "kosiarki" then
shadowText ( "Zako?cz prace" , scale_x ( 728 ), scale_y ( 591 ), scale_x ( 868 ), scale_y ( 636 ), tocolor ( 255 , 255 , 255 , 255 ), 1.00 , font2 , "center" , "center" , false , false , false , false , false )
else
shadowText ( "Rozpocznij prace" , scale_x ( 728 ), scale_y ( 591 ), scale_x ( 868 ), scale_y ( 636 ), tocolor ( 255 , 255 , 255 , 255 ), 1.00 , font2 , "center" , "center" , false , false , false , false , false )
end
shadowText ( "Ulepszenia" , scale_x ( 888 ), scale_y ( 592 ), scale_x ( 1028 ), scale_y ( 637 ), tocolor ( 255 , 255 , 255 , 255 ), 1.00 , font2 , "center" , "center" , false , false , false , false , false )
dxDrawImage ( scale_x ( 1010 ), scale_y ( 261 ), scale_x ( 16 ), scale_y ( 16 ), ":guieditor/images/cross.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
shadowText ( "Nickname:" , scale_x ( 729 ), scale_y ( 329 ), scale_x ( 880 ), scale_y ( 363 ), tocolor ( 255 , 255 , 255 , 255 ), 1.00 , font , "center" , "center" , false , false , false , false , false )
shadowText ( "Skoszone pola:" , scale_x ( 877 ), scale_y ( 329 ), scale_x ( 1028 ), scale_y ( 363 ), tocolor ( 255 , 255 , 255 , 255 ), 1.00 , font , "center" , "center" , false , false , false , false , false )
for i , v in ipairs ( pracownicy ) do
local dodatekY = ( scale_y ( 37 ))*( i - 1 )
local dodatekY2 = ( scale_y ( 74 ))*( i - 1 )
dxDrawRectangle ( scale_x ( 729 ), scale_y ( 363 ) + dodatekY , scale_x ( 299 ), scale_y ( 35 ), tocolor ( 0 , 0 , 0 , 120 ), false )
shadowText ( v . nick , scale_x ( 729 ), scale_y ( 364 ) + dodatekY2 , scale_x ( 877 ), scale_y ( 398 ), tocolor ( 255 , 255 , 255 , 255 ), 1.00 , font2 , "center" , "center" , false , false , false , false , false )
shadowText ( v . liczba , scale_x ( 880 ), scale_y ( 364 ) + dodatekY2 , scale_x ( 1028 ), scale_y ( 398 ), tocolor ( 255 , 255 , 255 , 255 ), 1.00 , font2 , "center" , "center" , false , false , false , false , false )
end
else
local punkty = getElementData ( localPlayer , "kospunkty" ) or 0
shadowText ( "Kupno ulepszen" , scale_x ( 401 ), scale_y ( 251 ), scale_x ( 1039 ), scale_y ( 295 ), tocolor ( 255 , 255 , 255 , 255 ), 1.00 , font2 , "center" , "center" , false , false , false , false , false )
dxDrawImage ( scale_x ( 1011 ), scale_y ( 262 ), scale_x ( 16 ), scale_y ( 16 ), ":np-gui/grafiki/cofnij.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
dxDrawText ( "Posiadasz: " .. punkty .. " punkt?w" , scale_x ( 402 ), scale_y ( 582 ), scale_x ( 1037 ), scale_y ( 648 ), tocolor ( 0 , 255 , 0 , 255 ), 1.00 , font2 , "center" , "center" , false , false , false , false , false )
for i , v in ipairs ( listaulepszen ) do
local dodatekY = ( scale_y ( 72 ))*( i - 1 )
local dodatekY2 = ( scale_y ( 144 ))*( i - 1 )
dxDrawRectangle ( scale_x ( 417 ), scale_y ( 297 )+ dodatekY , scale_x ( 610 ), scale_y ( 70 ), tocolor ( 0 , 0 , 0 , 120 ), false )
dxDrawImage ( scale_x ( 432 ), scale_y ( 307 )+ dodatekY , scale_x ( 50 ), scale_y ( 50 ), ":np-magazynier/grafiki/" .. v [ 4 ].. "" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
shadowText ( v [ 1 ], scale_x ( 501 ), scale_y ( 297 )+ dodatekY2 , scale_x ( 874 ), scale_y ( 332 ), tocolor ( 255 , 255 , 255 , 255 ), 1.00 , font2 , "left" , "center" , false , false , false , false , false )
shadowText ( v [ 2 ], scale_x ( 501 ), scale_y ( 332 )+ dodatekY2 , scale_x ( 874 ), scale_y ( 367 ), tocolor ( 255 , 255 , 255 , 255 ), 1.00 , font , "left" , "center" , false , false , false , false , false )
if mysz ( scale_x ( 904 ), scale_y ( 312 )+ dodatekY , scale_x ( 113 ), scale_y ( 38 )) then
dxDrawImage ( scale_x ( 904 ), scale_y ( 312 )+ dodatekY , scale_x ( 113 ), scale_y ( 38 ), ":np-gui/grafiki/button_on.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
else
dxDrawImage ( scale_x ( 904 ), scale_y ( 312 )+ dodatekY , scale_x ( 113 ), scale_y ( 38 ), ":np-gui/grafiki/button_off.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , 255 ), false )
end
shadowText ( "Zakup" , scale_x ( 904 ), scale_y ( 312 )+ dodatekY2 , scale_x ( 1017 ), scale_y ( 350 ), tocolor ( 255 , 255 , 255 , 255 ), 1.00 , font2 , "center" , "center" , false , false , false , false , false )
shadowText ( "Cena: " .. v [ 3 ].. "p" , scale_x ( 781 ), scale_y ( 297 )+ dodatekY2 , scale_x ( 894 ), scale_y ( 335 ), tocolor ( 255 , 255 , 255 , 255 ), 1.00 , font2 , "center" , "center" , false , false , false , false , false )
end
end
end
addEventHandler ( "onClientClick" , root , function( btn , state )
if btn == "left" and state == "down" then
if mysz ( scale_x ( 729 ), scale_y ( 592 ), scale_x ( 139 ), scale_y ( 44 )) and okno1 == true and ulepszenia == false then
if getElementData ( localPlayer , "pracuje" ) == "kosiarki" then
zakonczprace ()
else
rozpocznijprace ()
end
elseif mysz ( scale_x ( 889 ), scale_y ( 592 ), scale_x ( 139 ), scale_y ( 44 )) and okno1 == true and ulepszenia == false then
ulepszenia = true
elseif mysz ( scale_x ( 1010 ), scale_y ( 261 ), scale_x ( 16 ), scale_y ( 16 )) and okno1 == true and ulepszenia == false then
removeEventHandler ( "onClientRender" , root , guistart )
okno1 = false
showCursor ( false )
elseif mysz ( scale_x ( 1011 ), scale_y ( 262 ), scale_x ( 16 ), scale_y ( 16 )) and okno1 == true and ulepszenia == true then
ulepszenia = false
end
for i , v in ipairs ( listaulepszen ) do
local dodatekY = ( scale_y ( 72 ))*( i - 1 )
if mysz ( scale_x ( 904 ), scale_y ( 312 )+ dodatekY , scale_x ( 113 ), scale_y ( 38 )) and okno1 == true and ulepszenia == true then
local punkty = getElementData ( localPlayer , "kospunkty" ) or 0
if punkty < tonumber ( v [ 3 ]) then exports [ "np-notyfikacje" ]: noti ( "Posiadasz za ma?o punkt?w by zakupi? to ulepszenie" , "error" ) return end
if v [ 1 ] == "Pojemniejsza kosiarka" then
if getElementData ( localPlayer , "kosiarki:ulepszenie1" ) == 1 then exports [ "np-notyfikacje" ]: noti ( "Posiadasz ju? to ulepszenie" , "error" ) return end
setElementData ( localPlayer , "kosiarki:ulepszenie1" , 1 )
elseif v [ 1 ] == "Zarobek +5%" then
if getElementData ( localPlayer , "kosiarki:ulepszenie2" ) == 1 then exports [ "np-notyfikacje" ]: noti ( "Posiadasz ju? to ulepszenie" , "error" ) return end
setElementData ( localPlayer , "kosiarki:ulepszenie2" , 1 )
end
exports [ "np-notyfikacje" ]: noti ( "Zakupujesz ulepszenie: " .. v [ 1 ])
setElementData ( localPlayer , "kospunkty" , punkty - tonumber ( v [ 3 ]))
end
end
end
end )
addEvent ( "pokazTopke:kosiarki:client" , true )
addEventHandler ( "pokazTopke:kosiarki:client" , root , function( tabelka )
pracownicy = tabelka
end )
-- praca
local trawy = 0
function rozpocznijprace ()
setElementData ( localPlayer , "pracuje" , "kosiarki" )
triggerServerEvent ( "dajKosiarke:kosiarki" , localPlayer )
losuj ()
zaladunek = 0
removeEventHandler ( "onClientRender" , root , guistart )
okno1 = false
showCursor ( false )
wyladunek = createMarker ( 735.11 , - 1303.03 , 13.57 - .95 , "cylinder" , 2 , 25 , 131 )
addEventHandler ( "onClientMarkerHit" , wyladunek , function( gracz )
if gracz ~= localPlayer then return end
if not getPedOccupiedVehicle ( localPlayer ) then return end
if getElementData ( localPlayer , "kosiarki:ulepszenie1" ) == 1 then
ilosc = 500
else
ilosc = 250
end
if zaladunek ~= ilosc then return end
if ilosc == 250 then
zarobek = math . random ( 70 , 90 )
elseif ilosc == 500 then
zarobek = math . random ( 100 , 40 )
end
if getElementData ( localPlayer , "premium" ) then
zarobek = zarobek + zarobek * 0.15
end
if getElementData ( localPlayer , "kosiarki:ulepszenie1" ) == 2 then
zarobek = zarobek + zarobek * 0.05
end
local nagroda = math . random ( 1 , 5 )
if tonumber ( nagroda ) == 5 then
local los2 = math . random ( 1 , 3 )
if getElementData ( localPlayer , "player:premium" ) then
los2 = math . random ( 2 , 6 )
end
setElementData ( localPlayer , "punkty" , getElementData ( localPlayer , "punkty" )+ los2 )
exports [ "np-notyfikacje" ]: noti ( "Za dobr? prace otrzymujesz " .. los2 .. " RP" )
end
local zarobek2 = string . format ( "%1d" , zarobek )
setElementData ( localPlayer , "pieniadze" , getElementData ( localPlayer , "pieniadze" )+ zarobek2 )
exports [ "np-notyfikacje" ]: noti ( "Wy?adowa?e? trawe zarabiasz " .. zarobek2 .. " PLN" )
dostal_powiadomienie = false ;
zaladunek = 0
local los = math . random ( 1 , 3 )
local pkt = getElementData ( localPlayer , "kospunkty" ) or 0
setElementData ( localPlayer , "kospunkty" , pkt + los )
end )
end
function zakonczprace ()
setElementData ( localPlayer , "pracuje" , false )
triggerServerEvent ( "usunKosiarke:kosiarki" , localPlayer )
for i , v in ipairs ( getElementsByType ( "marker" )) do
if getElementData ( v , "element" ) then
destroyElement ( getElementData ( v , "element" ))
destroyElement ( v )
end
end
destroyElement ( wyladunek )
end
local miejsca = {
{ 773.27 , - 1295.40 , 13.56 },
{ 752.78 , - 1295.84 , 13.57 },
{ 752.78 , - 1253.25 , 13.56 },
{ 774.34 , - 1253.13 , 13.56 },
}
function losuj ()
trawy = 0
local los = miejsca [ math . random ( #miejsca)]
for i = 1 , 30 do
local add = i
obj = createObject ( 818 , los [ 1 ], los [ 2 ]+ add , los [ 3 ]- 2 )
setObjectScale ( obj , 0.5 )
marker = createMarker ( los [ 1 ], los [ 2 ]+ add , los [ 3 ], "corona" , 0.8 , 255 , 255 , 255 , 0 )
setElementData ( marker , "element" , obj )
trawy = trawy + 1
end
for i = 1 , 14 do
local add = i
obj = createObject ( 818 , los [ 1 ]- add , los [ 2 ], los [ 3 ]- 2 )
setObjectScale ( obj , 0.5 )
marker = createMarker ( los [ 1 ]- add , los [ 2 ], los [ 3 ], "corona" , 0.8 , 255 , 255 , 255 , 0 )
setElementData ( marker , "element" , obj )
trawy = trawy + 1
for i2 = 1 , 30 do
local add2 = i2
obj = createObject ( 818 , los [ 1 ]- add , los [ 2 ]+ add2 , los [ 3 ]- 2 )
setObjectScale ( obj , 0.5 )
marker = createMarker ( los [ 1 ]- add , los [ 2 ]+ add2 , los [ 3 ], "corona" , 0.8 , 255 , 255 , 255 , 0 )
setElementData ( marker , "element" , obj )
trawy = trawy + 1
end
end
addEventHandler ( "onClientMarkerHit" , root , function( gracz )
if gracz ~= localPlayer then return end
if not source then return end
if not getElementData ( source , "element" ) then return end
if not getPedOccupiedVehicle ( gracz ) then return end
if getElementData ( localPlayer , "kosiarki:ulepszenie1" ) == 1 then
ilosc = 350
else
ilosc = 250
end
if zaladunek == ilosc then
if not dostal_powiadomienie then
exports [ "np-notyfikacje" ]: noti ( "Twoja kosiarka jest pe?na musisz j? wy?adowa?" , "error" );
dostal_powiadomienie = true ;
end
return;
end
destroyElement ( getElementData ( source , "element" ))
destroyElement ( source )
trawy = trawy - 1
zaladunek = zaladunek + 1
if trawy == 0 then
for i , v in ipairs ( getElementsByType ( "marker" )) do
if getElementData ( v , "element" ) then
destroyElement ( getElementData ( v , "element" ))
destroyElement ( v )
end
end
marker = false
losuj ()
triggerServerEvent ( "daj:koszlecenia" , localPlayer , localPlayer )
end
end )
end
strefa = createColCuboid ( 722.99 , - 1308.70 , 13.57 - 1 , 60 , 100 , 10 )
addEventHandler ( "onClientColShapeLeave" , strefa , function( gracz )
if gracz ~= localPlayer then return end
if getElementData ( localPlayer , "pracuje" ) == "kosiarki" then
zakonczprace ()
end
end )
-- opcje
function shadowText ( text , x , y , w , h , color , size , font , xx , yy , x1 , x2 , x3 , x4 , x5 )
dxDrawText ( text , x + 1 , y + 1 , w + 1 , h + 1 , tocolor ( 0 , 0 , 0 ), size , font , xx , yy , x1 , x2 , x3 , x4 , x5 )
dxDrawText ( text , x , y , w , h , color , size , font , xx , yy , x1 , x2 , x3 , x4 , x5 )
end
function mysz ( psx , psy , pssx , pssy , abx , aby )
if not isCursorShowing () then return end
cx , cy = getCursorPosition ()
cx , cy = cx * sx , cy * sy
if cx >= psx and cx <= psx + pssx and cy >= psy and cy <= psy + pssy then
return true , cx , cy
else
return false
end
end
function scale_x ( value )
local result = ( value / 1440 ) * sx
return result
end
function scale_y ( value )
local result = ( value / 900 ) * sy
return result
end
s.lua
function pokazpracownikow ()
local q = exports [ 'np-mysql' ]: wykonaj ( "SELECT * from konta order by koszlecenia desc" )
local topka = {}
for i = 1 , 5 do
table . insert ( topka , { nick = q [ i ][ "login" ], liczba = q [ i ][ "koszlecenia" ]})
end
return topka
end
tablica = pokazpracownikow ()
setTimer (function()
tablica = pokazpracownikow ()
end , 600000 , 0 )
addEvent ( "pokazTopke:kosiarki:source" , true )
addEventHandler ( "pokazTopke:kosiarki:source" , root , function()
triggerClientEvent ( source , "pokazTopke:kosiarki:client" , source , tablica )
end )
kosiarka = { }
addEvent ( "dajKosiarke:kosiarki" , true )
addEventHandler ( "dajKosiarke:kosiarki" , root , function()
kosiarka [ source ] = createVehicle ( 572 , 770.50 , - 1306.18 , 13.14 , 0.9 , 0.0 , 3.4 )
warpPedIntoVehicle ( source , kosiarka [ source ])
triggerClientEvent ( root , "ghost:vehicle" , root , kosiarka [ source ])
setElementData ( kosiarka [ source ], "kierowca:kosiarki" , getElementData ( source , "dbid" ))
end )
addEvent ( "usunKosiarke:kosiarki" , true )
addEventHandler ( "usunKosiarke:kosiarki" , root , function()
if isElement ( kosiarka [ client ]) then
destroyElement ( kosiarka [ client ])
end
end )
addEventHandler ( "onPlayerQuit" , root , function()
if isElement ( kosiarka [ source ]) then
destroyElement ( kosiarka [ source ])
end
end )
addEvent ( "daj:koszlecenia" , true )
addEventHandler ( "daj:koszlecenia" , root , function( player )
local dbid = getElementData ( player , "dbid" )
local ilosc = getElementData ( player , "koszlecenia" ) or 0
local q = exports [ 'np-mysql' ]: wykonaj ( "UPDATE konta SET koszlecenia=koszlecenia+1 where dbid=?" , dbid )
setElementData ( player , "koszlecenia" , ilosc + 1 )
end )
addEventHandler ( "onVehicleStartEnter" , root , function( gracz , seat )
if seat ~= 0 then return end
if getElementData ( gracz , "pracuje" ) == "kosiarki" then
if getElementData ( source , "id" ) then
cancelEvent ()
end
if getElementData ( source , "kierowca:kosiarki" ) ~= getElementData ( gracz , "dbid" ) then
cancelEvent ()
end
else
if getElementData ( source , "kierowca:kosiarki" ) then
cancelEvent ()
end
end
end )