Jump to content

Afk Killer


Recommended Posts

not with server side

ok i have try to make waht but i dont work pl shelp

SERVER:

addEvent "Killer"
function blowVehicle(player) 
end  
triggerClientEvent(getRootElement(),"onkillTimer")
addEventHandler("onMapStarting")

CLIENT:

afkTime = 3000
 
function funcInput ( key, keyState )
if ( keyState == "up" ) then
if not isTimer(afktimer) then
     afktimer = setTimer(function() outputChatBox("afk") end,afkTime,1)
 
end
else
if isTimer( afktimer) then
killTimer ( afktimer )
end
end
end
 
function bindTheKeys ()
bindKey("fire","both",clientAction)
bindKey("next_weapon","both",clientAction)
bindKey("previous_weapon","both",clientAction)
bindKey("forwards","both",clientAction)
bindKey("backwards","both",clientAction)
bindKey("left","both",clientAction)
bindKey("right","both",clientAction)
bindKey("zoom_in","both",clientAction)
bindKey("zoom_out","both",clientAction)
bindKey("change_camera","both",clientAction)
bindKey("jump","both",clientAction)
bindKey("sprint","both",clientAction)
bindKey("look_behind","both",clientAction)
bindKey("crouch","both",clientAction)
bindKey("action","both",clientAction)
bindKey("walk","both",clientAction)
bindKey("aim_weapon","both",clientAction)
bindKey("conversation_yes","both",clientAction)
bindKey("conversation_no","both",clientAction)
bindKey("group_control_forwards","both",clientAction)
bindKey("group_control_back","both",clientAction)
bindKey("enter_exit","both",clientAction)
bindKey("vehicle_fire","both",clientAction)
bindKey("vehicle_secondary_fire","both",clientAction)
bindKey("vehicle_left","both",clientAction)
bindKey("vehicle_right","both",clientAction)
bindKey("steer_forward","both",clientAction)
bindKey("steer_back","both",clientAction)
bindKey("accelerate","both",clientAction)
bindKey("brake_reverse","both",clientAction)
bindKey("radio_next","both",clientAction)
bindKey("radio_previous","both",clientAction)
bindKey("radio_user_track_skip","both",clientAction)
bindKey("horn","both",clientAction)
bindKey("sub_mission","both",clientAction)
bindKey("handbrake","both",clientAction)
bindKey("vehicle_look_left","both",clientAction)
bindKey("vehicle_look_right","both",clientAction)
bindKey("vehicle_look_behind","both",clientAction)
bindKey("vehicle_mouse_look","both",clientAction)
bindKey("special_control_left","both",clientAction)
bindKey("special_control_right","both",clientAction)
bindKey("special_control_down","both",clientAction)
bindKey("special_control_up","both",clientAction)
bindKey("enter_passenger","both",clientAction)
bindKey("playerlist","both",clientAction)
bindKey("screenshot","both",clientAction)
bindKey("chatbox","both",clientAction)
bindKey("radar","both",clientAction)
bindKey("radar_zoom_in","both",clientAction)
bindKey("radar_zoom_out","both",clientAction)
bindKey("radar_move_north","both",clientAction)
bindKey("radar_move_south","both",clientAction)
bindKey("radar_move_east","both",clientAction)
bindKey("radar_move_west","both",clientAction)
bindKey("radar_attach","both",clientAction)
end
 
addEventHandler("onClientResourceStart",getRootElement(),bindTheKeys,Killer)

Link to comment

And again I have to say:

You seem to have no idea of scripting.

Your script is a total mess. The syntax is completely wrong at several points and it doesn't even make sense.

You trigger events, which don't exist, same goes for functions.

There is no client event "onkillTimer" and no "onMapStarting". Also there is no function "clientAction".

"blowVehicle(player)" makes absolutely no sense, the player is no vehicle.

It just looks like you just copied together several script parts.

Just START learning Lua and scripting in MTA.

You can't just go on snipping together sample scripts.

Either you consider that or nobody will help you.

Link to comment

A little redone of that afk kill script:

Server:

addEvent("KillAFK", true)
function killPlayer(player)
killPed(player, player)
outputChatBox("The player:"..getPlayerName(player).." was killed for being away from keyboard!")
outputDebugString("A player was successfully killed for being AFK", 3)
end 
 
addEventHandler("KillAFK", getRootElement(), killPlayer)

Client:

afkTime = 3000 -- 3000 ms(miliseconds) is equal to 3 seconds
-- so the formula is: i x 1000 = v
-- i == amount of time in seconds
-- v = the outcome
 
function checkAFK ( key, keyState )
if ( keyState == "up" ) then
if not isTimer(afktimer) then
setTimer(triggerServerEvent("KillAFK", getRootElement()), afkTime, 1)
end
if
elseif( keyState == "down") then
if isTimer( afktimer) then
killTimer ( afktimer )
end
end
end
 
function keys ()
bindKey("fire","both",clientAction)
bindKey("next_weapon","both",clientAction)
bindKey("previous_weapon","both",clientAction)
bindKey("forwards","both",clientAction)
bindKey("backwards","both",clientAction)
bindKey("left","both",clientAction)
bindKey("right","both",clientAction)
bindKey("jump","both",clientAction)
bindKey("sprint","both",clientAction)
bindKey("look_behind","both",clientAction)
bindKey("crouch","both",clientAction)
bindKey("action","both",clientAction)
bindKey("walk","both",clientAction)
bindKey("aim_weapon","both",clientAction)
bindKey("enter_exit","both",clientAction)
bindKey("vehicle_fire","both",clientAction)
bindKey("vehicle_secondary_fire","both",clientAction)
bindKey("accelerate","both",clientAction)
bindKey("brake_reverse","both",clientAction)
setTimer(checkAFK, afkTime, 0)
end
 
addEventHandler("onClientResourceStart",getRootElement(),keys)

Although i am NOT a 100% sure this will work, so just try, and let me know if it doesnt work.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...