[Include] OnPlayerChangeAngle & OnPlayerChangePosition
#1

opc.inc

Released on 22/9/2012


INTRO:
First release after long time (don't count update releases)! The reason of creation of this include is that I indeed need something like this for my new-old gamemode I am doing on! This can be used in all ways you can imagine - for AFK system, speed hack detection, airbraking, drift points counting and much more! Here's the include!

P.S. This post will be short!

__________________________________________________ __________________________________________________

INCLUDE:

There isn't any native functions, but there are two custom callbacks which are:

pawn Код:
OnPlayerChangeAngle(playerid, Float:old_angle, Float:new_angle);
OnPlayerChangePosition(playerid, Float:old_x, Float:old_y, Float:old_z, Float:new_x, Float:new_y, Float:new_z);
Here is some example usage of those two callbacks!

pawn Код:
#define TIMER_TIME 1*1000 //found in "opc.inc"

new count[MAX_PLAYERS] = 0;

public OnPlayerChangeAngle(playerid, Float:old_angle, Float:new_angle)
{
    if(old_angle < new_angle || old_angle > new_angle)
    {
        count[playerid] = 0;
        printf("Player %d changed their angle from %f to %f", playerid, old_angle, new_angle);
    }
    else if(old_angle == new_angle)
    {
        count[playerid]++;
        printf("Player %d hasn't changed their angle!", playerid);
        if(count[playerid] == 30)
        {
            printf("Player %d hasn't changed their angle for 30 seconds, therefor they may be AFK!", playerid);
        }
    }
    KillTimer(CheckTimer[playerid]);
    return 1;
}
pawn Код:
#define TIMER_TIME 1*1000 //found in "opc.inc"

new count2[MAX_PLAYERS] = 0;

public OnPlayerChangePosition(playerid, Float:old_x, Float:old_y, Float:old_z, Float:new_x, Float:new_y, Float:new_z)
{
    if(old_x != new_x || old_y != new_y || old_z != new_z)
    {
        count2[playerid] = 0;
        printf("Player %d changed their position from %f,%f,%f to %f,%f,%f", playerid, old_x, old_y, old_z, new_x, new_y, new_z);
    }
    else if(old_x == new_x || old_y == new_y)
    {
        count2[playerid]++;
        printf("Player %d hasn't changed their position!", playerid);
        if(count2[playerid] == 30)
        {
            printf("Player %d hasn't changed their position for 30 seconds, therefor they may be AFK!", playerid);
        }
    }
    KillTimer(CheckTimer2[playerid]);
}
Both of those examples represent simple AFK player detection, and as said you can use this for anything you want!

__________________________________________________ _______________________________________________

CREDITS:

fiki574_CRO - creating everything
****** - ALS hooking

Do not re-release / use stuff from this include without noticing me!

__________________________________________________ _______________________________________________

DOWNLOAD:

Pastebin v1.0 (current, recomended)

No mirrors allowed!!
Reply
#2

Thanks, very useful for my afk system!
i use it =) <3
Reply
#3

WOW! That was awesome! I will use it.
Reply
#4

Quote:
Originally Posted by 'Pawno.
Посмотреть сообщение
Thanks, very useful for my afk system!
i use it =) <3
Quote:
Originally Posted by newbienoob
Посмотреть сообщение
WOW! That was awesome! I will use it.
Thanks both!
Reply
#5

wow this is really differnt :P
Reply
#6

AWESOME Include! Thanks for this man.
Reply
#7

Quote:
Originally Posted by Niko_boy
Посмотреть сообщение
wow this is really differnt :P
Indeed

Quote:
Originally Posted by NoahF
Посмотреть сообщение
AWESOME Include! Thanks for this man.
No problem, and thank you!
Reply
#8

Just what I was looking for.
Well done.
Reply
#9

Quote:
Originally Posted by [xB]Lordz
Посмотреть сообщение
Just what I was looking for.
Well done.
Ty!
Reply
#10

This does not seems fine. You made it very complicated.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)