Szerző Téma: Nem tudom megvenni a kiválasztott kocsit!  (Megtekintve 1310 alkalommal)

Nem tudom megvenni a kiválasztott kocsit!
« Dátum: 2016. március 14. - 19:32:06 »
0 Show voters
Sziasztok, van egy carshop rendszer, tök faszán átírtam meg ilyesmi, de nem működött. Megnéztem, alapból sem működött. Ez a coreGaming rendszere, ami a héten lett kipublikálva. Egyik se működött, pedig minden rendesen volt beállítva. A scriptek:
sourceC.lua:
 
local screenSize = {guiGetScreenSize()}
local currSelected = 1
local isShopActive = false
local left, top = screenSize[1]/2 - 414/2, screenSize[2]/2 - 163/2
local dataFont = dxCreateFont(\"files/corefont.ttf\", 12)
local sellVehicles =
{
{509, \"Bicikli\", 17000, 0},
{481, \"BMX\", 24000, 0},
{510, \"Mountain Bike\", 28000, 0},
{478, \"Trabant\", 200000, 0},
{546, \"Lada\", 400000, 0},
{504, \"Opel Astra\", 1800000, 0},
{426, \"Audi RS5\", 1800000, 0},
{543, \"Kocsi 7\", 1300000, 0},
{549, \"Kocsi 8\", 2000000, 0},
{576, \"Kocsi 9\", 2500000, 0},
{540, \"Kocsi 10\", 1900000, 0},
{491, \"Kocsi 11\", 2300000, 0},
{554, \"Kocsi 12\", 2000000, 0},
{496, \"Kocsi 13\", 800000, 0},
{401, \"Kocsi 14\", 20000000, 0},
{415, \"Kocsi 15\", 20000000, 0},
{546, \"Kocsi 16\", 400000, 0},
{410, \"Kocsi 17\", 800000, 0},
{560, \"Kocsi 18\", 30000000, 0},
{506, \"Kocsi 19\", 32000000, 0},
{405, \"Kocsi 20\", 800000, 0},
{589, \"Kocsi 21\", 1200000, 0},
}
addEventHandler(\"onClientResourceStart\", getResourceRootElement(getThisResource()), function()
shopPickup = createPickup(2156.9482421875, -1173.9111328125, 23.81875038147, 3, 1239)
end)
addEventHandler(\"onClientPickupHit\", root, function(playerSource)
if source == shopPickup and playerSource == localPlayer then
cancelEvent()
fadeCamera(false)
setElementFrozen(localPlayer, true)
isShopActive = true
setTimer(function()
   fadeCamera(true)
   setCameraMatrix(-1953.0419921875, 264.271484375, 42.076904296875, -1942.005859375, 253.671875, 41.047080993652)
   shopVehicle = createVehicle(sellVehicles[currSelected][1], -1945.4873046875, 257.474609375, 41.047080993652)
   setElementDimension(localPlayer, 9999+getElementData(localPlayer, \"playerid\"))
   setElementDimension(shopVehicle, 9999+getElementData(localPlayer, \"playerid\"))
   addEventHandler(\"onClientRender\", root, vehicleRotation)
   addEventHandler(\"onClientRender\", root, updateColor)
end, 2000, 1)
showChat(false)
setElementData(localPlayer, \"coremode\", true)
currSelected = 1
end
end)
function exitShop()
if isShopActive then
setElementFrozen(localPlayer, false)
setElementDimension(localPlayer, 0)
setCameraTarget(localPlayer)
isShopActive = false
destroyElement(shopVehicle)
setElementPosition(localPlayer, 2136.130859375, -1147.9716796875, 24.476900100708)
removeEventHandler(\"onClientRender\", root, vehicleRotation)
removeEventHandler(\"onClientRender\", root, updateColor)
showChat(true)
currSelected = 1
setElementData(localPlayer, \"coremode\", false)
if colorPicker.isSelectOpen then
   colorPicker.closeSelect()
end
end
end
 
function vehicleRotation()
local x, y, z = getElementRotation(shopVehicle)
setElementRotation(shopVehicle, x, y, z + 0.5)
roundedRectangle(left, top * 1.92, 414, 163, tocolor(0,0,0,200))
--roundedRectangle(left-1000, top * 0.0001, 4000, 70, tocolor(0,0,0,200))
dxDrawImage(left, top * 1.92, 414, 163, \"files/arrowjobb.png\")
dxDrawImage(left, top * 1.92, 414, 163, \"files/arrowbal.png\")
dxDrawText(sellVehicles[currSelected][2], left + 55, top * 1.93 + 20, 269, 10, tocolor(255, 255, 255, 255), 1, dataFont)
dxDrawRectangle(left + 55, top * 2.03, 300, 1, tocolor(255,255,255,255))
dxDrawText(\"Ár - \" .. sellVehicles[currSelected][3] .. \" ft\", left + 55, top * 2.0 + 25, 269, 10, tocolor(255, 255, 255, 255), 0.9, dataFont)
dxDrawText(\"Szükséges szint - \" .. sellVehicles[currSelected][4] .. \"\", left + 55, top * 2.0 + 50, 269, 10, tocolor(255, 255, 255, 255), 0.9, dataFont)
end
addEventHandler(\"onClientKey\", root, function(key, source)
if not source or not isShopActive then return end
if key == \"backspace\" then
exitShop()
elseif key == \"arrow_l\" then
dxDrawImage(left-10, top * 1.92, 414, 163, \"files/arrowbal.png\")
if sellVehicles[currSelected - 1] then
   dxDrawImage(left-10, top * 1.92, 414, 163, \"files/arrowbal.png\")
   currSelected = currSelected - 1
   setElementModel(shopVehicle, sellVehicles[currSelected][1])
else
   currSelected = #sellVehicles
   setElementModel(shopVehicle, sellVehicles[currSelected][1])
end
elseif key == \"arrow_r\" then
dxDrawImage(left+10, top * 1.92, 414, 163, \"files/arrowjobb.png\")
if sellVehicles[currSelected + 1] then
   dxDrawImage(left+10, top * 1.92, 414, 163, \"files/arrowjobb.png\")
   currSelected = currSelected + 1
   setElementModel(shopVehicle, sellVehicles[currSelected][1])
else
   currSelected = 1
   setElementModel(shopVehicle, sellVehicles[currSelected][1])
end
elseif key == \"enter\" then
if sellVehicles[currSelected][3] > getElementData(localPlayer, \"money\") then
   exports.cg_notf:addNotification(\"Nincs elég kézpénzed a jármű megvásárlásához.\", \"error\")
else
   triggerServerEvent(\"onClientBuyVehicle\", localPlayer, localPlayer, sellVehicles[currSelected][1], sellVehicles[currSelected][3])
   exitShop()
end
end
end)
 
function openColorPicker(r, g, b)
if isShopActive then
colorPicker.openSelect(colors)
showCursor(true)
end
end
addEvent(\"openColorPicker\", true)
addEventHandler(\"openColorPicker\", getRootElement(), openColorPicker)
function updateColor()
if (not colorPicker.isSelectOpen) then return end
local r, g, b = colorPicker.updateTempColors()
if (shopVehicle and isElement(shopVehicle)) then
local r1, g1, b1, r2, g2, b2 = getVehicleColor(shopVehicle, true)
if (guiCheckBoxGetSelected(checkColor1)) then
   r1, g1, b1 = r, g, b
end
if (guiCheckBoxGetSelected(checkColor2)) then
   r2, g2, b2 = r, g, b
end
setVehicleColor(shopVehicle, r1, g1, b1, r2, g2, b2)
workaround = {r1, g1, b1, r2, g2, b2}
end
end
function getVehicleRealName(vehicleID)
local realName = sellVehicles[currSelected][vehicleID]
return realName
end
function roundedRectangle(x, y, w, h, borderColor, bgColor, postGUI)
if (x and y and w and h) then
if (not borderColor) then
   borderColor = tocolor(0, 0, 0, 200);
end
if (not bgColor) then
   bgColor = borderColor;
end
--> Background
dxDrawRectangle(x, y, w, h, bgColor, postGUI);
--> Border
dxDrawRectangle(x + 2, y - 1, w - 4, 1, borderColor, postGUI); -- top
dxDrawRectangle(x + 2, y + h, w - 4, 1, borderColor, postGUI); -- bottom
dxDrawRectangle(x - 1, y + 2, 1, h - 4, borderColor, postGUI); -- left
dxDrawRectangle(x + w, y + 2, 1, h - 4, borderColor, postGUI); -- right
end
end

 
sourceS.lua:
 
mysql = exports[\'mysql\']
addEvent(\"onClientBuyVehicle\", true)
addEventHandler(\"onClientBuyVehicle\", root, function(playerSource, model, price)
if exports.ace_global:hasMoney(playerSource, price) then
local insertid = mysql:query_insert_free(\"INSERT INTO vehicles SET model = \'\" .. model .. \"\', x = 2129.607421875, y = -1128.9453125, z = 25.601287841797, currx = 2129.607421875, curry = -1128.9453125, currz = 25.601287841797, rotx = 0, roty = 0, rotz = 90, faction = -1, owner = \" .. getElementData(playerSource, \"dbid\") .. \", locked = 0\")
if insertid then
   local veh = call( getResourceFromName( \"ace_vehicle-system\" ), \"createShopVehicle\", insertid, model, 2129.607421875, -1128.9453125, 25.601287841797, 0, 0, 90, \"DLM - 00\" .. insertid .. \"\")
   setElementRotation(veh, 0, 0, 90)
   setVehicleColor(veh, 0, 0, 0, 0, 0, 0)
   call( getResourceFromName( \"ace_item-rendszer\" ), \"deleteAll\", 38, insertid )
   exports.ace_global:giveItem( playerSource, 38, insertid )
   setElementData(veh, \"dbid\", insertid)
   setElementData(veh, \"enginebroke\", 0)
   setElementData(veh, \"fuel\", 100)
   setElementData(veh, \"engine\", 0)
   setElementData(veh, \"oldx\", 2129.607421875)
   setElementData(veh, \"oldy\", -1128.9453125)
   setElementData(veh, \"oldz\", 25.601287841797)
   setElementData(veh, \"faction\", -1)
   setElementData(veh, \"owner\", getElementData(playerSource, \"dbid\"))
   setElementData(veh, \"job\", 0)
   exports[\'ace_vehicle-system\']:reloadVehicle(insertid)
   mysql:query_free(\"UPDATE characters SET money = money - \'\" .. price .. \"\' WHERE id = \'\" .. getElementData(playerSource, \"dbid\") .. \"\'\")
   setElementData(playerSource, \"money\", getElementData(playerSource, \"money\") - price)
end
end
end)

 
Meta.xml:
 
<meta>
<script src=\"sourceC.lua\" type=\"client\" />
<script src=\"colorpickerC.lua\" type=\"client\" />
<script src=\"sourceS.lua\" type=\"server\" />
<export function=\"getVehicleRealName\" type=\"shared\" />
<file src=\"files/alpha.png\" />
<file src=\"files/palette.png\" />
<file src=\"files/arrowjobb.png\" />
<file src=\"files/arrowbal.png\" />
<file src=\"files/corefont.ttf\" />
</meta>

 
A másik resource is meg van, de azt nem raktam ide, mert fölösleges.
Debugscript:
\"width=500http://kepfeltoltes.hu/160314/703832623N_vtelen-1_www.kepfeltoltes.hu_.png[/img]

Nem tudom megvenni a kiválasztott kocsit!
« Válasz #1 Dátum: 2016. március 23. - 11:28:57 »
0 Show voters
Írj magadnak.. Vagy más szerver fájlai közül vedd ki..  :thumbsup:

Nem tudom megvenni a kiválasztott kocsit!
« Válasz #2 Dátum: 2016. március 24. - 05:08:35 »
0 Show voters
A problémák kiváltó oka 1. Nem tudja oda adni neked a kulcs itemet mert az \"ace-item\" mappában szereplő script deleteall \'lekérdezésel\' nem dolgozik 2. Nem tudja létrehozni a járművet miután nem működik az \"ace-vehicle-system\" Ergo mit tanultunk ma gyerekek ? : Nem a carshop a kuka(habár az is 1 edit szemét) hanem az ace-s cuccaid  (ha nem tudod kijavítani írj rám meló után majd segítek )

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal