Szerző Téma: [SCRIPT]Normál karakter irányítás  (Megtekintve 3246 alkalommal)

[SCRIPT]Normál karakter irányítás
« Dátum: 2016. November 04. - 00:07:57 »
+1
Üdv!
SA:MP-ról váltottam MTA-ra és elég fura volt az irányítása a karakternek, ezért összedobtam egy kliens oldali szkriptet, ami megoldotta ezt a problémát.
Itt az új verzió amiben semmilyen ütközés nincs:
 

local upgomb = false
local downgomb = false
local leftgomb = false
local rightgomb = false
function playerPressedKey(button, press)
    if (press) then
       if button == \"arrow_l\" or button== \"a\"  then
           leftgomb = true
          cancelEvent()
       end
       if button == \"arrow_r\" or button==\"d\"  then
           rightgomb = true
          cancelEvent()
       end
       if button == \"arrow_u\" or button == \"w\" then
           upgomb = true
          cancelEvent()
       end
       if button == \"arrow_d\" or button==\"s\" then
           downgomb = true
          cancelEvent()
       end
    else
       if button == \"arrow_l\" or button== \"a\"  then
           leftgomb = false
          cancelEvent()
           --setAnalogControlState(\"left\", 0)
       end
       if button == \"arrow_r\" or button==\"d\"  then
           rightgomb = false
          cancelEvent()
   --setAnalogControlState(\"right\", 0)
       end
       if button == \"arrow_u\" or button == \"w\" then
           upgomb = false
          cancelEvent()
   --setAnalogControlState(\"forwards\", 0)
       end
       if button == \"arrow_d\" or button==\"s\" then
           downgomb = false
          cancelEvent()
           --setAnalogControlState(\"backwards\", 0)
       end
    end
end
function processKeys()
if upgomb and downgomb  and getAnalogControlState(\"backwards\") == 0 then
setAnalogControlState(\"backwards\", 1)
elseif leftgomb and rightgomb and getAnalogControlState(\"right\") == 0 then
setAnalogControlState(\"right\", 1)
elseif upgomb and leftgomb   and rightgomb and getAnalogControlState(\"right\") == 0 then
setAnalogControlState(\"right\", 1)
elseif downgomb and leftgomb and rightgomb and getAnalogControlState(\"right\") == 0 then
setAnalogControlState(\"right\", 1)
end
if upgomb and rightgomb then
setAnalogControlState(\"forwards\", 0)
setAnalogControlState(\"right\", 1)
setAnalogControlState(\"forwards\", 1)
end
if downgomb and rightgomb then
setAnalogControlState(\"backwards\", 0)
setAnalogControlState(\"right\", 1)
setAnalogControlState(\"backwards\", 1)
end
if upgomb and (not downgomb) and getAnalogControlState(\"forwards\") == 0 then
setAnalogControlState(\"backwards\",0)
setAnalogControlState(\"forwards\",1)
end
if leftgomb and (not rightgomb) and getAnalogControlState(\"left\") == 0 then
setAnalogControlState(\"left\", 1)
--setAnalogControlState(\"right\", 0)
end
if (not upgomb) and downgomb and getAnalogControlState(\"backwards\") == 0 then
setAnalogControlState(\"backwards\",1)
--setAnalogControlState(\"forwards\",0)
end
if (not leftgomb) and rightgomb and getAnalogControlState(\"right\") == 0 then
--setAnalogControlState(\"left\", 1)
setAnalogControlState(\"right\", 1)
--setAnalogControlState(\"left\", 0)
end
if getAnalogControlState(\"right\") == 1 and not rightgomb then
setAnalogControlState(\"right\", 0)
end
if getAnalogControlState(\"left\") == 1 and not leftgomb then
setAnalogControlState(\"left\", 0)
end
if getAnalogControlState(\"forwards\") == 1 and not upgomb then
setAnalogControlState(\"forwards\", 0)
end
if getAnalogControlState(\"bacwards\") == 1 and not downgomb then
setAnalogControlState(\"bacwards\", 0)
end
end
addEventHandler(\"onClientRender\", root, processKeys)
addEventHandler(\"onClientKey\", root, playerPressedKey)

 
Spoiler for régebbi verzió:
local upgomb = false
local downgomb = false
local leftgomb = false
local rightgomb = false
function playerPressedKey(button, press)
    if (press) then
       
       if button == \"arrow_l\" or button== \"a\"  then
           leftgomb = true
       end
       if button == \"arrow_r\" or button==\"d\"  then
           rightgomb = true
       end
       if button == \"arrow_u\" or button == \"w\" then
           upgomb = true
       end
       if button == \"arrow_d\" or button==\"s\" then
           downgomb = true
       end
    else
       
       if button == \"arrow_l\"or button== \"a\"   then
           leftgomb = false
       end
       if button == \"arrow_r\"  or button==\"d\" then
           rightgomb = false
       end
       if button == \"arrow_u\" or button == \"w\" then
           upgomb = false
       end
       if button == \"arrow_d\" or button==\"s\" then
           downgomb = false
       end
    end
end
 
function processKeys()
if upgomb and downgomb then
setAnalogControlState(\"backwards\", 1)
elseif leftgomb and rightgomb then
setAnalogControlState(\"right\", 1)
elseif upgomb and leftgomb   and rightgomb then
setAnalogControlState(\"right\", 1)
elseif downgomb and leftgomb and rightgomb then
setAnalogControlState(\"right\", 1)
else
if not downgomb then
   setAnalogControlState(\"backwards\", 0)
end
if not rightgomb then
   setAnalogControlState(\"right\", 0)
end
end
end
addEventHandler(\"onClientRender\", root, processKeys)
addEventHandler(\"onClientKey\", root, playerPressedKey)
« Utoljára szerkesztve: 2016. November 06. - 14:41:44 írta 1ST_Chr »

Nem elérhető Xenius

  • 668
    • Profil megtekintése
[SCRIPT]Normál karakter irányítás
« Válasz #1 Dátum: 2016. November 21. - 20:23:16 »
0
A végén elírtad a nevet, \"bacwards\".

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal