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

Wysłany: 2020-04-07, 15:48


SamuelXDXD

Początkujący w C#






Wiek: 25
Na forum: 2731 dni
Posty: 17
Nick w MP: Kezoto



Respekt: 50

A jak ustawi? rotacj? bo jest ustawione g?r? do do?u?
Dzi?kuj? dzia?a Wilq ten client

Dodano: 2020-04-07, 15:45
Mam taki o to skrypt na nosze:

c.lua

-- USEFUL FUNCTION
function isEventHandlerAdded( sEventName, pElementAttachedTo, func )
if
type( sEventName ) == 'string' and
isElement( pElementAttachedTo ) and
type( func ) == 'function'
then
local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo )
if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then
for i, v in ipairs( aAttachedFunctions ) do
if v == func then
return true
end
end
end
end

return false
end
--


local data = {object = nil, player = nil}

function deleteRotation()
if isEventHandlerAdded( 'onClientPreRender', root, changeRotation ) then
removeEventHandler( 'onClientPreRender', root, changeRotation )
end
end
addEvent("iyw_samd_stretcher:deleteRotation", true)
addEventHandler("iyw_samd_stretcher:deleteRotation", root, deleteRotation)

function changeRotation()
if not data.player then deleteRotation() end
if not data.object then deleteRotation() end
local rotation = {getElementRotation(data.object)}
data.player.rotation = Vector3(rotation[1], rotation[2], rotation[3]+90)
end



addEvent("iyw_samd_stretcher:rotation", true)
addEventHandler("iyw_samd_stretcher:rotation", root, function(player, object)
data.object = object
data.player = player
addEventHandler("onClientPreRender", root, changeRotation)
end)

s.lua :

object = {}
attach = {}
controls = {"jump", "sprint", "crouch", "enter_exit", "enter_passenger"}

addCommandHandler("nosze-pomoc", function(player, cmd)
if getElementData(player, "player:faction") == "SAMC" then
outputChatBox("/nosze - rozstawia nosze przed Nami / usuwa nosze", player, 0, 255, 0)
outputChatBox("/nosze-ustaw [id] - ustawia gracza na noszach", player, 0, 255, 0)
outputChatBox("/nosze-zdejmij [id] - zdejmuje gracza z noszy", player, 0, 255, 0)
else
triggerClientEvent(player, 'iyw_notifications:send', player, "Nie jeste? na s?u?bie SAMD!", 'warning')
end
end)

function nosze(player, cmd)
if getElementData(player, "player:faction") == "SAMC" then
--if not getElementData(player,"mozenosze") then return triggerClientEvent(player, 'iyw_notifications:send', player, "error", "Nie jeste? w miejscu do tego przeznaczonym!") end
if not getElementData(player,"nosze") then
setElementData(player, "nosze", true)
object[player] = Object(1997, 0, 0, 0)
object[player]:attach(player, 0, 1.3, -1)
object[player]:setCollisionsEnabled(false)
else
removeElementData(player, "nosze")
if object[player] then
destroyElement(object[player])
end
end
else
triggerClientEvent(player, 'iyw_notifications:send', player, "error", "Nie jeste? na s?u?bie SAMD!")
end
end
addCommandHandler("nosze", nosze)

function ustaw(player, cmd, target)
if object[player] then
if not attach[player] then
local target = exports["pystories-core"]:findPlayer(player, target)
if not target then
triggerClientEvent(player, 'iyw_notifications:send', player, "error", "Nie znaleziono podanego gracza!")
return
end
if not getElementData(player, "nosze") then triggerClientEvent(player, 'iyw_notifications:send', player, "error", "Nie posiadasz roz?o?onych noszy!") return end
if (player.position-Vector3(getElementPosition(target))).length < 5 then
if not target.vehicle then
target:attach(object[player], 0, -0.2, 2)
attach[player] = target

for _,control in ipairs(controls) do
toggleControl(player, control, false)
end
local rotation = {getElementRotation(player)}
target:setAnimation("CRACK", "crckidle4", -1, true, false)
Timer(function() triggerClientEvent(target, "iyw_samd_stretcher:rotation", root, target, object[player],true) end, 500, 1)
else
triggerClientEvent(player, "iyw_notifications:send", player, "error", "Podany gracz znajduje si? w poje?dzie, nie mo?esz wzi?? go na nosze!")
end
else
triggerClientEvent(player, "iyw_notifications:send", player, "error", "Znajdujesz si? zbyt daleko od gracza, kt?rego chcesz wzi?? na nosze!")
end
else
triggerClientEvent(player, "iyw_notifications:send", player, "error", "Na tych noszach ju? kto? si? znajduje!")
end
else
triggerClientEvent(player, "iyw_notifications:send", player, "error", "Nie posiadasz roz?o?onych noszy!")
end
end
addCommandHandler("nosze-ustaw", ustaw)
function zdejmij(player, cmd, target)
if object[player] then
if attach[player] then
for _,control in ipairs(controls) do
toggleControl(player, control, true)
end
local target = exports["pystories-core"]:findPlayer(player, target)
if not target then
triggerClientEvent(player, 'iyw_notifications:send', player, "error", "Nie znaleziono podanego gracza!")
return
end
target:detach(object[player])
attach[player] = false
triggerClientEvent(target, "iyw_samd_stretcher:deleteRotation", root)
else
triggerClientEvent(player, "iyw_notifications:send", player, "error", "Na tych noszach nie znajduje si? nikt!")
end
else
triggerClientEvent(player, "iyw_notifications:send", player, "error", "Nie posiadasz roz?o?onych noszy!")
end
end
addCommandHandler("nosze-zdejmij",zdejmij)
addEventHandler("onPlayerQuit",root,function(_,_,_)
local player=source
if object[player] then
if attach[player] then
attach[player]:detach(object[player])
triggerClientEvent(attach[player], "iyw_samd_stretcher:deleteRotation", root)
attach[player] = false
end
destroyElement(object[player])
end
end)

function getTarget(player)
if not player then return end
if attach[player] then return attach[player] end
return false
end

function usun(player,target)
if not player then return end
if not target then return end
if attach[player] then
for _,control in ipairs(controls) do
toggleControl(player, control, true)
end
target:detach(object[player])
attach[player] = false
triggerClientEvent(target, "iyw_samd_stretcher:deleteRotation", root)
end
if getElementData(player,"nosze") then
removeElementData(player, "nosze")
if object[player] then
destroyElement(object[player])
end
end
end

:p
meta:

<meta>
<script src="s.lua" type="server" />
<script src="c.lua" type="client" cache="false" />
<export function="usun" type="server"/>
<export function="getTarget" type="server"/>
<oop>true</oop>
</meta>





Jak tutaj ustawi? rotacj? noszy? w sensie podmienione stoj? przodem w d?? i chcia?bym zmieni? by sta?y prosto.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-04-07, 17:07


Wilq







Wiek: 24
Na forum: 4429 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8


Więcej informacji znajdziesz w Wikipedii MTA:

setElementRotation


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-04-23, 23:42


SamuelXDXD

Początkujący w C#






Wiek: 25
Na forum: 2731 dni
Posty: 17
Nick w MP: Kezoto



Respekt: 50

Dobra mo?na zamkn??, nigdy nie zrobie kodu w Lua, wol? si? rozwija? w C#

Postaw piwo autorowi tego posta
 

 
Tagi: [lua] :: nie :: mogę :: ustawić :: rotację :: noszy!
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

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