Szevasztok
Nos van egy autós rendszerem: Venni kell autót, majd egy gombbal előlehet/ellehet tüntetni(Hasonló mint SAS-Networkon) és egyebek. Viszont az a baj hogy az autó tuningjait és a megváltoztatott szinét nem menti le, hanem van egy megadott és az alapján szinezi minden lehívásnál.
Vételnél:
addEvent(\"buycar1\",true)
addEventHandler(\"buycar1\",getRootElement(),
function(id,cost,name)
if (getPlayerMoney(client)>= tonumber(cost)) then
local account = getPlayerAccount(client)
local name = getAccountName(account)
local playercar = executeSQLQuery(\"SELECT Model,Paintjob,Color,Upgrade0,Upgrade1,Upgrade2,Upgrade3,Upgrade4,Upgrade5,Upgrade6,Upgrade7,Upgrade8,Upgrade9,Upgrade10,Upgrade11,Upgrade12,Upgrade13,Upgrade14,Upgrade15,Upgrade16 FROM carslot1 WHERE PlayerName = ?\",name)
if #playercar > 0 then
outputChatBox(\"You cant buy this car since you already have one in this slot\",client)
else
--[[local c1xml = xmlLoadFile(\"buyingc1.dat\")
if not c1xml then
c1xml = xmlCreateFile(\"buyingc1.dat\",\"wang\")
end
local node = xmlCreateChild(c1xml,\"buyc1\")
local msg = name..\" tried to buy vehicle \"..getVehicleNameFromModel(id)
local success1 = xmlNodeSetValue(node,msg)]]
local paintjob = 3
local color = \"88,88,83,70,89,122\"
takePlayerMoney(client,tonumber(cost))
local addVehicle = executeSQLQuery(\"INSERT INTO carslot1 (PlayerName,Model,Cost,Paintjob,Color,Upgrade0,Upgrade1,Upgrade2,Upgrade3,Upgrade4,Upgrade5,Upgrade6,Upgrade7,Upgrade8,Upgrade9,Upgrade10,Upgrade11,Upgrade12,Upgrade13,Upgrade14,Upgrade15,Upgrade16) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)\", tostring(name), tonumber(id), tonumber(cost), tonumber(paintjob), tostring(color), \" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \")
if addVehicle then
-- local msg2 = name..\" succeeded in sale $\"..cost
--local node2 = xmlCreateChild(c1xml,\"buyc1\")
--local success2 = xmlNodeSetValue(node2,msg2)
outputChatBox(\"Vehicle bought successfully\",client)
else
--local msg2 = name..\" failed in sale $\"..cost
--local node2 = xmlCreateChild(c1xml,\"buyc1\")
--local success2 = xmlNodeSetValue(node2,msg2)
outputChatBox(\"Vehicle has not been bought\",client)
end
--xmlSaveFile(c1xml)
--xmlUnloadFile(c1xml)
end
else
outputChatBox(\"You dont have enough money to buy this car\",client)
end
end)
Lehívásnál:
addEvent(\"spawncar1\",true)
addEventHandler(\"spawncar1\",getRootElement(),
function()
if not (isGuestAccount(getPlayerAccount(client))) then
if not (isPedInVehicle(client)) then
local x,y,z = getElementPosition(client)
if (getElementData(client,\"mycar1\")) and (getElementData(client,\"mycar1\")~= nil) --[[and (getElementType(getElementData(client,\"mycar1\")) ==\"vehicle\")]] then
local vehicle = getElementData(client,\"mycar1\")
destroyElement(vehicle)
removeElementData(client,\"mycar1\")
local x,y,z = getElementPosition(vehicle)
setElementPosition(vehicle,x,y,z)
outputChatBox(\"Vehicle destroyed\",client)
--[[ local vehicle = getElementData(client,\"mybik1\")
destroyElement(vehicle)
removeElementData(client,\"mybik1\")
outputChatBox(\"Vehicle destroyed\",client)]]
elseif not (getElementData(client,\"mycar1\")) then
local account = getPlayerAccount(client)
local name = getAccountName(account)
local playercar = executeSQLQuery(\"SELECT Model,Paintjob,Color,Upgrade0,Upgrade1,Upgrade2,Upgrade3,Upgrade4,Upgrade5,Upgrade6,Upgrade7,Upgrade8,Upgrade9,Upgrade10,Upgrade11,Upgrade12,Upgrade13,Upgrade14,Upgrade15,Upgrade16 FROM carslot1 WHERE PlayerName = ?\",name)
if (playercar) then
if #playercar > 0 then
local x,y,z = getElementPosition(client)
local vehicle = createVehicle(playercar[1].Model,x + 5,y +2,z)
setVehiclePaintjob(vehicle,playercar[1].Paintjob)
setElementData(vehicle,\"vehicleOwner\",\"mycar1\")
setElementData (vehicle,\"mycar1\",getPlayerName(source))
setElementData (client, \"mycar1\", vehicle)
setElementData(vehicle,\"VOwner\",getPlayerName(client))
outputChatBox (\"Car spawned.\", source, 255, 0, 0)
addVehicleUpgrade(vehicle, playercar[1].Upgrade0)
addVehicleUpgrade(vehicle, playercar[1].Upgrade1)
addVehicleUpgrade(vehicle, playercar[1].Upgrade2)
addVehicleUpgrade(vehicle, playercar[1].Upgrade3)
addVehicleUpgrade(vehicle, playercar[1].Upgrade4)
addVehicleUpgrade(vehicle, playercar[1].Upgrade5)
addVehicleUpgrade(vehicle, playercar[1].Upgrade6)
addVehicleUpgrade(vehicle, playercar[1].Upgrade7)
addVehicleUpgrade(vehicle, playercar[1].Upgrade8)
addVehicleUpgrade(vehicle, playercar[1].Upgrade9)
addVehicleUpgrade(vehicle, playercar[1].Upgrade10)
addVehicleUpgrade(vehicle, playercar[1].Upgrade11)
addVehicleUpgrade(vehicle, playercar[1].Upgrade12)
addVehicleUpgrade(vehicle, playercar[1].Upgrade13)
addVehicleUpgrade(vehicle, playercar[1].Upgrade14)
addVehicleUpgrade(vehicle, playercar[1].Upgrade15)
addVehicleUpgrade(vehicle, playercar[1].Upgrade16)
local col1 = gettok (playercar[1].Color, 1, string.byte(\',\') )
local col2 = gettok (playercar[1].Color, 2, string.byte(\',\') )
local col3 = gettok (playercar[1].Color, 3, string.byte(\',\') )
local col4 = gettok (playercar[1].Color, 4, string.byte(\',\') )
local col5 = gettok (playercar[1].Color, 5, string.byte(\',\') )
local col6 = gettok (playercar[1].Color, 6, string.byte(\',\') )
if col1 then
setVehicleColor(vehicle, tonumber(col1), tonumber(col2), tonumber(col3), tonumber(col4), tonumber(col5), tonumber(col6))
end
else
outputChatBox(\"You have not buy a car for this slot yet\",client)
end
end
end
else
outputChatBox(\"You need to get out of your vehicle first\",client)
end
else
outputChatBox(\"You need to log in first\",client)
end
end)