SA-MP Forums Archive
[Include] OnPlayerChangeAngle & OnPlayerChangePosition - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] OnPlayerChangeAngle & OnPlayerChangePosition (/showthread.php?tid=379557)



OnPlayerChangeAngle & OnPlayerChangePosition - fiki574 - 22.09.2012

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


AW: OnPlayerChangeAngle & OnPlayerChangePosition - 'Pawno. - 22.09.2012

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


Re: OnPlayerChangeAngle & OnPlayerChangePosition - newbienoob - 22.09.2012

WOW! That was awesome! I will use it.


Re: OnPlayerChangeAngle & OnPlayerChangePosition - fiki574 - 22.09.2012

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!


Re: OnPlayerChangeAngle & OnPlayerChangePosition - Niko_boy - 22.09.2012

wow this is really differnt :P


Re: OnPlayerChangeAngle & OnPlayerChangePosition - NoahF - 22.09.2012

AWESOME Include! Thanks for this man.


Re: OnPlayerChangeAngle & OnPlayerChangePosition - fiki574 - 22.09.2012

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!


Re: OnPlayerChangeAngle & OnPlayerChangePosition - Lordzy - 22.09.2012

Just what I was looking for.
Well done.


Re: OnPlayerChangeAngle & OnPlayerChangePosition - fiki574 - 22.09.2012

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


Re: OnPlayerChangeAngle & OnPlayerChangePosition - MicroD - 22.09.2012

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