Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- new Float:LastPosHash[MAX_PLAYERS];
- new InactiveSeconds[MAX_PLAYERS];
- public OnGameModeInit()
- {
- SetTimer("UpdateTimer", 1000, 1);
- return 1;
- }
- stock GetPositionHash(playerid)
- {
- new Float:ppx, Float:ppy, Float:ppz;
- GetPlayerPos(playerid, ppx, ppy, ppz);
- return floatround(ppx * ppy * ppz / 3);
- }
- forward UpdateTimer();
- public UpdateTimer()
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i) && !IsPlayerNPC(i))
- {
- if(LastPosHash[i] == GetPositionHash(i))
- {
- InactiveSeconds[i]++;
- }
- else
- {
- InactiveSeconds[i] = 0;
- LastPosHash[i] = GetPositionHash(i);
- }
- }
- }
- }
- stock IsPlayerInactive(playerid)
- {
- if(InactiveSeconds[playerid] > 10) return true;
- return false;
- }
- /*Usage Example:
- CMD:inactive(playerid)
- {
- if(IsPlayerInactive(playerid))
- {
- SendClientMessage(playerid, -1, "You are inactive!");
- }
- else
- {
- SendClientMessage(playerid, -1, "You are not inactive!");
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement