16.12.2009, 02:05
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;
}
// -----------------------------------------------------------------------------
// --------------------------------------------------------------
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;
}
// -----------------------------------------------------------------------------
// --------------------------------------------------------------