SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 09/07/2011, 01:55 PM   #1
Gamer_Z
High-roller
 
Gamer_Z's Avatar
 
Join Date: Jun 2009
Location: Fontys Uni. - Applied Sciences (Currently doing the hardest possible study Fontys has to offer)
Posts: 2,620
Reputation: 819
Exclamation Drift Points Counter Plug-In by Gamer_Z

View This topic in: / Bekijk deze topic in het: / Oglądnij ten temat w języku:

English/Engels/Angielskim
Dutch/Nederlands/Holenderskim
Polish/Pools/Polskim
More translations are welcome!
Meer vertalingen zijn welkom!
Większa ilość tłumaczeń jest mile widziana!


In Development/In ontwikkeling/W budowie:
None/Geen/Żadna

First of all I want to thank people that made this possible (sorry if I forgot somebody, lemme know):
Pghpunkid
Incognito
Kyosaur
RyDeR`
Zeex
Rock_Ro
Nero_3D


Special thanks go to (for help, etc):
Kyosaur
RyDeR`


Okay now, you are asking: "What does this plugin do?".

Well let's see this:
http://www.youtube.com/watch?v=f9AtUwlNOFk
That's drifting (and one of my favorite games which inspired me to write this plugin).

Here is a video that is representing this plugin:

http://www.youtube.com/watch?v=wNNcMC-R8So


And now: why not in PAWN? -
lemme explain:

PAWN is a scripting language made for small scripts (not the huge GM's like for sa-mp, but it can handle it easily )
and if you do many calculations on 500 players it will just do the calculations. While it's doing the calculations pawn cannot execute any other functions, so your gamemode will be 'paused' till the operation is done.
Now what this plugin does: it does all the needed calculations in the background for pawn and calls 3 callbacks to efficiently do everything.

Okay where can I download it?

The lastest source, compiled dll/so, includes are part of the "Gamer_Z's Project Bundle" and can be obtained from here:

http://gpb.googlecode.com/

Known problems/bugs:
- None


The functions explained:

Note: Please see the Wiki for more information



pawn Code:
//-1 means set for all players.
native DriftSet_UpdateDelay(delay);
native DriftGet_UpdateDelay();
Set/Get the interval between drift updates.(this is in TICKS, not seconds or miliseconds or nanoseconds!)

pawn Code:
native DriftSet_MinimalSpeed(Float:MinimalSpeed,playerid = (-1));
native DriftGet_MinimalSpeed(&Float:MinimalSpeed,playerid = (0));
Set/Get the minimal speed to approve a 'drift'.

pawn Code:
native DriftSet_MinimalAngle(Float:MinimalAngle,playerid = (-1));
native DriftGet_MinimalAngle(&Float:MinimalAngle,playerid = (0));
Set/Get the minimal angle to approve a 'drift'.

pawn Code:
native DriftSet_MaximalSpeed(Float:MaximalSpeed,playerid = (-1));
native DriftGet_MaximalSpeed(&Float:MaximalSpeed,playerid = (0));

native DriftSet_MaximalAngle(Float:MaximalAngle,playerid = (-1));
native DriftGet_MaximalAngle(&Float:MaximalAngle,playerid = (0));
These functions are self explainatory, if you want to make minimissions in RP like drift between 25 and 70 degrees then you can just use them

pawn Code:
native DriftSet_StartEndDelay(delay,playerid = (-1));
native DriftGet_StartEndDelay(playerid = (0));
This is the delay in ticks between a drift start and when a drift should be countet as 'ended' if the player is not drifting anymore.

pawn Code:
native DriftSet_Divider(divider,playerid = (-1));
native DriftGet_Divider(playerid = (0));
This sets the points divider so you won't get huge numbers in OnDirftUpdate and OnDriftEnd. defaul is 350.

pawn Code:
native DriftSet_DamageCheck(enable = 1,playerid = (-1),Float:MaxHealthLoose = 0.0);//default = disabled (0), enabled = 1
native DriftGet_DamageCheck(playerid = (0),&Float:MaxHealthLoose = 0);
This enables checking if the vehicle heal has changed, if yes it ends the drift and calls OnDriftEnd.
Also with MaxHealthLoose you can set the maximum amount of health to loose (so you can allow drift that 'scratch')

pawn Code:
native IsPlayerDrifting(playerid);
Check if a player is drifting.

pawn Code:
forward OnPlayerDriftStart(playerid);
This is called when a player starts drifting, handy to begin showing textdraws.

pawn Code:
forward OnPlayerDriftUpdate(playerid,value,combo);
//UPDATED IN R10 TO:
forward OnPlayerDriftUpdate(playerid,value,combo,flagid,Float:distance);
//UPDATED IN R17 TO:
forward OnPlayerDriftUpdate(playerid,value,combo,flagid,Float:distance,Float:speed);
This is called at every step when a drift is approved, it is called very many times per player if he drifts so keep your code short.
value is the amount of drift points gained with the last short drift move
combo increases until OnPlayerDriftEnd.
flagid is the closest flag within 10 meters
distance is the distance to the closest flag,
speed is the speed in km/h.

pawn Code:
#define DRIFT_REASON_TIME_EXPIRE (0)
#define DRIFT_REASON_CAR_DAMAGED (1)
//ADDED IN R19
#define DRIFT_REASON_PLAYER_EXIT_VEHICLE    (2)

forward OnPlayerDriftEnd(playerid,value,combo,reason);
This is called when the players drift delay time is epleased or when damage checks are enabled and the health is changed. The reason variable indicates how the drift was ended,
DRIFT_REASON_TIME_EXPIRE - the drift has ended because the player didn't start a new drift within the delay period.
DRIFT_REASON_CAR_DAMAGED - the drift has been ended because the vehicle health changed.
DRIFT_REASON_PLAYER_EXIT_VEHICLE - the drift has been ended because the player exited his vehicle

pawn Code:
native IsPlayerDrifting_precise(playerid);
This is more precise than IsPlayerDrifting, this actually tells you if the car is really (AT THE TIME OF THE CALL) drifting, not if the player is in a drift.

pawn Code:
native Drift_AddFLAG(Float:X,Float:Y,Float:Z);//returns flagid
Adds a 'Drift Checkpoint' so when somebody drifts within 10 meters from the flag OnDriftUpdate is expanded with flagid and Distance, how lower the distance how closer the player drifts!

pawn Code:
native Drift_DisableFLAG(flagid);
Disables an created drift checkpoint.

pawn Code:
native Drift_DeleteFLAG(flagid);
Deletes an created drift checkpoint (if AddFLAG is not used this action can be undone with EnableFLAG(flagid))

pawn Code:
native Drift_EnableFLAG(flagid);
enables an disabled (or deleted) drift checkpoint.

pawn Code:
native Drift_MoveFLAG(flagid,Float:X,Float:Y,Float:Z);
Moves a drift checkpoint to a new position.

pawn Code:
native Drift_SetCheckForFlags(enabled = 1,playerid =(-1));
native Drift_GetCheckForFlags(playerid = 0);
Enables / disables / get the setting for checking if players (or a specified player) are(/is) in a range of a drift checkpoint.

Added in R19
pawn Code:
native Drift_Private_ChangeState(playerid,newstate);

This native is used internally, it is not recommended to use this unless you know what you are doing.
Please refferer to the include to see where it is used and to the source to see what it does.

pawn Code:
native Drift_SetGlobalCheck(enable = 1);
native Drift_GetGlobalCheck();

Enables/disables the whole plugin, can be used at any time.

pawn Code:
native Drift_SetPlayerCheck(playerid = (-1),enable = 1);
native Drift_GetPlayerCheck(playerid = (0));
Enables/Disables/gets the checking for if the player drifts. if enable is 0 no drifts will be approved (for the specified player).

pawn Code:
native Drift_SetBackwardsCheck(enabled = 1,playerid =(-1));
native Drift_GetBackwardsCheck(playerid = 0);
enables/disables/gets the option for drifting backwards.

pawn Code:
native Drift_SetDriftMaxHealthLoose(Float:MaximalHealthLoose = 0.0,playerid = (-1));
native Drift_GetDriftMaxHealthLoose(&Float:MaximalHealthLoose,playerid = (0));
See: DriftSet_DamageCheck

Have fun, any questions? Post here.
__________________

Google code not working? Try GitHub

Last edited by Gamer_Z; 11/05/2013 at 01:45 AM. Reason: Update
Gamer_Z is offline   Reply With Quote
Old 09/07/2011, 01:59 PM   #2
MicroD
Huge Clucker
 
Join Date: Sep 2010
Posts: 350
Reputation: 9
Default Re: Drift Points Counter Plug-In by Gamer_Z

O M G nice plugin, i must try this!
MicroD is online now   Reply With Quote
Old 09/07/2011, 02:00 PM   #3
RyDeR`
High-roller
 
RyDeR`'s Avatar
 
Join Date: Feb 2009
Location: Belgium
Posts: 3,134
Reputation: 638
Default Re: Drift Points Counter Plug-In by Gamer_Z

Nice to see it released. Good job!
__________________

Sup?
RyDeR` is offline   Reply With Quote
Old 09/07/2011, 02:02 PM   #4
Gamer_Z
High-roller
 
Gamer_Z's Avatar
 
Join Date: Jun 2009
Location: Fontys Uni. - Applied Sciences (Currently doing the hardest possible study Fontys has to offer)
Posts: 2,620
Reputation: 819
Default Re: Drift Points Counter Plug-In by Gamer_Z

Quote:
Originally Posted by RyDeR` View Post
Nice to see it released. Good job!
Thanks, and I hope somebody will help develop this ^^ (and help making it cross compatible).

BTW does anyone have a function called 'IsVehicleMovingForward/Backward' ? I'm too lazy to resesrch it and make it on my own but I can
__________________

Google code not working? Try GitHub
Gamer_Z is offline   Reply With Quote
Old 09/07/2011, 02:07 PM   #5
Rock_Ro
Huge Clucker
 
Join Date: Mar 2011
Location: Los Santos
Posts: 281
Reputation: 2
Default Re: Drift Points Counter Plug-In by Gamer_Z

Lol.

A Drift Points Plugin, i was planning to release the best drift counter but this...ruin all my plans

Release aborted

Good Job, when i install San Andreas Again ( if i install ) i will test to see how it works xD

EDIT:
pawn Code:
stock IsVehicleDrivingBackwards(vehicleid)
{
    new
        Float:Float[3]
    ;
    if(GetVehicleVelocity(vehicleid, Float[1], Float[2], Float[0]))
    {
        GetVehicleZAngle(vehicleid, Float[0]);
        if(Float[0] < 90)
        {
            if(Float[1] > 0 && Float[2] < 0) return true;
        }
        else if(Float[0] < 180)
        {
            if(Float[1] > 0 && Float[2] > 0) return true;
        }
        else if(Float[0] < 270)
        {
            if(Float[1] < 0 && Float[2] > 0) return true;
        }
        else if(Float[1] < 0 && Float[2] < 0) return true;
    }
    return false;
}
Rock_Ro is offline   Reply With Quote
Old 09/07/2011, 02:09 PM   #6
Johnny_Xayc
Huge Clucker
 
Johnny_Xayc's Avatar
 
Join Date: Aug 2009
Posts: 322
Reputation: 0
Default Re: Drift Points Counter Plug-In by Gamer_Z

Sweeeeeeeet!
Johnny_Xayc is offline   Reply With Quote
Old 09/07/2011, 02:09 PM   #7
Gamer_Z
High-roller
 
Gamer_Z's Avatar
 
Join Date: Jun 2009
Location: Fontys Uni. - Applied Sciences (Currently doing the hardest possible study Fontys has to offer)
Posts: 2,620
Reputation: 819
Default Re: Drift Points Counter Plug-In by Gamer_Z

Quote:
Originally Posted by Rock_Ro View Post
Lol.

A Drift Points Plugin, i was planning to release the best drift counter but this...ruin all my plans

Release aborted

Good Job, when i install San Andreas Again ( if i install ) i will test to see how it works xD
you can release a good drift counter like in the video, I'm not that enthousast to make it, so this plugin can help you make the best drift counter filterscript (make some nice textdraws in it, on combo change make it appear bigger etc..)

and thanks for the function! I will port it to the plugin to make the drif counter less buggy
__________________

Google code not working? Try GitHub
Gamer_Z is offline   Reply With Quote
Old 09/07/2011, 02:11 PM   #8
MicroD
Huge Clucker
 
Join Date: Sep 2010
Posts: 350
Reputation: 9
Default Re: Drift Points Counter Plug-In by Gamer_Z

Plugin cant start:

Last edited by MicroD; 15/09/2011 at 04:39 PM.
MicroD is online now   Reply With Quote
Old 09/07/2011, 02:12 PM   #9
Gamer_Z
High-roller
 
Gamer_Z's Avatar
 
Join Date: Jun 2009
Location: Fontys Uni. - Applied Sciences (Currently doing the hardest possible study Fontys has to offer)
Posts: 2,620
Reputation: 819
Default Re: Drift Points Counter Plug-In by Gamer_Z

Quote:
Originally Posted by David Skrbic View Post
Plugin cant start:
download the dll's from the web and place it where you have samp-server.exe.
http://www.dll-files.com/dllindex/dl...shtml?msvcp100

OR install VC2010
__________________

Google code not working? Try GitHub
Gamer_Z is offline   Reply With Quote
Old 09/07/2011, 02:22 PM   #10
Omega-300
Banned
 
Join Date: May 2011
Location: In Tha Hood
Posts: 34
Reputation: 0
Default Re: Drift Points Counter Plug-In by Gamer_Z

It seems like you have no idea about ticks, you should read the first answer here: http://superuser.com/questions/10118...-is-a-cpu-tick
And it is not correctly that it does calculations in background.
You should also implement something like Y_Less's 'foreach' so that it cache players that are in vehicle so you don't need to loop every player, just ones that are DRIVING a car.
Omega-300 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] [FS]۞.:DRIFT Points Counter .:OWNAGE EDITION:. ۞ abhinavdabral Filterscripts 166 24/06/2014 10:01 AM
Drift counter! Natrens Help Archive 7 06/08/2011 01:43 PM
Drift map + points need help speediekiller2 Help Archive 3 29/08/2010 11:43 AM
Drift Counter XxerykxX Help Archive 3 12/07/2010 12:56 PM


All times are GMT. The time now is 07:47 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.