Wysłany: 2012-08-29, 19:47
luki123luki123
Place Game
Wiek: 28 Na forum: 5275 dni Posty: 1948
Nick w MP: LuKiO
Piwa : 6101
Witam dzi? chce si? zapyta? jak zrobi? ma?a blokad? np. na team lub acl do tego skryptu
serwer
function onCreateStinger ( x , y , z , rx , ry , rz )
stinger = createObject ( 2899 , x , y , z + 0.1 , rx , ry , rz )
setElementData ( stinger , "isStinger" , true )
triggerClientEvent ( "onCreateStinger" , getRootElement (), x , y , z )
stingerPlant ( source )
end
addEvent ( "onCreateStinger" , true )
addEventHandler ( "onCreateStinger" , getRootElement (), onCreateStinger )
function stingerPlant ( player )
setPedAnimation ( player , "BOMBER" , "BOM_plant" , 3000 , false , false , false )
setTimer ( setPedAnimation , 2000 , 1 , player )
end
klient
function getPointFrontOfElement ( element , distance )
local x , y , z = getElementPosition ( element )
local rx , ry , rz = getElementRotation ( element )
x = x + ( distance * ( math . sin ( math . rad (- rz ))) )
y = y + ( distance * ( math . cos ( math . rad (- rz ))) )
return x , y , z
end
function getPositionFromElementAtOffset ( element , x , y , z )
if not x or not y or not z then
return x , y , z
end
local matrix = getElementMatrix ( element )
local offX = x * matrix [ 1 ][ 1 ] + y * matrix [ 2 ][ 1 ] + z * matrix [ 3 ][ 1 ] + matrix [ 4 ][ 1 ]
local offY = x * matrix [ 1 ][ 2 ] + y * matrix [ 2 ][ 2 ] + z * matrix [ 3 ][ 2 ] + matrix [ 4 ][ 2 ]
local offZ = x * matrix [ 1 ][ 3 ] + y * matrix [ 2 ][ 3 ] + z * matrix [ 3 ][ 3 ] + matrix [ 4 ][ 3 ]
return offX , offY , offZ
end
function getVehicleWheelPosition ( vehicle , wheel )
local x , y , z = 0 , 0 , 0
local minX , minY , minZ , maxX , maxY , maxZ = getElementBoundingBox ( vehicle )
if wheel == 1 then
x , y , z = getPositionFromElementAtOffset ( vehicle , minX , maxY , minZ )
elseif wheel == 2 then
x , y , z = getPositionFromElementAtOffset ( vehicle , minX , - maxY , minZ )
elseif wheel == 3 then
x , y , z = getPositionFromElementAtOffset ( vehicle , maxX , maxY , minZ )
elseif wheel == 4 then
x , y , z = getPositionFromElementAtOffset ( vehicle , maxX , - maxY , minZ )
end
return x , y , z
end
function team ()
if getPlayerTeam ( getLocalPlayer () == getTeamFromName ( "Policja" )) then
end
end
function plantStingerCommand ()
local x , y , z = getPointFrontOfElement ( getLocalPlayer (), 3 )
local rx , ry , rz = getElementRotation ( getLocalPlayer ())
z = getGroundPosition ( x , y , z )
triggerServerEvent ( "onCreateStinger" , getLocalPlayer (), x , y , z , rx , ry , rz )
end
bindKey ( "x" , "down" , plantStingerCommand )
function onClientRender ()
if isPedInVehicle ( getLocalPlayer ()) then
vehicle = getPedOccupiedVehicle ( getLocalPlayer ())
g_Stingers = getElementsByType ( "object" )
-- local wx0 , wy0 , wz0 = getVehicleWheelPosition ( vehicle , 0 )
local wx1 , wy1 , wz1 = getVehicleWheelPosition ( vehicle , 1 )
local wx2 , wy2 , wz2 = getVehicleWheelPosition ( vehicle , 2 )
local wx3 , wy3 , wz3 = getVehicleWheelPosition ( vehicle , 3 )
local wx4 , wy4 , wz4 = getVehicleWheelPosition ( vehicle , 4 )
-- for visual debug wheel positions
-- dxDrawLine3D ( wx1 , wy1 , wz1 , wx2 , wy2 , wz2 , tocolor ( 0 , 255 , 0 ))
-- dxDrawLine3D ( wx3 , wy3 , wz3 , wx4 , wy4 , wz4 , tocolor ( 0 , 255 , 0 ))
for k , v in ipairs ( g_Stingers ) do
if getElementData ( v , "isStinger" ) == true then
local vx , vy , vz = getElementPosition ( v )
if getDistanceBetweenPoints3D ( wx1 , wy1 , wz1 , vx , vy , vz ) <= 2.0 then
setVehicleWheelStates ( vehicle , 1 , - 1 , - 1 , - 1 )
end
if getDistanceBetweenPoints3D ( wx2 , wy2 , wz2 , vx , vy , vz ) <= 2.0 then
setVehicleWheelStates ( vehicle , - 1 , 1 , - 1 , - 1 )
end
if getDistanceBetweenPoints3D ( wx3 , wy3 , wz3 , vx , vy , vz ) <= 2.0 then
setVehicleWheelStates ( vehicle , - 1 , - 1 , 1 , - 1 )
end
if getDistanceBetweenPoints3D ( wx4 , wy4 , wz4 , vx , vy , vz ) <= 2.0 then
setVehicleWheelStates ( vehicle , - 1 , - 1 , - 1 , 1 )
end
end
end
end
end
addEventHandler ( "onClientRender" , getRootElement (), onClientRender )
function onCreateStinger ( x , y , z )
if( getDistanceBetweenPoints3D ( x , y , z , getElementPosition ( getLocalPlayer ())) <= 10 ) then
local sound = playSound3D ( "plant.wav" , x , y , z )
setSoundMaxDistance ( sound , 10 )
end
end
addEvent ( "onCreateStinger" , true )
addEventHandler ( "onCreateStinger" , getRootElement (), onCreateStinger )
Wiem ?e jest z neta ale potrzebuje tego skryptu do mojego rpg
Wysłany: 2012-08-29, 21:03
Riot
3X
Wiek: 29 Na forum: 5729 dni Posty: 1123
Nick w MP: Riot/3X
Piwa : 286
Czy m?g?by? ?askawie napisa? to jeszcze raz, tylko po POLSKU by?my zrozumieli?
Wysłany: 2012-08-29, 21:14
luki123luki123
Place Game
Wiek: 28 Na forum: 5275 dni Posty: 1948
Nick w MP: LuKiO
Piwa : 6101
?eby np gracz nie m?g? podstawi? blokady tylko policja
Wysłany: 2012-08-29, 21:23
Riot
3X
Wiek: 29 Na forum: 5729 dni Posty: 1123
Nick w MP: Riot/3X
Piwa : 286
if getPlayerTeam ( source ) == getTeamFromName ( "Nazwa_Teamu" ) then
Wysłany: 2012-08-29, 21:29
luki123luki123
Place Game
Wiek: 28 Na forum: 5275 dni Posty: 1948
Nick w MP: LuKiO
Piwa : 6101
Ziomek11 , wiem ale nie dzia?a
function team ()
if getPlayerTeam ( getLocalPlayer ) == getTeamFromName ( "Policja" )) then
end
end
Wysłany: 2012-08-29, 21:31
Riot
3X
Wiek: 29 Na forum: 5729 dni Posty: 1123
Nick w MP: Riot/3X
Piwa : 286
Ale dajesz to po stronie clietna ? Bo getLocalPlayer() mo?esz dawa? tylko po stronie clienta.
Wysłany: 2012-08-29, 21:52
luki123luki123
Place Game
Wiek: 28 Na forum: 5275 dni Posty: 1948
Nick w MP: LuKiO
Piwa : 6101
no clinet
[ Dodano : 2012-08-29, 22:02 ]
ok zrobi?em dzi?a bez czatbox ale jak zrobi? z nim
function plantStingerCommand ()
if getPlayerTeam ( getLocalPlayer () ) == getTeamFromName ( "Policja" ) then
else outputChatBox ( "Nie Jeste? policjantem" , source )
local x , y , z = getPointFrontOfElement ( getLocalPlayer (), 3 )
local rx , ry , rz = getElementRotation ( getLocalPlayer ())
z = getGroundPosition ( x , y , z )
triggerServerEvent ( "onCreateStinger" , getLocalPlayer (), x , y , z , rx , ry , rz )
end
end
bindKey ( "x" , "down" , plantStingerCommand )
[ Dodano : 2012-08-29, 22:14 ]
ok dzia?a teraz tylko jak jeste? w policji to ci te? pisz?
function plantStingerCommand ()
outputChatBox ( "Nie Jeste? policjantem" , getLocalPlayer () )
if getPlayerTeam ( getLocalPlayer () ) == getTeamFromName ( "Policja" ) then
local x , y , z = getPointFrontOfElement ( getLocalPlayer (), 3 )
local rx , ry , rz = getElementRotation ( getLocalPlayer ())
z = getGroundPosition ( x , y , z )
triggerServerEvent ( "onCreateStinger" , getLocalPlayer (), x , y , z , rx , ry , rz )
end
end
bindKey ( "x" , "down" , plantStingerCommand )
Wysłany: 2012-08-29, 23:15
Piorun
Wiek: 32 Na forum: 6712 dni Posty: 1837
Nick w MP: Piorun
Piwa : 516
Nie tw?j skrypt + nie potrafisz tworzy? warunk?w. Stworzy?e? warunek, a przed nim utworzy?e? funkcj?, kt?ra ma si? po nim wykona? .. gdzie tu logika?
Najpierw warunek, lub warunki
if .. and .. and .. and .. then
potem dajesz funkcje lub zatwierdzasz zmienne..
outputChatBox (...)
local x = ...
... i zamykasz
Kompletnie nie znasz podstaw.
Wysłany: 2012-08-30, 10:28
luki123luki123
Place Game
Wiek: 28 Na forum: 5275 dni Posty: 1948
Nick w MP: LuKiO
Piwa : 6101
Tagi: kolczatka
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: