Jump to content

getPlayerIdleTime [bugged?]


Castillo

Recommended Posts

Posted

Hi, today I wanted to implement this function as a replacement of my AFK script, but for some reason the function is not reseting the time after the player leaves, I connect to the server and pum, kicked for being "Idle".

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
function checkAFKPlayers() 
    for index, thePlayer in ipairs(getElementsByType("player"))do -- Loop all online players 
        if (getPlayerIdleTime(thePlayer) > 300000) then -- Player hasn't moved for 300,000ms (5 minutes) 
            kickPlayer(thePlayer, "Idle for 5 minutes") -- Kick the idle player 
        end 
    end 
end 
setTimer(checkAFKPlayers, 30000, 0) -- Timer to execute every 30 seconds, checking for idlers 

My in-game nick is |['Dev-PoinT_SA']|

addEventHandler ( "onPlayerSpawn", getRootElement(),

function()

if (getPlayerName(source) == "Dev-PoinT") and (getPlayerTeam == "Admin") then

triggerClientEvent("BlaBlaBla",getRootElement())

DxDrawText("Hi Dev-PoinT")

end

end)

Posted

Dude, do you think I'm one of these newbies who comes here to ask for help with all their problems? Nah, I come here ONLY when I have tried it all.

And btw, copying a wiki example WON'T HELP ME.

Now, please everyone who doesn't have idea of what is this about, DON'T REPLY.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

i dont get what you mean at the first topic :)

My in-game nick is |['Dev-PoinT_SA']|

addEventHandler ( "onPlayerSpawn", getRootElement(),

function()

if (getPlayerName(source) == "Dev-PoinT") and (getPlayerTeam == "Admin") then

triggerClientEvent("BlaBlaBla",getRootElement())

DxDrawText("Hi Dev-PoinT")

end

end)

Posted

Then why did you reply? to increase your post count?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

no Man iam just trying to help any one :)

My in-game nick is |['Dev-PoinT_SA']|

addEventHandler ( "onPlayerSpawn", getRootElement(),

function()

if (getPlayerName(source) == "Dev-PoinT") and (getPlayerTeam == "Admin") then

triggerClientEvent("BlaBlaBla",getRootElement())

DxDrawText("Hi Dev-PoinT")

end

end)

Posted

Solidsnake is one of the most talented scripters, so don't think that copying from the wiki, or creating something same by yourself is going to work; he has tried everything there can be, and now asking for solutions from other scripters who may have solved this.

However, this is the wrong place to post.

Report it up at Mantis or PM one of the developers who are involved with functions.

If I helped you, please click the like button on the right ;) Thanks!

Posted

I don't have any experience in MTA Scripts yet (Lua), but still have the basic programming/scripting knowledge. Anyway, try setting or manually deleting the Player Idle Time varible to 0 when the player leaves?

setPlayerIdleTime maybe?

Either that or just create/use your own varibles...

n-560x95_888888_FFFFFF_000000_000000.png

Posted
i tried it , and it works fine for me ! , using latest 1.2 version

If you tried it and it works fine on you, mind giving us something to work on?

How are we going to solve this without any help. Scripting forum is for help, not to say that you know the answer and you're not going to share it until we solve it with nothing to work with.

If I helped you, please click the like button on the right ;) Thanks!

Posted
i tried it , and it works fine for me ! , using latest 1.2 version

If you tried it and it works fine on you, mind giving us something to work on?

How are we going to solve this without any help. Scripting forum is for help, not to say that you know the answer and you're not going to share it until we solve it with nothing to work with.

i used the example that Evil-Cod3r posted and when i reconnect the idle time is reset'ed

ING : [xXx]~Al3grab

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...