Wysłany: 2017-01-22, 15:41
Vintage
Wiek: 23 Na forum: 3555 dni Posty: 64
Piwa : 1
Witam mam taki skrypt na taxi i chcia?bym go podpi?? pod mysql i dodac funkcje typu sprawdza czy gracz jest zapisany w tabeli
kod :
local allow_vehs ={
[ 420 ]= true ,
}
local vehs ={
{- 1987.56555 , 160.60571 , 27.17412 },
}
taxi ={}
for k , v in ipairs ( vehs )do
taxi [ k ]= createVehicle ( 420 , v [ 1 ], v [ 2 ], v [ 3 ])
setElementData ( taxi [ k ], "vehicle:taxi" , true )
end
addEventHandler ( "onPlayerVehicleEnter" , root ,function( veh , seat )
if seat == 0 then
if allow_vehs [ getElementModel ( veh )] then
if getElementData ( veh , "vehicle:taxi" ) then
outputChatBox ( "*Zosta?e?(a?) taks?wkarzem. Dostaniesz informacj? o po?o?eniu klienta po wezwaniu us?ugi." , source , 255 , 255 , 255 )
setElementData ( source , "player:taxi" , true )
end
end
end
if allow_vehs [ getElementModel ( veh )] then
if getElementData ( veh , "vehicle:taxi" ) then
setElementData ( source , "taxi" , false )
end
end
end )
addEventHandler ( "onPlayerVehicleExit" , root ,function( veh , seat )
if seat == 0 then
if allow_vehs [ getElementModel ( veh )] then
if getElementData ( veh , "vehicle:taxi" ) then
respawnVehicle ( veh )
setElementData ( source , "player:taxi" , false )
end
end
end
end )
addCommandHandler ( "taxi" ,function( plr )
if getElementData ( plr , "taxi" ) then
return outputChatBox ( "*Zam?wi?e?(a?) ju? us?ug?. Poczekaj cierpliwie na taks?wk?" , plr , 255 , 255 , 0 )
end
count ={}
for _ , v in ipairs ( getElementsByType ( "player" ))do
if getPedOccupiedVehicle ( v ) then
if getElementData ( getPedOccupiedVehicle ( v ), "vehicle:taxi" ) then
if allow_vehs [ getElementModel ( getPedOccupiedVehicle ( v ))] then
table . insert ( count , v )
end
end
end
end
if #count==0 then
return outputChatBox ( "*Brak taks?wkarzy na s?u?bie." , plr , 255 , 255 , 0 )
end
local x , y , z = getElementPosition ( plr )
for _ , v in ipairs ( getElementsByType ( "player" ))do
if getPedOccupiedVehicle ( v ) then
if getElementData ( getPedOccupiedVehicle ( v ), "vehicle:taxi" ) then
if allow_vehs [ getElementModel ( getPedOccupiedVehicle ( v ))] then
outputChatBox ( "--NOWE ZLECENIE--" , v , 255 , 255 , 0 )
outputChatBox ( "*Gracz " .. getPlayerName ( plr ).. " zam?wi?(a) us?ug? taxi." , v , 255 , 255 , 0 )
local miasto = getZoneName ( x , y , z )
local strefa = getZoneName ( x , y , z , true )
outputChatBox ( "*Po?o?enie : " .. miasto .. ", " .. strefa , v , 255 , 255 , 0 )
end
end
end
end
outputChatBox ( "*Zam?wi?e?(a?) us?ug? taxi. Czekaj cierpliwie w tym miejscu, taks?wkarz nie b?dzie cie szuka?." , plr , 255 , 255 , 0 )
setElementData ( plr , "taxi" , true )
end )
addCommandHandler ( "oplata" ,function( plr , cmd , gracz , ilosc )
if getElementData ( plr , "player:taxi" ) then
local cel = getPlayerFromName ( gracz )
if cel then
setElementData ( cel , "TaxiInfo" ,{ plr , ilosc })
outputChatBox ( "*Gracz " .. getPlayerName ( plr ).. " poda?(a) Ci kwitek do zap?aty " .. ilosc .. " $. Aby podpisa? wpisz /akceptuj" , cel , 255 , 255 , 255 )
outputChatBox ( "*Poda?e?(a?) kwitek klientowi do zap?aty." , plr , 255 , 255 , 255 )
end
end
end )
addCommandHandler ( "akceptuj" ,function( plr )
if getElementData ( plr , "TaxiInfo" ) then
local taksowkarz , ilosc = unpack ( getElementData ( plr , "TaxiInfo" ))
local taksowkarz = getPlayerFromName ( getPlayerName ( taksowkarz ))
if not taksowkarz then
return outputChatBox ( "*Taks?wkarz nie jest ju? online" , plr , 255 , 255 , 255 )
end
if tonumber ( getPlayerMoney ( plr ))< tonumber ( ilosc ) then
return outputChatBox ( "*Nie posiadasz pieni?dzy aby podpisa? kwitek z kwot? " .. ilosc .. " $" , plr , 255 , 255 , 255 )
end
givePlayerMoney ( taksowkarz , tonumber ( ilosc ))
takePlayerMoney ( plr , tonumber ( ilosc ))
outputChatBox ( "*Podpisa?e? kwitek. Zabrano Ci " .. ilosc .. " $" , plr , 255 , 255 , 255 )
outputChatBox ( "*Gracz " .. getPlayerName ( plr ).. " podpisa? kwitek. Otrzymujesz " .. ilosc .. " $" , taksowkarz , 255 , 255 , 255 )
end
end )
Wysłany: 2017-01-22, 15:54
_Haze
Peace Yo!
Wiek: 24 Na forum: 4184 dni Posty: 1648
Nick w MP: Haze
Piwa : 2628
Wysłany: 2017-01-22, 15:56
Vintage
Wiek: 23 Na forum: 3555 dni Posty: 64
Piwa : 1
Hazmudex , tylko tam jest opisany sqlite troche mysql
ale brakuje tu po??czenia z mysql ze skryptem
[ Dodano : 2017-01-22, 16:38 ]
Hazmudex ,
tak zrobi?em i nie dzia?a ;/
kod :
local connect = dbConnect ( "sqlite" , "file.db" )
if connect then
outputDebugString ( "Po??czenie z baz? SQLite zako?czy?o si? powodzeniem." )
else
outputDebugString ( "Po??czenie z baz? SQLite zako?czy?o si? nie powodzeniem." )
stopResource ( getThisResource ())
end
for i , v in ipairs ( getElementsByType ( "player" )) do
local name = getPlayerName ( v )
local id = getElementData ( v , "Player:ID" )
dbQuery ( connect , "INSERT INTO player ( name, id ) VALUES ( ?,? )" , name , id )
end
local allow_vehs ={
[ 420 ]= true ,
}
local vehs ={
{- 1987.56555 , 160.60571 , 27.17412 },
}
taxi ={}
for k , v in ipairs ( vehs )do
taxi [ k ]= createVehicle ( 420 , v [ 1 ], v [ 2 ], v [ 3 ])
setElementData ( taxi [ k ], "vehicle:taxi" , true )
end
addEventHandler ( "onPlayerVehicleEnter" , root ,function( veh , seat )
dbQuery ( connect , "INSERT INTO taxi ( serial, uid ... ) VALUES ( 10,255 ... )" , Warto ?? 1 , Warto ?? 2 ...)
if seat == 0 then
if allow_vehs [ getElementModel ( veh )] then
if getElementData ( veh , "vehicle:taxi" ) then
outputChatBox ( "*Zosta?e?(a?) taks?wkarzem. Dostaniesz informacj? o po?o?eniu klienta po wezwaniu us?ugi." , source , 255 , 255 , 255 )
setElementData ( source , "player:taxi" , true )
end
end
end
if allow_vehs [ getElementModel ( veh )] then
if getElementData ( veh , "vehicle:taxi" ) then
setElementData ( source , "taxi" , false )
end
end
end )
addEventHandler ( "onPlayerVehicleExit" , root ,function( veh , seat )
if seat == 0 then
if allow_vehs [ getElementModel ( veh )] then
if getElementData ( veh , "vehicle:taxi" ) then
respawnVehicle ( veh )
setElementData ( source , "player:taxi" , false )
end
end
end
end )
addCommandHandler ( "taxi" ,function( plr )
if getElementData ( plr , "taxi" ) then
return outputChatBox ( "*Zam?wi?e?(a?) ju? us?ug?. Poczekaj cierpliwie na taks?wk?" , plr , 255 , 255 , 0 )
end
count ={}
for _ , v in ipairs ( getElementsByType ( "player" ))do
if getPedOccupiedVehicle ( v ) then
if getElementData ( getPedOccupiedVehicle ( v ), "vehicle:taxi" ) then
if allow_vehs [ getElementModel ( getPedOccupiedVehicle ( v ))] then
table . insert ( count , v )
end
end
end
end
if #count==0 then
return outputChatBox ( "*Brak taks?wkarzy na s?u?bie." , plr , 255 , 255 , 0 )
end
local x , y , z = getElementPosition ( plr )
for _ , v in ipairs ( getElementsByType ( "player" ))do
if getPedOccupiedVehicle ( v ) then
if getElementData ( getPedOccupiedVehicle ( v ), "vehicle:taxi" ) then
if allow_vehs [ getElementModel ( getPedOccupiedVehicle ( v ))] then
outputChatBox ( "--NOWE ZLECENIE--" , v , 255 , 255 , 0 )
outputChatBox ( "*Gracz " .. getPlayerName ( plr ).. " zam?wi?(a) us?ug? taxi." , v , 255 , 255 , 0 )
local miasto = getZoneName ( x , y , z )
local strefa = getZoneName ( x , y , z , true )
outputChatBox ( "*Po?o?enie : " .. miasto .. ", " .. strefa , v , 255 , 255 , 0 )
end
end
end
end
outputChatBox ( "*Zam?wi?e?(a?) us?ug? taxi. Czekaj cierpliwie w tym miejscu, taks?wkarz nie b?dzie cie szuka?." , plr , 255 , 255 , 0 )
setElementData ( plr , "taxi" , true )
end )
addCommandHandler ( "oplata" ,function( plr , cmd , gracz , ilosc )
if getElementData ( plr , "player:taxi" ) then
local cel = getPlayerFromName ( gracz )
if cel then
setElementData ( cel , "TaxiInfo" ,{ plr , ilosc })
outputChatBox ( "*Gracz " .. getPlayerName ( plr ).. " poda?(a) Ci kwitek do zap?aty " .. ilosc .. " $. Aby podpisa? wpisz /akceptuj" , cel , 255 , 255 , 255 )
outputChatBox ( "*Poda?e?(a?) kwitek klientowi do zap?aty." , plr , 255 , 255 , 255 )
end
end
end )
addCommandHandler ( "akceptuj" ,function( plr )
if getElementData ( plr , "TaxiInfo" ) then
local taksowkarz , ilosc = unpack ( getElementData ( plr , "TaxiInfo" ))
local taksowkarz = getPlayerFromName ( getPlayerName ( taksowkarz ))
if not taksowkarz then
return outputChatBox ( "*Taks?wkarz nie jest ju? online" , plr , 255 , 255 , 255 )
end
if tonumber ( getPlayerMoney ( plr ))< tonumber ( ilosc ) then
return outputChatBox ( "*Nie posiadasz pieni?dzy aby podpisa? kwitek z kwot? " .. ilosc .. " $" , plr , 255 , 255 , 255 )
end
givePlayerMoney ( taksowkarz , tonumber ( ilosc ))
takePlayerMoney ( plr , tonumber ( ilosc ))
outputChatBox ( "*Podpisa?e? kwitek. Zabrano Ci " .. ilosc .. " $" , plr , 255 , 255 , 255 )
outputChatBox ( "*Gracz " .. getPlayerName ( plr ).. " podpisa? kwitek. Otrzymujesz " .. ilosc .. " $" , taksowkarz , 255 , 255 , 255 )
end
end )
[ Dodano : 2017-01-22, 16:41 ]
Poprawi?em warto?ci i nic ;v
Tagi: podpięcie :: skryptu :: pod :: mysql :: funckcje
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: