[FilterScript] [Filterscript] Speed Boost for 0.3
#15

C:\Documents and Settings\WINXP\Escritorio\bost.pwn(127) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Warning.
why? xD


// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Vehicle Speed Boost FilterScript for SAMP 0.3
// 2nd September 2009
// By Matite
// Special thanks to kc!
// v1.0.1
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Includes...
// -----------
// SAMP
#include <a_samp>
// -----------------------------------------------------------------------------
// Defines...
// ----------
// Used for messages sent to the player
#define COLOR_MESSAGE_YELLOW 0xFFDD00AA
// -----------------------------------------------------------------------------
// Variables...
// ------------
// Stores the players speed boost factor
// (it is set to the default of 1.5 when the FS is loaded or when a player connects)
new Float:SpeedBoostMultiplier[MAX_PLAYERS];
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------


public OnFilterScriptInit()
{
// Print to server console
print("\n-------------------------------------------------");
print(" Speed Boost Filterscript for SAMP 0.3 by Matite");
print("-------------------------------------------------\n");

// Loop
for (new i = 0; i < MAX_PLAYERS; i++)
{
// Check if player is connected and not a NPC
if (IsPlayerConnected(i) && !IsPlayerNPC(i))
{
// Set the default speed boost for each player
SpeedBoostMultiplier[i] = 1.5;
}
}

// Exit here
return 1;
}

// -----------------------------------------------------------------------------


public OnFilterScriptExit()
{
// Print to server console
print("\n------------------------------------------------");
print(" Unloaded Speed Boost Filterscript for SAMP 0.3");
print("------------------------------------------------\n");
// Exit here
return 1;
}
// -----------------------------------------------------------------------------

public OnPlayerCommandText(playerid, cmdtext[])
{
// Create variables
new cmd[256];
new idx;

// Get the command
cmd = strtok(cmdtext, idx);

// Check command typed
if (strcmp(cmd, "/setspeedboost", true) == 0 || strcmp(cmd, "/ssb", true) == 0)
{
// Create string variables
new strBoostMultiplier[256];
new strTempString[256];

// Get the vaue typed
strBoostMultiplier = strtok(cmdtext, idx);

// Check a boost factor was supplied
if (!strlen(strBoostMultiplier))
{
// Send message and exit here
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "** Usage: /setspeedboost <SpeedBoostMultiplier>");
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* Allows you to set the speed boost multiplier that is applied when you press the horn key.");
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* Accepted speed boost multiplier values are between 1.0 and 3.0");
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* The shortcut for this command is: /ssb");
format(strTempString,sizeof(strTempString), "* Your current speed boost multiplier is: %0.2f", SpeedBoostMultiplier[playerid]);
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, strTempString);
return 1;
}

// Check the boost factor supplied is numeric
if (!IsNumeric2(strBoostMultiplier))
{
// Send message and exit here
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "** Usage: /setspeedboost <BoostMultiplier>");
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* Allows you to set the speed boost multiplier that is applied when you press the horn key.");
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* Accepted speed boost multiplier values are between 1.0 and 3.0");
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* The shortcut for this command is: /ssb");
format(strTempString,sizeof(strTempString), "* Your current speed boost multiplier is: %0.2f", SpeedBoostMultiplier[playerid]);
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, strTempString);
return 1;
}


// Convert to float
new Float:BoostMultiplier = floatstr(strBoostMultiplier);

// Check speed boost multiplier is not too high or low
if (BoostMultiplier < 1.0 || BoostMultiplier > 3.0)
{
// Send message and exit here
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* Sorry, you must enter a speed boost multiplier between 1.0 and 3.0");
return 1;
}

// Store the new speed boost multiplier value for the player

// Format and send message

SpeedBoostMultiplier[playerid] = BoostMultiplier;
format(strTempString,sizeof(strTempString), "* You set your speed boost multiplier to %0.2f", SpeedBoostMultiplier[playerid]);
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, strTempString);

// Exit here
return 1;
}

// Exit here and return 0 (the command was not processed here)
return 0;
}


// -----------------------------------------------------------------------------

public OnPlayerConnect(playerid)
{
// Set the default speed boost for the player
// (the previous player may of changed it)
SpeedBoostMultiplier[playerid] = 1.5;

// Send message
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "* Speed Boost v1.01 by Matite - type /ssb to set your speed boost factor.");

// Exit here
return 1;
}
// -----------------------------------------------------------------------------


public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
// Check if the player is in any vehicle and is the driver
if (IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
// Check for the HORN key (Crouch key is the same as the horn key)
if (newkeys & KEY_CROUCH)
{
// Create variables
new Float:vx, Float:vy, Float:vz;

// Get the vehicles velocity
GetVehicleVelocity(GetPlayerVehicleID(playerid), vx, vy, vz);

// Check the values are not too high already
if (floatabs(vx) < 3 && floatabs(vy) < 3 && floatabs(vz) < 3)
{
// Boost the vehicle speed
SetVehicleVelocity(GetPlayerVehicleID(playerid), vx * SpeedBoostMultiplier[playerid], vy * SpeedBoostMultiplier[playerid], vz * SpeedBoostMultiplier[playerid]);
}

// Exit here
return 1;
}
}

// Exit here
return 1;
}


// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

stock strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}

new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}

// -----------------------------------------------------------------------------

IsNumeric2(const string[])
{
// Is Numeric Check 2
// ------------------
// By DracoBlue... handles negative numbers

new length=strlen(string);
if (length==0) return false;
for (new i = 0; i < length; i++)
{
if((string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+' && string[i]!='.') // Not a number,'+' or '-' or '.'
|| (string[i]=='-' && i!=0) // A '-' but not first char.
|| (string[i]=='+' && i!=0) // A '+' but not first char.
) return false;
}
if (length==1 && (string[0]=='-' || string[0]=='+' || string[0]=='.')) return false;
return true;
}

// -----------------------------------------------------------------------------
// --------------------------------------------------------------
Reply


Messages In This Thread
[Filterscript] Speed Boost for 0.3 - by Matite - 02.09.2009, 13:06
Re: Speed Boost Filterscript for 0.3 - by javind0 - 02.09.2009, 13:26
Re: Speed Boost Filterscript for 0.3 - by brett7 - 02.09.2009, 13:49
Re: Speed Boost Filterscript for 0.3 - by Shubham - 02.09.2009, 14:18
Re: [Filterscript] Speed Boost for 0.3 - by @TheShadow@ - 02.09.2009, 15:18
Re: [Filterscript] Speed Boost for 0.3 - by GAYA - 21.10.2009, 17:29
Re: [Filterscript] Speed Boost for 0.3 - by heufix - 21.10.2009, 18:29
Re: [Filterscript] Speed Boost for 0.3 - by Luka P. - 22.10.2009, 14:28
Re: [Filterscript] Speed Boost for 0.3 - by SamSam - 24.10.2009, 07:05
Re: [Filterscript] Speed Boost for 0.3 - by addysnow1 - 24.10.2009, 13:36
Re: Speed Boost Filterscript for 0.3 - by ke6i - 24.10.2009, 18:15
Re: [Filterscript] Speed Boost for 0.3 - by SergiKirov - 24.10.2009, 18:30
Re: [Filterscript] Speed Boost for 0.3 - by meegan1 - 08.11.2009, 19:09
Re: [Filterscript] Speed Boost for 0.3 - by rk01-1 - 08.11.2009, 19:45
Re: [Filterscript] Speed Boost for 0.3 - by [TBB]Darkness - 16.12.2009, 02:05
Re: [Filterscript] Speed Boost for 0.3 - by DiddyBop - 25.12.2009, 14:02
Re: [Filterscript] Speed Boost for 0.3 - by winczek1 - 09.01.2010, 07:07
Re: [Filterscript] Speed Boost for 0.3 - by Cedimedi - 09.01.2010, 07:19
Re: [Filterscript] Speed Boost for 0.3 - by [NNFc]MinDs - 06.02.2010, 13:29
Re: [Filterscript] Speed Boost for 0.3 - by CristianTdj - 07.04.2010, 15:45
Re: [Filterscript] Speed Boost for 0.3 - by McX_9 - 07.04.2010, 15:53
Re: [Filterscript] Speed Boost for 0.3 - by Zh3r0 - 07.04.2010, 17:38
Re: [Filterscript] Speed Boost for 0.3 - by Adil - 07.04.2010, 17:42
Re: [Filterscript] Speed Boost for 0.3 - by McX_9 - 08.04.2010, 15:27
Re: [Filterscript] Speed Boost for 0.3 - by MX_Master - 08.04.2010, 15:46
Re: [Filterscript] Speed Boost for 0.3 - by MrEnd - 08.04.2010, 16:00
Re: [Filterscript] Speed Boost for 0.3 - by russo666 - 08.04.2010, 16:33
Re: [Filterscript] Speed Boost for 0.3 - by Basicz - 18.09.2010, 09:41
Re: [Filterscript] Speed Boost for 0.3 - by royal_king - 18.09.2010, 11:26
Re: [Filterscript] Speed Boost for 0.3 - by chaosnz - 20.09.2010, 20:02
Re: [Filterscript] Speed Boost for 0.3 - by niels44 - 26.10.2012, 16:07
Re: [Filterscript] Speed Boost for 0.3 - by XProtocol - 26.10.2012, 16:14
Re: [Filterscript] Speed Boost for 0.3 - by TheNeeraz - 08.11.2014, 00:45
Re : [Filterscript] Speed Boost for 0.3 - by Doranne - 08.11.2014, 01:01
Re: [Filterscript] Speed Boost for 0.3 - by Abagail - 08.11.2014, 01:44

Forum Jump:


Users browsing this thread: 2 Guest(s)