Jump to content

AFK Script


toptional

Recommended Posts

Getting retarded errors like this

ERROR: attempt to call global 'spawnPlayer' (a nil value)

and

ERROR: attempt to call global 'killPlayer' (a nil value)

Script Client :

addCommandHandler ( 'afk', 
function (AFKZone) 
    spawnPlayer ( source, 1958.7082519531, -1517.5471191406, 973.55889892578, 0, 1, 0, 0 ) 
    setElementFrozen ( thePlayer, true ) 
    toggleControl ( thePlayer, "fire", false ) 
    outputChatBox ( "#FF0000You are now in AFK mode do /stopafk to go back and play!", getRootElement(), 255, 255, 255, true ) 
end 
) 
  
addCommandHandler ( 'stopafk', 
function (StopAFK) 
    killPlayer(sourcePlayer, sourcePlayer) 
    setElementFrozen ( thePlayer, false ) 
    toggleControl ( thePlayer, "fire", true ) 
    end 
) 
     
  
  

Link to comment
Getting retarded errors like this

ERROR: attempt to call global 'spawnPlayer' (a nil value)

and

ERROR: attempt to call global 'killPlayer' (a nil value)

Script Client :

addCommandHandler ( 'afk', 
function (AFKZone) 
    spawnPlayer ( source, 1958.7082519531, -1517.5471191406, 973.55889892578, 0, 1, 0, 0 ) 
    setElementFrozen ( thePlayer, true ) 
    toggleControl ( thePlayer, "fire", false ) 
    outputChatBox ( "#FF0000You are now in AFK mode do /stopafk to go back and play!", getRootElement(), 255, 255, 255, true ) 
end 
) 
  
addCommandHandler ( 'stopafk', 
function (StopAFK) 
    killPlayer(sourcePlayer, sourcePlayer) 
    setElementFrozen ( thePlayer, false ) 
    toggleControl ( thePlayer, "fire", true ) 
    end 
) 
     
  
  

Your using it on client-side , use it on server-side and it will work. because killPlayer and spawnPlayer is server-sided functions.

Link to comment

Bit confused bit heres what i got

Server:

  
addCommandHandler ( 'afk', 
function (AFKZone) 
    setElementPosition ( thePlayer, 1958.7082519531, -1517.5471191406, 973.55889892578 ) 
    setElementFrozen ( thePlayer, true ) 
    toggleControl ( thePlayer, "fire", false ) 
    outputChatBox ( "#FF0000You are now in AFK mode do /stopafk to go back and play!", getRootElement(), 255, 255, 255, true ) 
end 
) 
  
addCommandHandler ( 'stopafk', 
function (StopAFK) 
    killPlayer(sourcePlayer, sourcePlayer) 
    setElementFrozen ( thePlayer, false ) 
    toggleControl ( thePlayer, "fire", true ) 
    end 
) 
  

Link to comment

server.lua

addCommandHandler ( 'afk', 
function (thePlayer) 
    setElementPosition ( thePlayer, 1958.7082519531, -1517.5471191406, 973.55889892578) 
    setElementFrozen ( thePlayer, true ) 
    toggleControl ( thePlayer, "fire", false ) 
    outputChatBox ("#FF0000You are now in AFK mode do /stopafk to go back and play!", thePlayer, 255, 255, 255) 
end 
) 
  
addCommandHandler ( 'stopafk', 
function (thePlayer) 
    killPed(thePlayer) 
    setElementFrozen ( thePlayer, false ) 
    toggleControl (thePlayer, "fire", true ) 
    end 
) 

meta.xml

 <script src="server.lua" type="server"/>  

Edited by Guest
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...