Basil.
Wiek: 24 Na forum: 3723 dni Posty: 80
Nick w MP: njefjem
Cze??, mam spraw?.
Posiadam skrypt na suszark?, kt?ry lekko przerobi?em. Teraz chcia?bym zrobi? co? takiego, ?e gdy najad? na samoch?d b?d? gracza, to na ekranie wy?wietla mi si? obrazek, pomo?ecie?
Kod po stronie clienta:
Kod:
local w,h = guiGetScreenSize()
local vehicle={}
vehicle.id=nil
vehicle.speed=nil
vehicle.driver=nil
local option={}
value=nil
element=nil
option.selected=0
option.actived=false
option["vehicle"]={
"Akcja: Napraw pojazd",
"Akcja: Przenie? pojazd",
"Akcja: Przenie? do przechowywalni",
"Akcja: Zaci?gnij/Spu?? r?czny",
"Akcja: Zniszcz pojazd",
}
option["player"]={
"Akcja: Przenie? do siebie",
"Akcja: Brak Akcji",
"Akcja: Przenie? do niego",
}
function isPedAiming ( thePedToCheck )
if isElement(thePedToCheck) then
if getElementType(thePedToCheck) == "player" or getElementType(thePedToCheck) == "ped" then
if getPedTask(thePedToCheck, "secondary", 0) == "TASK_SIMPLE_USE_GUN" then
return true
end
end
end
return false
end
function isRendering()
if option.actived == true then
if not element then return end
local vx,vy,vz=getElementVelocity(element)
local wlasciciel=getElementData(element, "car_owner") or "Publiczny"
mathSpeed=(vx^2+vy^2+vz^2)^0.5*1.8*100
if mathSpeed < 0 then return end
if value == "vehicle" then
local driver=getElementData(element,"vehicle:driver") or "brak"
local id=getElementData(element,"car_id") or "brak"
dxDrawText(string.format("%.02f", mathSpeed).." km/h", (296/1280)*w, (0/720)*h, (2865/2280)*w, (900/720)*h, tocolor(255, 255, 255, 255), (2.00/1280)*w, (2.00/720)*h, "default-bold", "center", "center", false)
dxDrawText("ID pojazdu: "..id..".", (297/1280)*w, (0/720)*h, (1595/1280)*w, (950/720)*h, tocolor(255, 255, 255, 255), (1.00/1280)*w, (1.00/720)*h, "default-bold", "center", "center", false)
dxDrawText("W?a?ciciel: "..wlasciciel.."", (100/1280)*w, (0/720)*h, (1740/1250)*w, (980/720)*h, tocolor(255, 255, 255, 255), (1.00/1280)*w, (1.00/700)*h, "default-bold", "center", "center", false)
dxDrawText(option[value][option.selected] or "Akcja: brak", (688/1280)*w, (0/720)*h, (1180/1280)*w, (1010/720)*h, tocolor(217, 0, 0, 255), (1.00/1280)*w, (1.00/720)*h, "default-bold", "center", "center", false)
end
if value == "player" then
dxDrawText(getPlayerName(element)..".", (486/1280)*w, (0/720)*h, (2580/2280)*w, (950/720)*h, tocolor(255, 255, 255, 255), (1.00/1280)*w, (1.00/720)*h, "default-bold", "center", "center", false)
dxDrawText(option[value][option.selected] or "Akcja: brak", (1288/2280)*w, (0/720)*h, (2150/2280)*w, (1040/720)*h, tocolor(217, 0, 0, 255), (1.00/1280)*w, (1.00/720)*h, "default-bold", "center", "center", false)
end
end
end
function blockShoot()
if getPedWeapon(localPlayer) == 22 then
toggleControl("fire", false)
toggleControl("aim_weapon", true)
toggleControl("action", false)
else
toggleControl("fire", false)
end
end
addEventHandler("onClientRender", root, blockShoot)
addEventHandler("onClientPlayerTarget",root,
function(el)
if isPedAiming(localPlayer) and el and getPedWeapon(localPlayer) == 22 then
if not option.actived then
if getElementType(el) == "vehicle" then
value="vehicle"
element=el
option.actived=true
elseif getElementType(el) == "player" then
value="player"
element=el
option.actived=true
else return end
bindKey("mouse1", "down", onElementClicked)
bindKey("mouse_wheel_down", "down", onElementMoveDown)
bindKey("mouse_wheel_up", "down", onElementMoveUp)
addEventHandler("onClientHUDRender", root, isRendering)
end
else
if option.actived then
vehicle.el=nil
option.actived=false
unbindKey("mouse1", "down", onElementClicked)
unbindKey("mouse_wheel_down", "down", onElementMoveDown)
unbindKey("mouse_wheel_up", "down", onElementMoveUp)
removeEventHandler("onClientHUDRender", root, isRendering)
end
end
end)
function onElementMoveUp() if option.selected > 5 then option.selected=1 else option.selected=option.selected+1 end end
function onElementMoveDown() if option.selected < 1 then option.selected=5 else option.selected=option.selected-1 end end
function onElementClicked() if option.selected > 0 then triggerServerEvent("onDryerAction", localPlayer, value, option.selected, element) end end