Wysłany: 2018-07-06, 09:09
adisonboss
Wiek: 23 Na forum: 3331 dni Posty: 237
Piwa : 6
Witam. Jak doda? ?eby wsadzanie do wi?zienia dzia?a?o tylko dla ACL Policja. Czy nale?y doda? to doda? pojedynczo przy ka?dej funkcji czy og?lnie na samym pocz?tku skryptu. Je?li b?dzie potrzebna strona server to dam. Za pomoc i
--***********************************--
--***********************************--
-- Jail System --
-- By sebikLOL --
-- Client Side --
--***********************************--
--***********************************--
lp = getLocalPlayer ()
rRoot = getResourceRootElement ( getThisResource ())
setElementData ( lp , "jailed" , false )
------
addEventHandler ( "onClientResourceStart" , rRoot ,function()
triggerServerEvent ( "getDataz" , lp , lp )
outputDebugString ( "Jail System v2.1 By sebikLOL | Started" )
end )
desz = {}
addEvent ( "sendDataz" , true )
addEventHandler ( "sendDataz" , root ,function( jTable , tTable )
------
jWin = guiCreateWindow ( 460 , 172 , 445 , 416 , "Jail System v2.1 | By sebikLOL" , false )
--- Center Window ---
local screenW , screenH = guiGetScreenSize ()
local windowW , windowH = guiGetSize ( jWin , false )
local x , y = ( screenW - windowW )/ 2 ,( screenH - windowH )/ 2
guiSetPosition ( jWin , x , y , false )
----- Center Window -----
guiSetVisible ( jWin , false )
guiWindowSetSizable ( jWin , false )
-------------------------
jBut = guiCreateButton ( 247 , 338 , 167 , 31 , "Aresztuj go" , false , jWin )
tGrid = guiCreateGridList ( 240 , 184 , 190 , 144 , false , jWin )
guiGridListSetSelectionMode ( tGrid , 0 )
-------
--
sEdit = guiCreateEdit ( 14 , 380 , 217 , 23 , "Wyszukaj..." , false , jWin )
--
--------
local timeC = guiGridListAddColumn ( tGrid , "Czas" , 0.85 )
if timeC then
for k , v in ipairs ( tTable ) do
local time = v [ 1 ]
local des = v [ 2 ]
local row = guiGridListAddRow ( tGrid )
desz [ row ] = des
guiGridListSetItemText ( tGrid , row , timeC , time .. " " .. des , false , true )
end
local row = guiGridListAddRow ( tGrid )
guiGridListSetItemText ( tGrid , row , timeC , "Inny..." , false , true )
end
--------
jGrid = guiCreateGridList ( 240 , 31 , 190 , 144 , false , jWin )
guiGridListSetSelectionMode ( jGrid , 0 )
--------
local jailC = guiGridListAddColumn ( jGrid , "Wi?zienie" , 0.85 )
for k , v in ipairs ( jTable ) do
local name = v [ 1 ]
local row = guiGridListAddRow ( jGrid )
guiGridListSetItemText ( jGrid , row , jailC , name , false , false )
end
jcBut = guiCreateButton ( 246 , 378 , 172 , 24 , "Zamknij" , false , jWin )
function jailShow ()
guiSetVisible ( jWin , not guiGetVisible ( jWin ) )
showCursor ( guiGetVisible ( jWin ) )
guiSetInputEnabled ( guiGetVisible ( jWin ) )
destroyElement ( pList )
-- Players List
pList = guiCreateGridList ( 14 , 31 , 218 , 338 , false , jWin )
column = guiGridListAddColumn ( pList , "Player" , 0.85 )
if ( column ) then
for id , player in ipairs ( getElementsByType ( "player" )) do
row = guiGridListAddRow ( pList )
guiGridListSetItemText ( pList , row , column , getPlayerName ( player ), false , false )
end
end
-- Players List
end
addEvent ( "jailShow" , true )
addEventHandler ( "jailShow" , root , jailShow )
function changeText ( button , state , x , y )
selectedRow , selectedCol = guiGridListGetSelectedItem ( pList )
sPlayer = guiGridListGetItemText ( pList , selectedRow , selectedCol )
local thePlr = getPlayerFromName ( sPlayer )
if thePlr then
local isJailed = getElementData ( thePlr , "jailed" )
if isJailed == false then
guiSetText ( jBut , "Aresztuj go" )
elseif isJailed == true then
guiSetText ( jBut , "Wyci?gnij go" )
end
end
end
addEventHandler ( "onClientGUIClick" , root , changeText )
function onClick ( button , state , absoluteX , absoluteY )
selectedRow , selectedCol = guiGridListGetSelectedItem ( pList )
sPlayer = guiGridListGetItemText ( pList , selectedRow , selectedCol )
jail = guiGridListGetItemText ( jGrid , guiGridListGetSelectedItem ( jGrid ), 1 )
time = guiGridListGetItemText ( tGrid , guiGridListGetSelectedItem ( tGrid ), 1 )
timeDes = tostring ( desz [ guiGridListGetSelectedItem ( tGrid )])
if ( source == jBut ) then
if guiGetText ( jBut ) == "Aresztuj go" then
if time ~= "Other .." then
triggerServerEvent ( "JailHimx" , lp , sPlayer , jail , time , timeDes )
else
createTimeSelect ( sPlayer , jail )
end
elseif guiGetText ( jBut ) == "Wyci?gnij go" then
triggerServerEvent ( "unJailHim" , lp , sPlayer )
end
----------
elseif ( source == jcBut ) then
guiSetVisible ( jWin , false )
showCursor ( false )
guiSetInputEnabled ( false )
end
end
addEventHandler ( "onClientGUIClick" , root , onClick )
------------
end )
addEventHandler ( "onClientPlayerDamage" , root ,function( at )
if getElementData ( source , "jailed" ) == true then
if at then cancelEvent () end
end
end )
-------
addEventHandler ( "onClientGUIClick" , root ,function()
if source == sEdit then
guiSetText ( sEdit , "" )
--[[
else
guiSetText ( sEdit , "Search .." )
--]]
end end )
addEventHandler ( "onClientGUIChanged" , root ,function()
if source == sEdit then
------
guiGridListClear ( pList )
for k , v in ipairs ( getElementsByType ( "player" ) ) do
local name = string . lower ( getPlayerName ( v ))
if name then
if string . find ( name , string . lower ( guiGetText ( sEdit )) ) then
row = guiGridListAddRow ( pList )
guiGridListSetItemText ( pList , row , column , getPlayerName ( v ), false , false )
end
end
end
end
------
end )
------
function createTimeSelect ( theJailed , theJail )
if not tostring ( theJailed ) then outputChatBox ( "** #FFFF00Wybierz gracza !" , 255 , 0 , 0 , true ) return end
if not tostring ( theJail ) then outputChatBox ( "** #FFFF00Wybierz gracza aby da? go do wiezienia !" , 255 , 0 , 0 , true ) return end
if isElement ( TimeSelect_Window ) then return end
TimeSelect_Window = guiCreateWindow ( 550 , 397 , 270 , 125 , "Wpisz czas" , false )
--
local screenW , screenH = guiGetScreenSize ()
local windowW , windowH = guiGetSize ( TimeSelect_Window , false )
local x , y = ( screenW - windowW )/ 2 ,( screenH - windowH )/ 2
guiSetPosition ( TimeSelect_Window , x , y , false )
--
-- guiSetVisible ( jWin , false )
--
TimeSelect_Edit = guiCreateEdit ( 15 , 37 , 89 , 26 , "" , false , TimeSelect_Window )
TimeSelect_Label = guiCreateLabel ( 110 , 41 , 10 , 15 , "in" , false , TimeSelect_Window )
TimeSelect_Grid = guiCreateGridList ( 126 , 31 , 130 , 95 , false , TimeSelect_Window )
guiGridListSetSelectionMode ( TimeSelect_Grid , 2 )
---
column = guiGridListAddColumn ( TimeSelect_Grid , "" , 0.80 )
r1 = guiGridListAddRow ( TimeSelect_Grid )
r2 = guiGridListAddRow ( TimeSelect_Grid )
r3 = guiGridListAddRow ( TimeSelect_Grid )
guiGridListSetItemText ( TimeSelect_Grid , r1 , column , "Godziny" , false , false )
guiGridListSetItemText ( TimeSelect_Grid , r2 , column , "Minuty" , false , false )
guiGridListSetItemText ( TimeSelect_Grid , r3 , column , "Sekundy" , false , false )
TimeSelect_Button = guiCreateButton ( 14 , 72 , 91 , 40 , "OK" , false , TimeSelect_Window )
--
function onOk ()
if source == TimeSelect_Button then
--
removeEventHandler ( "onClientGUIClick" , root , onOk )
--
----------------
theTime = guiGetText ( TimeSelect_Edit )
timeType = guiGridListGetItemText ( TimeSelect_Grid , guiGridListGetSelectedItem ( TimeSelect_Grid ) )
--
destroyElement ( TimeSelect_Window )
jailShow ()
--
if tonumber ( theTime ) then
if tostring ( timeType ) then
triggerServerEvent ( "JailHimx" , lp , theJailed , theJail , theTime .. " " .. timeType , timeType , true )
else
outputChatBox ( "** #FFFF00Prosze wybierz minuty, sekundy, godziny !" , 255 , 0 , 0 , true )
end
else
outputChatBox ( "** #FFFF00Please Enter a Number !" , 255 , 0 , 0 , true )
end
----------------
end
end
addEventHandler ( "onClientGUIClick" , root , onOk )
end
Wysłany: 2018-07-06, 10:54
AppleSir
Majster LUA
Wiek: 27 Na forum: 3045 dni Posty: 19
Nick w MP: Przybysz
Wysłany: 2018-07-06, 10:58
adisonboss
Wiek: 23 Na forum: 3331 dni Posty: 237
Piwa : 6
Dobrze wiem jak to da? ale og?lnie na pocz?tku skryptu czy przy ka?dej funkcji
Wysłany: 2018-07-06, 11:20
Kalizman
Wiek: 23 Na forum: 3651 dni Posty: 1394
Piwa : 4619
adisonboss , po wej?ciu w marker sprawdzasz czy jest gracz w grupie ACL je?eli tak to otwiera panel etc.
Wysłany: 2018-07-06, 11:56
adisonboss
Wiek: 23 Na forum: 3331 dni Posty: 237
Piwa : 6
Ale to nie jest na marker to jest na komend?
Wysłany: 2018-07-06, 11:58
Kalizman
Wiek: 23 Na forum: 3651 dni Posty: 1394
Piwa : 4619
no to przy komendzie? tak trudno zajarzy??
Wysłany: 2018-07-06, 12:04
adisonboss
Wiek: 23 Na forum: 3331 dni Posty: 237
Piwa : 6
Dobrze spokojnie ju? ogarne...
[ Dodano : 2018-07-06, 12:23 ]
Tylko ?e jest problem bo nie mog? znale?? linijki odpowiadaj?cej za wpisanie tej komendy i otworzenie gui
[ Dodano : 2018-07-06, 12:31 ]
To strona serwera
--***********************************--
--***********************************--
-- Jail System --
-- By sebikLOL --
-- Server Side --
--***********************************--
--***********************************--
Command = get ( "command" ) -- getTheCommand
rRoot = getResourceRootElement ( getThisResource ())
------
function getData ( to )
local file = xmlLoadFile ( "data.xml" )
jTable = {}
tTable = {}
if file then
for k , v in ipairs ( xmlNodeGetChildren ( xmlFindChild ( file , "Jails" , 0 )))do
local name = xmlNodeGetAttribute ( v , "name" )
local posX , posY , posZ = xmlNodeGetAttribute ( v , "posX" ), xmlNodeGetAttribute ( v , "posY" ), xmlNodeGetAttribute ( v , "posZ" )
local int = xmlNodeGetAttribute ( v , "int" )
local dim = xmlNodeGetAttribute ( v , "dim" )
table . insert ( jTable , { name , posX , posY , posZ , int , dim })
end
for k , v in ipairs ( xmlNodeGetChildren ( xmlFindChild ( file , "time" , 0 )))do
local times = xmlNodeGetAttribute ( v , "times" )
for i = 1 , 50 do
local iTime = gettok ( times , i , string . byte ( ',' ) )
if iTime then
--
if tonumber ( iTime ) > 59.5 then
iTime = math . floor ( iTime / 60 )
iTimeDes = "Minutes"
if iTime > 59.5 then
iTime = math . floor ( iTime / 60 )
iTimeDes = "Houres"
end
else
iTimeDes = "Seconds"
end
table . insert ( tTable ,{ iTime , iTimeDes })
end
end
end
end
triggerClientEvent ( to , "sendDataz" , to , jTable , tTable ) -- sending to client event
end
addEvent ( "getDataz" , true )
addEventHandler ( "getDataz" , root , getData )
addCommandHandler ( Command , -- Adding The Command Handler
function ( player , cmd )
if hasObjectPermissionTo ( player , "function.kickPlayer" ) then
triggerClientEvent ( player , "jailShow" , player )
else
outputChatBox ( " Access Denied " , player , 255 , 0 , 0 )
end
end
)
anims = {
"F_smklean_loop" ,
"M_smklean_loop" ,
"M_smkstnd_loop" ,
"M_smk_drag" ,
"M_smk_in" ,
"M_smk_loop" ,
"M_smk_out" ,
"M_smk_tap" ,
}
function removeVehicle ( thePlayer )
if isPedInVehicle ( thePlayer ) then destroyElement ( getPedOccupiedVehicle ( thePlayer )) end
end
function JailHim ( jailed , theJails , time , timeDes , showWho , timeReady )
thePlayer = getPlayerFromName ( jailed )
if not thePlayer then outputChatBox ( "** #FFFF00Prosz? wybierz gracza !" , source , 255 , 0 , 0 , true ) return end
removePedFromVehicle ( thePlayer )
for k , v in ipairs ( jTable ) do
if theJails == v [ 1 ] then
theJail = v
end
end
if theJail then
if tostring ( time ) then
if timeReady == true then
theTimex = tonumber ( time )
else
theTimex = gettok ( time , 1 , string . byte ( timeDes ) )
end
if timeDes == "Hours" then
theTimex = math . floor ( theTimex * 60 * 60 * 1000 )
elseif timeDes == "Minutes" then
theTimex = math . floor ( theTimex * 60 * 1000 )
elseif timeDes == "Seconds" then
theTimex = math . floor ( theTimex * 1000 )
end
startJailTimer ( thePlayer , theTimex )
local x , y , z = theJail [ 2 ], theJail [ 3 ], theJail [ 4 ]
local int = theJail [ 5 ]
local dim = theJail [ 6 ]
setElementInterior ( thePlayer , int )
setElementDimension ( thePlayer , dim )
setElementPosition ( thePlayer , x , y , z )
setElementData ( thePlayer , "jailed" , true )
setElementData ( rRoot , "" .. getPlayerSerial ( thePlayer ).. "-j" , true )
toggleControl ( thePlayer , "fire" , false )
if showWho ~= true then
outputChatBox ( "** #FFFF00Zostales uwieziony [ " .. getPlayerName ( thePlayer ).. " #FFFF00] at " .. theJail [ 1 ].. " For " .. time , source , 255 , 0 , 0 , true )
outputChatBox ( "** #FFFF00Zostales uwieziony przez [ " .. getPlayerName ( source ).. " #FFFF00] at " .. theJail [ 1 ].. " For " .. time , thePlayer , 255 , 0 , 0 , true )
end
outputChatBox ( "** #FFFF00[ " .. getPlayerName ( thePlayer ).. " #FFFF00] zostales uwieziony na " .. time , root , 255 , 0 , 0 , true )
local randomAnim
setPedAnimation ( thePlayer , "SMOKING" , anims [ math . random ( #anims)],theTimex/2)
else
outputChatBox ( "** #FFFF00Prosze wybierz czas !" , source , 255 , 0 , 0 , true )
end
else
outputChatBox ( "** #FFFF00Prosze wybrac wiezienie !" , source , 255 , 0 , 0 , true )
end
end
addEvent ( "JailHimx" , true )
addEventHandler ( "JailHimx" , root , JailHim )
function unJailHim ( jailed , showWho )
thePlayer = getPlayerFromName ( jailed )
if not thePlayer then outputChatBox ( "** #FFFF00Prosze wybrac gracza !" , source , 255 , 0 , 0 , true ) return end
--if getElementData ( thePlayer , "jailed" ) == true then
setElementInterior ( thePlayer , 0 )
setElementDimension ( thePlayer , 0 )
setElementPosition ( thePlayer , 201.30215 , 168.38332 , 1003.02344 )
setElementInterior ( thePlayer , 3 )
setElementData ( thePlayer , "jailed" , false )
setElementData ( rRoot , "" .. getPlayerSerial ( thePlayer ).. "-j" , false )
if showWho ~= true then
outputChatBox ( "** #FFFF00You Released [ " .. getPlayerName ( thePlayer ).. " #FFFF00]" , source , 255 , 0 , 0 , true )
outputChatBox ( "** #FFFF00Zostales zwolniony przez [ " .. getPlayerName ( source ).. " #FFFF00]" , thePlayer , 255 , 0 , 0 , true )
end
outputChatBox ( "** #FFFF00[ " .. getPlayerName ( thePlayer ).. " #FFFF00] Zostal zwolniony " , root , 255 , 0 , 0 , true )
setPedAnimation ( thePlayer )
stopJailTimer ( Player )
toggleControl ( thePlayer , "fire" , true )
-- setTimer ( killPed , 1500 , 1 , thePlayer )
--else
-- outputChatBox ( "The Player is Not Jailed !" , source , 255 , 0 , 0 , true )
-- end
end
addEvent ( "unJailHim" , true )-- unJail
addEventHandler ( "unJailHim" , root , unJailHim )
addEvent ( "onJailEnd" , true )
addEventHandler ( "onJailEnd" , root ,function( player )
unJailHim ( getPlayerName ( player ), true )
end )
addEventHandler ( "onPlayerSpawn" , root , -- Check If He Is Jailed [ OnSpawn ]
function()
if getElementData ( source , "jailed" ) == true then
randomJail = jTable [ math . random ( #jTable)]
if randomJail then
x , y , z = randomJail [ 2 ], randomJail [ 3 ], randomJail [ 4 ]
int = randomJail [ 5 ]
dim = randomJail [ 6 ]
setElementInterior ( source , int )
setElementDimension ( source , dim )
setElementPosition ( source , x , y , z )
end
end
end )
addEventHandler ( "onPlayerJoin" , root , -- Check If He Is Jailed - By Serial [ OnJoin ]
function()
if getElementData ( rRoot , "" .. getPlayerSerial ( source ).. "-j" ) == true then
randomJail = jTable [ math . random ( #jTable)]
if randomJail then
x , y , z = randomJail [ 2 ], randomJail [ 3 ], randomJail [ 4 ]
int = randomJail [ 5 ]
dim = randomJail [ 6 ]
setElementInterior ( source , int )
setElementDimension ( source , dim )
setElementPosition ( source , x , y , z )
--
time = getElementData ( rRoot , "" .. getPlayerSerial ( source ).. "-t" , time ) or 5 * 1000
startJailTimer ( source , time )
setElementData ( source , "jailed" , true )
end
end
end )
----
function startJailTimer ( Player , theTime ) -- to start mission timer ..
if Player then
TimerDisplay = textCreateDisplay ()
m , s , cs = msToTimeStr ( theTime )
fullTime = m .. ":" .. s
TimerText = textCreateTextItem ( "Time Left : " .. tostring ( fullTime ).. "" , 0.39 , 0.7 , "medium" , 0 , 255 , 0 , 255 , 2.0 , "left" , "center" , 255 )
textDisplayAddText ( TimerDisplay , TimerText )
textDisplayAddObserver ( TimerDisplay , Player )
sortTimerShit ( Player , TimerText , theTime )
end
end
-- Robbed from JailTimerr resource , and it was robbed from arc_ : p
function msToTimeStr ( ms )
if not ms then
return ''
end
if ms < 0 then
return "0" , "00" , "00"
end
local centiseconds = tostring ( math . floor ( math . fmod ( ms , 1000 )/ 10 ))
if #centiseconds == 1 then
centiseconds = '0' .. centiseconds
end
local s = math . floor ( ms / 1000 )
local seconds = tostring ( math . fmod ( s , 60 ))
if #seconds == 1 then
seconds = '0' .. seconds
end
local minutes = tostring ( math . floor ( s / 60 ))
return minutes , seconds , centiseconds
end
function sortTimerShit ( plr , timer , time ) -- to sort timer 's shit ..
if timer and time then
if isTimer(timerShitTimer) then
killTimer(timerShitTimer)
end
timerShitTimer = setTimer(function(plr)
time = time - 70
m,s,cs = msToTimeStr(time)
fullTime = m..":"..s
textItemSetText(timer,"Time Left : "..tostring(fullTime).."")
if plr then
setElementData(rRoot,""..getPlayerSerial(plr).."-t",time)
end
if ( tonumber(m) <= 0 and tonumber(s) <= 0 and tonumber(cs) <= 0 ) then
onTimerFinish(plr,timer)
end
end , 50 , 0 ,plr )
end
end
function stopJailTimer(Player)
textDestroyDisplay(TimerDisplay)
if TimerText then
textDestroyTextItem(TimerText)
end
if isTimer(timerShitTimer) then
killTimer(timerShitTimer)
end
end
function onTimerFinish(Player) -- on timer end
stopJailTimer(Player)
triggerEvent("onJailEnd",Player,Player)
end
NWM Gdzie jest funkcja odp za uruchamianie przez komende
[ Dodano : 2018-07-06, 15:30 ]
Do zamkni?cia napisa?em w?asny lepszy skrypt.
Tagi: więzienie
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: