About Me:
Hello dear SA-MP community
My name's Nickk888, i'm a German/Polish PAWN Scripter for about 6 years now, I own a ******* channel about SA-MP Scripting in Polish language and I create scripts for the public for free. Excuse my English skill, I'm no native English speaker, so please keep this in mind
I'll try my best ^_^
About Include:
NDRIFT is a Include that basically calculates if someone is drifting and calls a Callback with the calculated Score.
This Include was a drifting Filterscript which author was
Luby,
i've modified and optimized the code and Converted it to an Include.
You can Enable or Disable the Counter globally or Per-Player, check if someone is drifting and check if someone damaged the vehicle while drifting, all within 1 callback!
Features:- Easy to use!
- Easy to activate!
- Self hooking include, just include it!
- Everything is done within the main Callback, drift start, drift end and scoring!
- Easy to Set-Up!
- Bug Free Calculation and callback calling!
- Fast Tick Rate
Functions:
Код:
CreateDriftCounter(tickrate, minspeed, Float:minangle, Float:maxangle); - Starts the drift calculation with given parameters.
DestroyDriftCounter(); - Stops/Destroys the drift calculation.
FinishDriftingPlayer(playerid, bool:callfinish); - Force Finish Player Drifting
IsPlayerDrifting(playerid); - Check if Player is drifting.
TogglePlayerDriftCounter(playerid, bool:activated); - Toggle drifting Calculation for the Player.
Callbacks:
Код:
OnPlayerDrifting(playerid, vehicleid, score, driftstate); - Is calling when player is drifting.
Settings:
Код:
DRIFT_DEFAULT_COUNTER_TICKRATE - Calculation Tick rate.
DRIFT_DEFAULT_FINISH_TICKRATE - Default tickrate to stop the drift counter if player is not drifting.
DRIFT_DEFAULT_MIN_ANGLE - Minimum angle for the drift calculation.
DRIFT_DEFAULT_MAX_ANGLE - Maximum angle for the drift calculation.
DRIFT_DEFAULT_MIN_SPEED - The minimum speed required to take drift score.
Callback drift states:
Код:
DRIFT_STATE_DRIFTING - Player is still drifting(Drift Update)
DRIFT_STATE_START - Player started drifting.
DRIFT_STATE_FINISH - Player finished the drift(Not drifting for about 3 seconds)
DRIFT_STATE_VEHICLEDAMAGED - Player damaged the vehicle.
How to use it:
Just open the example script within the package!
Код:
#include <a_samp>
#include <ndrift>
new DriftScore[MAX_PLAYERS]; //Players score Pool, here we store the drift reward.
new PlayerText:td[MAX_PLAYERS]; //TextDraw variable.
public OnFilterScriptInit()
{
CreateDriftCounter(); //Activated the whole system
return 1;
}
hook OnPlayerConnect(playerid)
{
//Counter TextDraw
td[playerid] = CreatePlayerTextDraw(playerid,98.000000, 360.000000, "~b~DRIFT~n~~y~SCORE: ~w~+13~n~~r~TOTAL: ~g~4587");
PlayerTextDrawBackgroundColor(playerid,td[playerid], 255);
PlayerTextDrawFont(playerid,td[playerid], 2);
PlayerTextDrawLetterSize(playerid,td[playerid], 0.420000, 1.900000);
PlayerTextDrawColor(playerid,td[playerid], -1);
PlayerTextDrawSetOutline(playerid,td[playerid], 1);
PlayerTextDrawSetProportional(playerid,td[playerid], 1);
PlayerTextDrawUseBox(playerid,td[playerid], 1);
PlayerTextDrawBoxColor(playerid,td[playerid], 50);
PlayerTextDrawTextSize(playerid,td[playerid], 275.000000, 0.000000);
PlayerTextDrawSetSelectable(playerid,td[playerid], 0);
return 1;
}
hook OnPlayerDisconnect(playerid)
{
PlayerTextDrawDestroy(playerid, td[playerid]); //Destroys the Counter TextDraw
return 1;
}
public OnPlayerDrifting(playerid, vehicleid, score, driftstate)
{
score *= 10; //Score multiplier, the higher the value is, the more score the player gets!
new string[128];
switch(driftstate)
{
case DRIFT_STATE_VEHICLEDAMAGED: //Has the vehicle taking damage while drifting?
{
FinishDriftingPlayer(playerid, false); //Forces the player counter to stop.
GameTextForPlayer(playerid, "Vehicle damaged...~n~~r~DRIFT FAILED!", 2000, 1); //Show a text on the player's screen.
PlayerTextDrawHide(playerid, td[playerid]); //Hides the counter TD
DriftScore[playerid] = 0; //Resets the score counter.
}
case DRIFT_STATE_FINISH: //If the drift has been finished
{
GivePlayerMoney(playerid, DriftScore[playerid]); //Gives the player the score reward.
PlayerTextDrawHide(playerid, td[playerid]); //Hides the counter TD
format(string, sizeof string, "~g~+$%i", DriftScore[playerid]); //Formats the string
GameTextForPlayer(playerid, string, 2000, 1); //Show a text on the player's screen.
DriftScore[playerid] = 0; //Resets the score counter.
}
case DRIFT_STATE_DRIFTING, DRIFT_STATE_START: //Is player drifting(Main drift Update)
{
DriftScore[playerid] += score; //Adds the score to the reward pool.
format(string, sizeof string, "~b~DRIFT~n~~y~SCORE: ~w~+%i~n~~r~TOTAL: ~g~%i", score, DriftScore[playerid]); //Formats the string
PlayerTextDrawSetString(playerid, td[playerid], string); //Formats the string
PlayerTextDrawShow(playerid, td[playerid]); //Updates the counter TD.
}
}
return 1;
}
Changelog:
Version 1.0:
Video:
https://www.youtube.com/watch?v=Zaj3aro6c8c
Download:
https://************/ndrift-release
Credits:
a_samp: SAMP Team
Y_Hooks: ******
Luby for the filterscript i could edit.
Looks good and you've some great content on your YT channel. I loved it. Great job!
Nice better than iKarim's! (just kidding) but still good job! will +rep u once i can.