Witam, od jakiegos czasu bawie sie troszke w LUA - sa to moje poczatki, dopiero zaczynam ogarniac jak co dziala.
Mam problem z isPedInVehicle
Kod wyglada tak
[lua]function spawnInfernus(plr)
local x,y,z = getElementPosition(plr)
if IsPlayerInVehicle(plr) then
createVehicle(411, x+2,y+2,z)
outputChatBox("Infernus zostal zrespiony",plr,0,255,0)
else
outputChatBox("Wyjdz z pojazdu",plr,255,0,0)
end
end
addCommandHandler("infernus", spawnInfernus)
function spawnTurismo(plr)
local x,y,z = getElementPosition(plr)
if IsPlayerInVehicle(plr) then
createVehicle(451, x+2,y+2,z)
outputChatBox("Turismo zostalo zrespione",plr,0,255,0)
else
outputChatBox("Wyjdz z pojazdu",plr,255,0,0)
end
end
addCommandHandler("turismo", spawnTurismo)[/lua]
Bledy przy wpisywaniu komendy /turismo oraz /infernus:
ERROR: tworzeniepojazdows.lua:31: attempt to call global 'IsPedInVehicle' (a nil value)
ERROR: tworzeniepojazdows.lua:42: attempt to call global 'IsPedInVehicle' (a nil value)
Domyslam sie, ze jest tu jakas prosta sprawa ale nie mam zielonego pojecia co trzeba zrobic. I jakby ktos mial sie doczepic to szukalem w google i posty tutaj na ten temat ale nic nie znalazlem, a przynajmniej nic co by pomoglo.
EDIT:
Blad naprawilem ale wtedy komendy dotycza tylko mnie, jak zrobic aby dotyczylo to gracza ktory wpisuje komende?
[lua]function spawnInfernus(plr)
local x,y,z = getElementPosition...
WARNING: test/server.lua:41: Bad argument @ 'isPedInVehicle' [Expected ped at argument 1, got vehicle] - taki b??d wyskakuje bo wjechaniu w marker, a kod;
addEventHandler('onMarkerHit',MarkerMech,function(Player)
if not isPedInVehicle (Player) then
return
end
if isElementWithinMarker(Player,MarkerMech) then
triggerClientEvent(Player,"PokazGuiNaprawa",root)
triggerClientEvent(Player,"PokazButony",root)
showCursor(Player,true)
end
end)
function NaprawaPojazdu(source)
if isElementWithinMarker(source,MarkerMech) then
local Pojazd = getPedOccupiedVehicle(source)
local Nazwa = getVehicleName(Pojazd)
local Kasa = getPlayerMoney(source)
if (Kasa > 51) then
takePlayerMoney(source, 50)
fixVehicle(Pojazd, true)
end
end
end
addEventHandler('GuiMech',root,NaprawaPojazdu)
addEventHandler('onMarkerHit',MarkerMech2,function(Player)
if not isPedInVehicle (Player) then
return
end
if isElementWithinMarker(Player,MarkerMech2) then
triggerClientEvent(Player,"PokazGuiNaprawa",root)
triggerClientEvent(Player,"PokazButony",root)
showCursor(Player,true)
end
end)
function NaprawaPojazdu2(source)
if isElementWithinMarker(source,MarkerMech2) then
local Pojazd = g...
mam problem nie wiem czemu funkcja dzia?a ale wywala mi b??d do wy?ej napisanego kodu.
Wyci?g z debugu:
prosz? o pomoc, dopiero sie ucz? wi?c nie wiem co jest nie tak, funkcja jak m?wi?em dzia?a, ale zale?y mi na jak najlepszym kodzie nie wywalaj?cym b?edu.