It is currently Fri 22. Nov 2024 23:34:46

All times are UTC + 1 hour [ DST ]




Post new topic  Post a reply   Page 1 of 1  [ 9 posts ] 
Author Message

S4Y|Merry
 Post subject: Anti Afk Chyba
PostPosted: Sun 06. Sep 2015 2:34:58 
offline
Nováček
Nováček

Joined: Tue 18. Aug 2015 11:56:01
Posts: 9

Points: 151 002
Cash: $699
Přeji krásný den všem co nyní čtou toto téma nerad jej zakládám ačkoliv už si nevím rady s tímto kódem.
Zabijí tak jak je nastaven a vypíše že byl hráč kicknutý ale hráč zůstává ve hře můžete mi prosím poradit jestli je chyba v kódu nebo někde jinde ? Děkuji předem za cokoliv co by mi mohlo pomoci.

Server
Spoiler: show
Code:
local raceState = ""

function onPlayerAFKKill ()
   if raceState == "Running" then
      setElementData(source,"afkkills",getElementData(source,"afkkills")+1)
      if getElementData(source,"afkkills") == 4 then
         kickPlayer(source,"You was AFK for to long.")
         triggerClientEvent ( "onRollMessageStart", getRootElement(), getPlayerName(source).."#FFFFFF, left [AFK]!",2565,255,255)
         outputChatBox(getPlayerName(source).."#FFFFFF was kicked by the #FF0000AFK System#FFFFFF.",getRootElement(),255,0,0,true)
         return
      end
      setElementHealth(source, 0)
      local kills = getElementData(source,"afkkills")
      triggerClientEvent ( "onRollMessageStart", getRootElement(), getPlayerName(source).."#FFFFFF, #FF9900AFK #FFFFFF[#FF9900"..kills.."#FFFFFF/4]!",2565,255,255,"afk")
   end
end
addEvent("onPlayerAFKTimelimit",true)
addEventHandler("onPlayerAFKTimelimit",getRootElement(),onPlayerAFKKill)

function onPlayerIsBack ()
   setElementData(source,"afkkills",0)
end   
addEvent("onPlayerIsBack",true)
addEventHandler("onPlayerIsBack",getRootElement(),onPlayerIsBack)

function changeRaceState(newStateName)
   raceState = newStateName
end
addEvent("onRaceStateChanging", true)
addEventHandler( "onRaceStateChanging", getRootElement(), changeRaceState)


Client
Spoiler: show
Code:
local me = getLocalPlayer()
setElementData(me,"afkkills",0)
local afktime = 0
local guiAFKAlpha = 0
guiAFKAlphaSet = 0.02
local ltfont = guiCreateFont("ltfont.ttf",20)

function permanentPlayerAFKTime ()
local vehicle = getPedOccupiedVehicle ( getLocalPlayer() )
if isPedInVehicle (getLocalPlayer()) then
   --check freeze state
   if(isElementFrozen (vehicle)) then
      afktime = 0
      return
   end
   --check movement state
    local x,y,z = getElementVelocity (vehicle)
   local speed = ((x^2 + y^2 + z^2)^(0.5))* 180
      if speed > 1 then
         checkPlayerAFKStatus()
         afktime = 0
         return
      end
   --add afkTimer
   afktime = afktime+1
   --trigger Event
   if afktime == 30 then
      triggerServerEvent("onPlayerAFKTimelimit",getLocalPlayer())
      guiAFKAlphaSet = -0.05
   end
   if afktime == 15 then
      guiSetVisible(afkImage,true)
      addEventHandler("onClientRender",getRootElement(),renderAfkImage)
      guiAFKAlphaSet = 0.0125
   end
else
   afktime = 0
end
end
setTimer(permanentPlayerAFKTime,1000,0)

function onPlayerPressedKey(button)
if button == "u" then return end
if button == "mouse1" then return end
if button == "mouse2" then return end
if button == "mouse3" then return end
if button == "mouse_wheel_up" then return end
if button == "mouse_wheel_down" then return end
   --afktime = 0
   --checkPlayerAFKStatus()
end
addEventHandler("onClientKey",getRootElement(), onPlayerPressedKey)

function checkPlayerAFKStatus()
if getElementData(me,"afkkills") > 0 then
triggerServerEvent("onPlayerIsBack",getLocalPlayer())
end
guiAFKAlphaSet = -0.05
end

afkImage = guiCreateStaticImage(0.3,0.35,0.4,0.275,"tools/images/afk_info/afk.png",true)
guiSetVisible(afkImage,false)
guiSetAlpha(afkImage,0)
afkTimeLeft = guiCreateLabel( 0.85,0.8,0.15,0.2,"",true,afkImage)
guiSetFont(afkTimeLeft,ltfont)

function renderAfkImage()
local alpha = guiGetAlpha(afkImage)
guiSetAlpha(afkImage,alpha+guiAFKAlphaSet)
guiSetText(afkTimeLeft,(30-afktime))
if alpha + guiAFKAlphaSet >= 1 then
   guiAFKAlphaSet = 0
elseif alpha + guiAFKAlphaSet <= 0 then
   removeEventHandler("onClientRender",getRootElement(),renderAfkImage)
   guiSetVisible(afkImage,false)
end
end



Meta
Spoiler: show
Code:
<meta>
   <info author="Merry" type="misc" version="1.0.0" name="antiafk"/>
   <oop>true</oop>
   
   <script src="client.lua" type="client"/>
   <script src="server.lua" type="server"/>
   
   <file src="afk.png" />
</meta>


Top
   
 

Black::.Ru1n
 Post subject: Re: Anti Afk Chyba
PostPosted: Sun 06. Sep 2015 10:33:06 
offline
VIP
'Super GT'
'Super GT'
User avatar

Joined: Wed 04. Jun 2014 12:38:32
Posts: 270

Points: 922 853
Cash: $1 302 768
script máš dobře , dal si tomu práva ? budto v mtaconfig nebo přes AP

___________________
[DM] Kret/\ ft. Ru1n - Skilled [25%]
[DM] Ru1n v.1 - Welcome to the family [15%]

Image


Top
   
 

-4md-sbn
 Post subject: Re: Anti Afk Chyba
PostPosted: Sun 06. Sep 2015 10:54:51 
offline
VIP
'Hunter'
'Hunter'
User avatar

Joined: Fri 18. Apr 2014 17:13:49
Posts: 621
Location: Czech Republic [CZ]

Points: 2 595 171
Cash: $1 505 992
JogurtCZ wrote:
script máš dobře , dal si tomu práva ? budto v mtaconfig nebo přes AP


Z vlastni zkusenosti vim, ze to je k nicemu, takze dle me musi byt chyba v clientu, ackoliv nevim kde.

___________________

> Click to redirect to 4md website.


Top
   
 

S4Y|Merry
 Post subject: Re: Anti Afk Chyba
PostPosted: Sun 06. Sep 2015 12:43:10 
offline
Nováček
Nováček

Joined: Tue 18. Aug 2015 11:56:01
Posts: 9

Points: 151 002
Cash: $699
JogurtCZ wrote:
script máš dobře , dal si tomu práva ? budto v mtaconfig nebo přes AP


Též mě napadlo že by jsem měl přidat práva na kick. Ale bohužel netuším jak :crazy:


Top
   
 

#SH
 Post subject: Re: Anti Afk Chyba
PostPosted: Sun 06. Sep 2015 15:05:26 
offline
'Mower'
'Mower'

Joined: Thu 30. Oct 2014 13:01:25
Posts: 45

Points: 4 802
Cash: $451
JogurtCZ wrote:
script máš dobře , dal si tomu práva ? budto v mtaconfig nebo přes AP


V mtaconfig nastavujes jen aby se ti scripty zapli automaticky.
btw: name = jméno scriptu
Proste do acl.xml pridas do "Admin" tohle "resource.name"


Top
   
 

S4Y|Merry
 Post subject: Re: Anti Afk Chyba
PostPosted: Sun 06. Sep 2015 15:58:01 
offline
Nováček
Nováček

Joined: Tue 18. Aug 2015 11:56:01
Posts: 9

Points: 151 002
Cash: $699
resource.AntiAFK přidán ale stále jen vypíše hlášku do chatu a nekickne :/


Top
   
 

Black::.Ru1n
 Post subject: Re: Anti Afk Chyba
PostPosted: Sun 06. Sep 2015 17:37:43 
offline
VIP
'Super GT'
'Super GT'
User avatar

Joined: Wed 04. Jun 2014 12:38:32
Posts: 270

Points: 922 853
Cash: $1 302 768
A pridal si to do 'Admin' ? Protoze default nema prqvo kickovat

___________________
[DM] Kret/\ ft. Ru1n - Skilled [25%]
[DM] Ru1n v.1 - Welcome to the family [15%]

Image


Top
   
 

S4Y|Merry
 Post subject: Re: Anti Afk Chyba
PostPosted: Sun 06. Sep 2015 22:23:23 
offline
Nováček
Nováček

Joined: Tue 18. Aug 2015 11:56:01
Posts: 9

Points: 151 002
Cash: $699
Bohužel mám to tam jak jsi říkal nefunguje to..


Top
   
 

#SH
 Post subject: Re: Anti Afk Chyba
PostPosted: Sun 06. Sep 2015 23:21:07 
offline
'Mower'
'Mower'

Joined: Thu 30. Oct 2014 13:01:25
Posts: 45

Points: 4 802
Cash: $451
MerryMakerCZ wrote:
Bohužel mám to tam jak jsi říkal nefunguje to..



A co debugscript? pise najaky error nebo warning? (/debugscript3)


Top
   
 
Display posts from previous:  Sort by  
Post new topic  Post a reply   Page 1 of 1  [ 9 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
TOPlist
Powered by phpBB® Forum Software © phpBB Group

©MSHost.cz