Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2019-09-21, 11:04


Mateusesek

Szkrypterr






Wiek: 25
Na forum: 2668 dni
Posty: 43
Nick w MP: Kek



Respekt: 50

Witam... Dzi? spr?bowa?em zakupi? serwer do Multi Theft Auto
Wszystko spoczko :D zabra?em paczk? z Owl Gaming tylko ?e spolszczon? i jest problem duuu?y problem... Ot?? na Local Host wszystko ?miga bardzo ?adnie czyli auta mo?na kupi? i si? zapisuj?.. a ju? na Server Project rejestracja dzia?a ale autka nie i jest mega du?o b??d?w..

To jest tak.. Kupuje auto ono znika a w konsoli albo debug script mam taki error
[19-09-18 22:56:35ERRORcarshop-system/s_shop.lua:333callfailed to call 'vehicle-system:reloadVehicle' [string "?"]

Poniewa? jestem zawzi?ty spr?bowa?em to naprawi? lecz umiem tylko podpi?? baze i zmieni? kilka kod?w w Lua to jest kod tego carshop-system


-- MAXIME 
local rc 10 
local bmx 0 
local bike 15 
local low 25 
local offroad 35 
local sport 100 
local van 50 
local bus 75 
local truck 200 
local boat 300 -- except dinghy 
local heli 500 
local plane 750 
local race 75 
local minute 10 -- CARSHOP UPDATE INTERVAL IN MINUTE 
local spawnedShopVehicles = {} 
local vehicleTaxes = { 
offroadlowsporttrucklowlow1000trucktruck200, -- dumperstretch 
lowsportlowvanvansporttruckhelivanlowlowlowlowvanlow1000lowtruckvansport, -- hunter 
boatbus1000truckoffroadvanlowbuslowlow, -- rhino 
vanrclowtruck500lowboathelibike0, -- monstertram 
vansportboatboatboattruckvan10lowvan, -- caddie 
planebikebikebikercrclowlowbikehelivanbikeboat20lowlowplanesportlowlow, -- dinghy 
sportbmxvanvanboat1075helihelioffroad, -- baggagedozer 
offroadlowlowboatlowoffroadlowhelivanvanlowrclowlowlowoffroadsportlowvanbmxbmxplaneplaneplanetrucktrucklowlowlowplaneplane 10bikebikebiketruckvanlowlowtrucklow, -- hydra 
1020offroadlowlowlowlow00offroad, -- forklifttractor2x train 
lowsportlowvantrucklowlowlowrclowlowlowvanplanevanlow500500racerace, -- 2x monster 
racelowracehelirclowlowlowoffroad0, -- train trailer 
01010offroad15lowlow3*planetrucklow,-- train trailerkartmowersweeperat400 
lowbikevanlowvanlowbikeracevanlow0van2*planeplanercboatlowlowlowoffroad, -- train trailerandromeda 
lowtruckracesportlowlowlowlowlowvanlowlow 
local global = exports.global 
local mysql exports.mysql 
local currentYear getRealTime().year+1900 

function SmallestID() -- finds the smallest ID in the SQL instead of auto increment 
local result mysql:query_fetch_assoc("SELECT MIN(e1.id+1) AS nextID FROM vehicles AS e1 LEFT JOIN vehicles AS e2 ON e1.id +1 = e2.id WHERE e2.id IS NULL") 
if result then 
local id tonumber(result["nextID"]) or return id 
end 
return false 
end 

local maximeCarShop = {} 
function fetchMaximeCarShop () 
local preparedQuery "SELECT * FROM `vehicles_shop` WHERE `enabled` = '1' AND `spawnto`!='0' " 
local q1 mysql:query(preparedQuery) 
if not q1 then 
outputDebugString("Database error / Could not fetch maxime's car shop from SQL / carshop-sytem / s_shop.lua") 
return false 
end 
maximeCarShop = {} 
while true do 
local row mysql:fetch_assoc(q1) 
if not row then break end 
table.insert(maximeCarShoprow ) 
--outputDebugString(maximeCarShop[1].vehmodelend 
mysql:free_result(q1) 
return true 
end 

function getSmallestVehID(thePlayercommandNameoutputChatBox(tostring(SmallestID( )), thePlayerend 
addCommandHandler("getsmallestveh"getSmallestVehID falsefalse) 

function carshop_updateVehiclesforceUpdate ) 
--CLEAR SPAWNED VEHICLES AT SHOPS 
for iveh in pairs(spawnedShopVehicles) do 
if veh[1] and isElement(veh[1]) and getElementType(veh[1]) == "vehicle" then 
destroyElement(veh[1]) 
destroyElement(veh[2]) 
end 
end 
spawnedShopVehicles = {} 

local blocking = { } 

for keyvalue in ipairsgetElementsByType"player" ) ) do 
local xygetElementPositionvalue table.insert(blocking, { xyzgetElementInteriorvalue ), getElementDimensionvalue ), true } ) 
end 

for keyvalue in ipairsgetElementsByType"vehicle" ) ) do 
local xygetElementPositionvalue table.insert(blocking, { xyzgetElementInteriorvalue ), getElementDimensionvalue ), falsevalue } ) 
end 

for dealerID 1#shops do 
if #shops[dealerID]["spawnpoints"] > 0 then 
for kv in ipairsshops[dealerID]["spawnpoints"] ) do 
local canPopulate2 true 
for _va in ipairsblocking ) do 
if (v[4] == va[4] and v[5] == va[5]) then 
local distance getDistanceBetweenPoints3Dv[1], v[2], v[3], va[1], va[2], va[3] ) 
if distance 4 then 
canPopulate2 false 
if va[7] and isElement(va[7]) and getElementType(va[7]) == "vehicle" then 
respawnVehicle(va[7]) 
end 
break 
end 
end 
end 

local vehicleData getRandomVehicleFromCarshop(dealerID) 
if canPopulate2 and vehicleData then 
local letter1 string.char(math.random(65,90)) 
local letter2 string.char(math.random(65,90)) 
local plate letter1 .. letter2 .. math.random(09) .. " " .. math.random(10009999local model tonumber(vehicleData.vehmtamodel) 
--getVehicleModelFromName(data[1]) or tonumber(data[1]) 

local vehicle createVehiclemodel v[1], v[2], v[3], v[4], v[5], v[6], plate local vehBrand vehicleData["vehbrand"local vehModel vehicleData["vehmodel"local vehPrice tonumber(vehicleData["vehprice"]) 
local vehTax tonumber(vehicleData["vehtax"]) 
local vehYear tonumber(vehicleData["vehyear"]) 

local odometer if vehYear currentYear 1 then 
local yearsSince currentYear vehYear for 1yearsSince do 
odometer odometer math.random(60500end 
end 

local vehicle_shop_id tonumber(vehicleData["id"]) 
if not (vehicle and vehBrand and vehModel and vehPrice and vehTax and vehYear and vehicle_shop_idthen 
outputDebugString("failed to spawn a "..data[1]) 
--next 
else 

setElementInterior(vehiclev[4]) 
setElementDimension(vehiclev[5]) 
setVehicleLockedvehicletrue setTimer(setElementFrozen1801vehicletrue setVehicleDamageProofvehicletrue setVehicleVariant(vehicleexports['vehicle-system']:getRandomVariant(getElementModel(vehicle))) 
v["vehicle"] = vehicle 

local x v[1] - ( ( math.cos math.rad v[6] ) ) ) * 1.5 local y v[2] - ( ( math.sin math.rad v[6] ) ) ) * 1.5 local tempPickup nil 
if dealerID == 6 then -- Boatshop 
tempPickup createPickup(v[1], v[2], v[3]+131239) 
else 
tempPickup createPickup(xyv[3], 31239end 
table.insert(spawnedShopVehicles, {vehicletempPickup}) 
exports.anticheat:changeProtectedElementDataEx(tempPickup"carshop:parentCar"v["vehicle"], falseexports.anticheat:changeProtectedElementDataEx(v["vehicle"], "brand"vehBrand trueexports.anticheat:changeProtectedElementDataEx(v["vehicle"], "maximemodel"vehModel trueexports.anticheat:changeProtectedElementDataEx(v["vehicle"], "year"vehYear trueexports.anticheat:changeProtectedElementDataEx(v["vehicle"], "odometer"odometer trueexports.anticheat:changeProtectedElementDataEx(v["vehicle"], "carshop:cost"vehPrice trueexports.anticheat:changeProtectedElementDataEx(v["vehicle"], "carshop"dealerIDtrueexports.anticheat:changeProtectedElementDataEx(v["vehicle"], "carshop:childPickup"tempPickupfalseexports.anticheat:changeProtectedElementDataEx(v["vehicle"], "carshop:taxcost"vehTaxtrueexports.anticheat:changeProtectedElementDataEx(v["vehicle"], "dbid", -1trueexports.anticheat:changeProtectedElementDataEx(v["vehicle"], "vehicle_shop_id"vehicle_shop_idtrue) 
for 15do 
exports.anticheat:changeProtectedElementDataEx(v["vehicle"], "description:" .. i""trueend 

notifyEveryoneWhoOrderedThisModel(shops[dealerID]["name"], shops[dealerID]["nicename"], vehicle_shop_idvehYearvehBrandvehModelvehPriceend 
end 
end 
end 
end 
end 

function carshop_pickupUse(thePlayerlocal parentCar getElementData(source"carshop:parentCar") 
if parentCar and isElement(parentCarthen 
local costCar getElementData(parentCar"carshop:cost"local costTax getElementData(parentCar"carshop:taxcost") 
if costCar and costTax then 
triggerClientEvent(thePlayer"carshop:showInfo"parentCarcostCarcostTaxend 
cancelEvent() 
end 
end 
addEventHandler("onPickupHit"getResourceRootElement(), carshop_pickupUse) 

function carshop_Initalize( ) 
carshop_updateVehiclestrue )    
setTimercarshop_updateVehicles1000*60*minute0false end 
addEventHandler"onResourceStart"getResourceRootElement(), carshop_Initalize) 

function carshop_blockEnterVehicle(thePlayerlocal isCarShop getElementData(source"carshop") 
if (isCarShopthen 
local costCar getElementData(source"carshop:cost"local payByCash true 
local payByBank true 

if not exports.global:hasMoney(thePlayercostCar) or costCar == 0 then 
payByCash false 
end 

local money getElementData(thePlayer"bankmoney") - costCar 
if money or costCar == 0 then 
payByBank false 
end 

triggerClientEvent(thePlayer"carshop:buyCar"sourcecostCarpayByCashpayByBankend 
cancelEvent() 
end 
addEventHandler"onVehicleEnter"getResourceRootElement(), carshop_blockEnterVehicleaddEventHandler"onVehicleStartEnter"getResourceRootElement(), carshop_blockEnterVehicle) 

function carshop_buyVehicle(paymentMethod) 
if not client then 
return false 
end 

local isCarshopVehicle getElementData(source"carshop") 
if not isCarshopVehicle then 
return false 
end 

local isOverlayDisabled getElementData(client"hud:isOverlayDisabled") 

if not exports.global:canPlayerBuyVehicle(clientthen 
if isOverlayDisabled then 
outputChatBox("You have already reached the maximum number of vehicles"client02550) 
else 
exports.hud:sendBottomNotification(client"Maximum vehicle limit""You have already reached the maximum number of vehicles. /stats for details."end 
return false 
end 



local costCar getElementData(source"carshop:cost") 
if (paymentMethod == "cash"then 
if not exports.global:hasMoney(clientcostCar) or costCar == 0 then 
if isOverlayDisabled then 
outputChatBox("You don't have enough money on hand for this pal.."client02550) 
else 
exports.hud:sendBottomNotification(client"Money is always a problem..""You don't have enough money on hand for this pal.."end 
return false 
else 
exports.global:takeMoney(clientcostCarend 
elseif (paymentMethod == "bank"then 
local money getElementData(client"bankmoney") - costCar 
if money or costCar == 0 then 
if isOverlayDisabled then 
outputChatBox("You don't have enough money in your bank account for this pal.."client02550) 
else 
exports.hud:sendBottomNotification(client"Money is always a problem..""You don't have enough money in your bank account for this pal.."end 
else 
exports.anticheat:changeProtectedElementDataEx(client"bankmoney"moneyfalsemysql:query_free("UPDATE characters SET bankmoney=" .. mysql:escape_string((tonumber(money) or 0)) .. " WHERE id=" .. mysql:escape_string(getElementDataclient"dbid" ))) 
end 
else 
if isOverlayDisabled then 
outputChatBox("No."client02550) 
else 
exports.hud:sendBottomNotification(client"No!""Just no..."end 
return false 
end 

local dbid getElementData(client"account:character:id"local modelID getElementModel(sourcelocal xygetElementPosition(sourcelocal rxryrz getElementRotation(sourcelocal odometer tonumber(getElementData(source'odometer')) * 1000 
local col = { getVehicleColor(source) } 
local color1 toJSON( {col[1], col[2], col[3]} ) 
local color2 toJSON( {col[4], col[5], col[6]} ) 
local color3 toJSON( {col[7], col[8], col[9]} ) 
local color4 toJSON( {col[10], col[11], col[12]} ) 
local letter1 string.char(math.random(65,90)) 
local letter2 string.char(math.random(65,90)) 
local var1var2 getVehicleVariant(sourcelocal plate letter1 .. letter2 .. math.random(09) .. " " .. math.random(10009999local locked 1 
local vehShopID getElementData(source"vehicle_shop_id") or 0 
local smallestID SmallestID()    
local insertid mysql:query_insert_free("INSERT INTO vehicles SET id='"..mysql:escape_string(smallestID).."', model='" .. mysql:escape_string(modelID) .. "', x='" .. mysql:escape_string(x) .. "', y='" .. mysql:escape_string(y) .. "', z='" .. mysql:escape_string(z) .. "', rotx='" .. mysql:escape_string(rx) .. "', roty='" .. mysql:escape_string(ry) .. "', rotz='" .. mysql:escape_string(rz) .. "', color1='" .. mysql:escape_string(color1) .. "', color2='" .. mysql:escape_string(color2) .. "', color3='" .. mysql:escape_string(color3) .. "', color4='" .. mysql:escape_string(color4) .. "', faction='-1', owner='" .. mysql:escape_string(dbid) .. "', plate='" .. mysql:escape_string(plate) .. "', currx='" .. mysql:escape_string(x) .. "', curry='" .. mysql:escape_string(y) .. "', currz='" .. mysql:escape_string(z) .. "', currrx='0', currry='0', currrz='" .. mysql:escape_string(rz) .. "', locked='" .. mysql:escape_string(locked) .. "',variant1="..var1..",variant2="..var2..",description1='', description2='', description3='',description4='',description5='', creationDate=NOW(), createdBy='-1', vehicle_shop_id='"..mysql:escape_string(vehShopID).."',odometer='".. mysql:escape_string(odometer).."'") 

if not insertid then 
return false 
end 

--[[ -- DO NOT UNQUOTE MAXIME 
local brand getElementData(source"brand") or false 
local model getElementData(source"maximemodel"local year getElementData(source"year") 

if brand then 
local insertid2 mysql:query_insert_free("INSERT INTO vehicles_custom SET id='"..mysql:escape_string(insertid).."', brand='" .. mysql:escape_string(brand) .. "', model='" .. mysql:escape_string(model) .. "', year='" .. mysql:escape_string(year) .. "', duration='1000' ") 

if not insertid2 then 
return false 
end 
end 
]] 

exports.logs:dbLog(client6"ve"..tostring(insertid), "BOUGHTNEWCAR "..getVehicleNameFromModel(modelID).." (Custom Model ID #"..vehShopID..", Price: $"..exports.global:formatMoney(costCar)..")"callgetResourceFromName"item-system" ), "deleteAll"3insertid exports.global:giveItemclient3insertid )    
local tempPickup getElementData(source,"carshop:childPickup") 
if (isElement(tempPickup)) then 
destroyElement(tempPickupend 
destroyElement(source)    
'exports'('vehicle-system'):reloadVehicle(insertidlocal license = (getElementData(client"license.car") == 1) and "" or "You don't have a drivers license. You better not drive this on the street." 

if isOverlayDisabled then 
outputChatBox("Congratulations, you just bought a vehicle!"clientoutputChatBox("Make sure to /park it at the respawnspot you want within an hour,"clientoutputChatBox("otherwise the vehicle will get deleted, non-recoverable."clientoutputChatBox(licenseclientoutputChatBox("Edit the vehicle description using /ed or /editdescription."client) 
else 
local content = {} 
table.insert(content, {"Make sure to /park it at the respawnspot you want within an hour or the vehicle will get deleted!"}) 
table.insert(content, {license}) 
table.insert(content, {"Edit the vehicle description using /ed or /editdescription."}) 

exports.hud:sendBottomNotification(client"Congratulations, you just bought a vehicle!"content30end 

local adminID getElementData(client"account:id")    
local addLog mysql:query_free("INSERT INTO `vehicle_logs` (`vehID`, `action`, `actor`) VALUES ('"..tostring(insertid).."', 'bought from carshop', '"..adminID.."')") or false 
if not addLog then 
outputDebugString("Failed to add vehicle logs."end 

triggerEvent("vehicle-manager:handling:orderVehicle:cancel"clientend 
addEvent("carshop:buyCar"trueaddEventHandler("carshop:buyCar"getRootElement(), carshop_buyVehiclelocal vehicleColors 
function getRandomVehicleColorvehicle ) 
if not vehicleColors then 
vehicleColors = { } 
local file fileOpen"vehiclecolors.conf"true ) 
while not fileIsEOFfile ) do 
local line fileReadLinefile ) 
if #line > 0 and line:sub( 1, 1 ) ~= "#" then 
local model tonumbergettokline1string.byte(' ') ) ) 
if not vehicleColorsmodel then 
vehicleColorsmodel ] = { } 
end 
vehicleColorsmodel ][ #vehicleColors[ model ] + 1 ] = { 
tonumbergettokline2string.byte(' ') ) ), 
tonumbergettokline3string.byte(' ') ) ) or nil, 
} 
end 
end 
fileClosefile end 

local colors vehicleColorsgetElementModelvehicle ) ] 
if colors then 
return unpackcolorsmath.random1#colors ) ] ) 
end 
end 

function fileReadLinefile local buffer "" 
local tmp 
repeat 
tmp fileReadfile) or nil 
if tmp and tmp ~= "\r" and tmp ~= "\n" then 
buffer buffer .. tmp 
end 
until not tmp or tmp == "\n" or tmp == "" 

return buffer 
end 

function isForSale(vehicle) 
if type(vehicle) == "number" then 
elseif type(vehicle) == "string" then 
vehicle tonumber(vehicle) 
elseif isElement(vehicle) and getElementType(vehicle) == "vehicle" then 
vehicle getElementModel(vehicle) 
else 
return false 
end 
for _shop in ipairs(shops) do 
for _data in ipairs(shop.prices) do 
if getVehicleModelFromName(data[1]) == vehicle then 
return true 
end 
end 
end 
return false 
end 

MTAoutputChatBox outputChatBox 
function outputChatBoxtextvisibleTorgbcolorCoded ) 
if text then 
if string.len(text) > 128 then -- MTA Chatbox size limit 
MTAoutputChatBoxstring.sub(text1127), visibleTorgbcolorCoded outputChatBoxstring.sub(text128), visibleTorgbcolorCoded ) 
else 
MTAoutputChatBoxtextvisibleTorgbcolorCoded end 
end 
end 

function notifyEveryoneWhoOrderedThisModel(shopnameshopnicenamevehicle_shop_idvehYearvehBrandvehModelvehPrice) 
for iplayer in pairs (getElementsByType("player")) do 
if shopname and shopnicename and vehicle_shop_id and vehYear and vehBrand and vehModel and vehPrice then 
local orderedVehID getElementData(player"carshop:grotti:orderedvehicle:"..shopname) or false 
if orderedVehID and tonumber(orderedVehID) == tonumber(vehicle_shop_idthen 
if exports.global:hasItem(player2then 
local languageslot getElementData(player"languages.current"local language getElementData(player"languages.lang" .. languageslotlocal languagename call(getResourceFromName("language-system"), "getLanguageName"languagelocal playerName exports.global:getPlayerName(playerlocal itemName vehYear.." "..vehBrand.." "..vehModel 

exports.global:sendLocalText(player"*"..playerName.." receives a text message."2555110230, {}, trueoutputChatBox("["..languagename.."] SMS from "..shopnicename..": Hello! As you have ordered, we now have a "..itemName.." in stock for $"..exports.global:formatMoney(vehPrice)..". Come check it out!" player12025580end 
end 
end 
end 
end 

function getRandomVehicleFromCarshop(shopID) 
if shopID and tonumber(shopIDthen 
--outputDebugString("getRandomVehicleFromCarshop - shopID - "..shopID) 
--shopID tonumber(shopIDlocal preparedQuery "SELECT * FROM `vehicles_shop` WHERE `enabled` = '1' AND `spawnto`='"..exports.global:toSQL(shopID).."' " 
local q1 mysql:query(preparedQuery) 
if not q1 then 
outputDebugString("Database error / getRandomVehicleFromCarshop / carshop-sytem / s_shop.lua") 
return false 
end 
local tempTable = {} 
while true do 
local row mysql:fetch_assoc(q1) 
if not row then break end 
table.insert(tempTablerow end 
mysql:free_result(q1) 
if #tempTable > 0 then 
local ran math.random1#tempTable ) 
return tempTable[ran] 
else 
return false 
end 
end 
end

Bardzo prosz? kogo? o jak? kolwiek pomoc z g?ry dzi?kuje ;)

Postaw piwo autorowi tego posta
 

 
Tagi: vehicle
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Odpowiedz do tematu

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku