new playerState = GetPlayerState(playerid);
{
if (playerState == PLAYER_STATE_DRIVER)
{
//boosts script
}
}
well you use onplayerstatechange and do if(newstate == PLAYER_STATE_DRIVER) let him use em and use } else { then tell them they cant use it
|
OnPlayerKeyStateChange
//SpeedBoost With Car Fly Nitros by Boom
//Don't Romove the Credits Please
//You can Add it with the credits thanks Enjoy my script
#include a_samp
#define FILTERSCRIPT
#define red 0xF60000AA
#define GREEN 0x21DD00FF
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
#define COLOR_MESSAGE_YELLOW 0xFFDD00AA
//------------------------------------------------------------------------------
new Float:SpeedBoostMultiplier[MAX_PLAYERS];
// -----------------------------------------------------------------------------
public OnFilterScriptInit()
{
print("\n-------------------------------------------------");
print(" Speed Boost With Car Fly Has been loaded by Boom");
print("-------------------------------------------------\n");
for (new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i) && !IsPlayerNPC(i))
{
SpeedBoostMultiplier[i] = 3.0;
}
}
return 1;
}
// -----------------------------------------------------------------------------
public OnFilterScriptExit()
{
print("\n------------------------------------------------");
print(" Unloaded SpeedBoost with CarFly By Boom Successfully");
print("------------------------------------------------\n");
return 1;
}
// -----------------------------------------------------------------------------
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
new idx;
cmd = strtok(cmdtext, idx);
if (strcmp(cmd, "/SpeedBoostSetup", true) == 0 || strcmp(cmd, "/ssb", true) == 0)
{
new strBoostMultiplier[256];
new strTempString[256];
strBoostMultiplier = strtok(cmdtext, idx);
if (!strlen(strBoostMultiplier))
{
return 1;
}
if (!IsNumeric2(strBoostMultiplier))
{
return 1;
}
new Float:BoostMultiplier = floatstr(strBoostMultiplier);
if (BoostMultiplier < 1.0 || BoostMultiplier > 3.0)
{
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "*** Error: You can just change it for 0.1 to 3.0");
return 1;
}
SpeedBoostMultiplier[playerid] = BoostMultiplier;
format(strTempString,sizeof(strTempString), "*** You set your speed boost multiplier to %0.2f", SpeedBoostMultiplier[playerid]);
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, strTempString);
return 1;
}
return 0;
}
// -----------------------------------------------------------------------------
public OnPlayerConnect(playerid)
{
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "*** Welcome To Anti-Knots Team! Enjoy!");
// (the previous player may of changed it)
SpeedBoostMultiplier[playerid] = 2.0; //Its 2.0 you can also doing 3.0 and change it
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[])
{
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;
}
// -----------------------------------------------------------------------------
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys == KEY_CROUCH)
{
if(IsPlayerInAnyVehicle(playerid))
{
{
RepairVehicle(GetPlayerVehicleID(playerid));
}
}
}
if (PRESSED(KEY_FIRE))
{
new
vehicleid = GetPlayerVehicleID(playerid);
if (vehicleid)
{
AddVehicleComponent(vehicleid, 1010);
}
}
if(newkeys & KEY_FIRE && IsPlayerInAnyVehicle(playerid))
{
if(!IsNosVehicle(GetPlayerVehicleID(playerid))) return
AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
PlayerPlaySound(playerid, 1133 ,0, 0, 0);
}
if(newkeys & KEY_SUBMISSION && IsPlayerInAnyVehicle(playerid))
{
if(IsPlayerInAnyVehicle(playerid))
{
new Float:x, Float:y, Float:z;
GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
SetVehicleVelocity(GetPlayerVehicleID(playerid) ,x ,y ,z+0.3);
}
}
if (IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if (newkeys & KEY_FIRE)
{
new Float:vx, Float:vy, Float:vz;
GetVehicleVelocity(GetPlayerVehicleID(playerid), vx, vy, vz);
if (floatabs(vx) < 3 && floatabs(vy) < 3 && floatabs(vz) < 3)
{
SetVehicleVelocity(GetPlayerVehicleID(playerid), vx * SpeedBoostMultiplier[playerid], vy * SpeedBoostMultiplier[playerid], vz * SpeedBoostMultiplier[playerid]);
}
return 1;
}
}
return 1;
}
IsNosVehicle(vehicleid)
{
#define NO_NOS_VEHICLES 52
new InvalidNosVehicles[NO_NOS_VEHICLES] =
{
581,523,462,521,463,522,461,448,468,586,417,425,469,487,512,520,563,593,
509,481,510,472,473,493,520,595,484,430,453,432,476,497,513,533,577,
452,446,447,454,590,569,537,538,570,449,519,460,488,511,519,548,592
};
for(new i = 0; i < NO_NOS_VEHICLES; i++)
{
if(GetVehicleModel(vehicleid) == InvalidNosVehicles[i])
{
return false;
}
}
return true;
}
//SpeedBoost With Car Fly Nitros by Boom
//Don't Romove the Credits Please
//You can Add it with the credits thanks Enjoy my script
#include a_samp
#define FILTERSCRIPT
#define red 0xF60000AA
#define GREEN 0x21DD00FF
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
#define COLOR_MESSAGE_YELLOW 0xFFDD00AA
//------------------------------------------------------------------------------
new Float:SpeedBoostMultiplier[MAX_PLAYERS];
// -----------------------------------------------------------------------------
public OnFilterScriptInit()
{
print("\n-------------------------------------------------");
print(" Speed Boost With Car Fly Has been loaded by Boom");
print("-------------------------------------------------\n");
for (new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i) && !IsPlayerNPC(i))
{
SpeedBoostMultiplier[i] = 3.0;
}
}
return 1;
}
// -----------------------------------------------------------------------------
public OnFilterScriptExit()
{
print("\n------------------------------------------------");
print(" Unloaded SpeedBoost with CarFly By Boom Successfully");
print("------------------------------------------------\n");
return 1;
}
// -----------------------------------------------------------------------------
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
new idx;
cmd = strtok(cmdtext, idx);
if (strcmp(cmd, "/SpeedBoostSetup", true) == 0 || strcmp(cmd, "/ssb", true) == 0)
{
new strBoostMultiplier[256];
new strTempString[256];
strBoostMultiplier = strtok(cmdtext, idx);
if (!strlen(strBoostMultiplier))
{
return 1;
}
if (!IsNumeric2(strBoostMultiplier))
{
return 1;
}
new Float:BoostMultiplier = floatstr(strBoostMultiplier);
if (BoostMultiplier < 1.0 || BoostMultiplier > 3.0)
{
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "*** Error: You can just change it for 0.1 to 3.0");
return 1;
}
SpeedBoostMultiplier[playerid] = BoostMultiplier;
format(strTempString,sizeof(strTempString), "*** You set your speed boost multiplier to %0.2f", SpeedBoostMultiplier[playerid]);
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, strTempString);
return 1;
}
return 0;
}
// -----------------------------------------------------------------------------
public OnPlayerConnect(playerid)
{
SendClientMessage(playerid, COLOR_MESSAGE_YELLOW, "*** Welcome To Anti-Knots Team! Enjoy!");
// (the previous player may of changed it)
SpeedBoostMultiplier[playerid] = 2.0; //Its 2.0 you can also doing 3.0 and change it
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[])
{
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;
}
// -----------------------------------------------------------------------------
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys == KEY_CROUCH)
{
if(IsPlayerInAnyVehicle(playerid))
{
{
RepairVehicle(GetPlayerVehicleID(playerid));
}
}
}
if (PRESSED(KEY_FIRE))
{
new
vehicleid = GetPlayerVehicleID(playerid);
if (vehicleid)
{
AddVehicleComponent(vehicleid, 1010);
}
}
if(newkeys & KEY_FIRE && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == 2)
{
if(!IsNosVehicle(GetPlayerVehicleID(playerid))) return
AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
PlayerPlaySound(playerid, 1133 ,0, 0, 0);
}
if(newkeys & KEY_SUBMISSION && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == 2)
{
new Float:x, Float:y, Float:z;
GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
SetVehicleVelocity(GetPlayerVehicleID(playerid) ,x ,y ,z+0.3);
}
if (IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if (newkeys & KEY_FIRE)
{
new Float:vx, Float:vy, Float:vz;
GetVehicleVelocity(GetPlayerVehicleID(playerid), vx, vy, vz);
if (floatabs(vx) < 3 && floatabs(vy) < 3 && floatabs(vz) < 3)
{
SetVehicleVelocity(GetPlayerVehicleID(playerid), vx * SpeedBoostMultiplier[playerid], vy * SpeedBoostMultiplier[playerid], vz * SpeedBoostMultiplier[playerid]);
}
return 1;
}
}
return 1;
}
IsNosVehicle(vehicleid)
{
#define NO_NOS_VEHICLES 52
new InvalidNosVehicles[NO_NOS_VEHICLES] =
{
581,523,462,521,463,522,461,448,468,586,417,425,469,487,512,520,563,593,
509,481,510,472,473,493,520,595,484,430,453,432,476,497,513,533,577,
452,446,447,454,590,569,537,538,570,449,519,460,488,511,519,548,592
};
for(new i = 0; i < NO_NOS_VEHICLES; i++)
{
if(GetVehicleModel(vehicleid) == InvalidNosVehicles[i])
{
return false;
}
}
return true;
}
public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
if(IsPlayerInAnyVehicle(playerid))
{
if(newkeys &= 2)
{
new Float:ZAngle,Float:X,Float:Y,Float:Z,vehicleid;
vehicleid = GetPlayerVehicleID(playerid);
GetVehiclePos(vehicleid,X,Y,Z);
GetVehicleZAngle(vehicleid,ZAngle);
SetVehicleZAngle(vehicleid,ZAngle);
SetVehiclePos(vehicleid,X,Y,Z+2);
}
}
return 1;
}
public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
if(IsPlayerInAnyVehicle(playerid))
{
if(newkeys &= 2)
{
if( GetPlayerState( playerid ) != PLAYER_STATE_DRIVER ) return SendClientMessage(playerid, -1, "You cant use this since youre not the driver!"); // if the playerstate doesnt equals to 2, it sends him the message
new Float:ZAngle,Float:X,Float:Y,Float:Z,vehicleid;
vehicleid = GetPlayerVehicleID(playerid);
GetVehiclePos(vehicleid,X,Y,Z);
GetVehicleZAngle(vehicleid,ZAngle);
SetVehicleZAngle(vehicleid,ZAngle);
SetVehiclePos(vehicleid,X,Y,Z+2);
}
}
return 1;
}
pawn Код:
|
#include <a_samp> //includes a_samp
new AllCars[93] =
{
400,401,402,404,405,410,411,412,415,418,419,420,421,422,424,426,429,434,436,
438,439,442,445,451,458,466,467,470,474,475,477,478,480,480,480,480,489,490,
491,492,494,496,500,501,502,503,504,505,506,507,516,517,518,526,527,529,533,
534,535,536,540,541,542,543,545,546,547,549,550,551,555,558,559,560,561,562,
565,566,567,575,576,580,585,587,589,596,597,598,600,602,603,604,605,
}; //defines all the cars in game
new Float:x = 2324.3391; //x position
new Float:y = -1270.5941; //y position
new Float:z = 22.1586; //z position
new Float:rot = 180.6980; //rotation
new ccar; //stores the car
forward ccc(); //forward ccc
main()
{
print("ChaseCar loaded!"); //prints ClaseCar loaded!
}
public OnFilterScriptInit()
{
ccar = AddStaticVehicle(562,x,y,z,rot,122,1); // ccar
SetTimer("ccc", 500, 1); //sets the timer
for(new i=0; i<MAX_VEHICLES; i++) //loop
{
if(i == ccar) //if i == ccar
{
SetVehicleNumberPlate(i, "ChaseMe"); //sets the cars number plate
SetVehicleToRespawn(i); //respawns it (VERY IMPORTANT!!!)
}
}
return 1;
}
public OnFilterScriptExit()
{
DestroyVehicle(ccar); //destroys the car
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(vehicleid == ccar) //if vehicleid == ccar
{
new name[MAX_PLAYER_NAME], string[44]; //defines name and string
GetPlayerName(playerid, name, sizeof(name)); //gets the players name
format(string, sizeof(string), "%s has taken the ChaseCar!",name); //formats the message
SendClientMessageToAll(0xFF0000FF, string); //sends the message
}
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(vehicleid == ccar) //if vehicleid == ccar
{
new name[MAX_PLAYER_NAME], string[44]; //defines name and string
GetPlayerName(playerid, name, sizeof(name)); //gets the players name
format(string, sizeof(string), "%s has left the ChaseCar!",name); //formats the message
SendClientMessageToAll(0xFF0000FF, string); //sends the message
}
return 1;
}
public OnVehicleSpawn(vehicleid)
{
if(vehicleid == ccar)
{
ChangeVehiclePaintjob(vehicleid,0); // paint job
AddVehicleComponent(vehicleid, 1038); // roof
AddVehicleComponent(vehicleid, 1079); // rim
AddVehicleComponent(vehicleid, 1037); // exhaust
AddVehicleComponent(vehicleid, 1041); // side
AddVehicleComponent(vehicleid, 1153); // front
AddVehicleComponent(vehicleid, 1148); // rear
AddVehicleComponent(vehicleid, 1139); // Spoiler
AddVehicleComponent(vehicleid, 1010); // Nitrous
SendClientMessageToAll(0xFF0000FF, "The ChaseCar Respawned!!!"); //message
}
return 1;
}
public ccc() //public
{
for(new i=0; i < MAX_PLAYERS; i++) //loop
{
if(IsPlayerInCar(i)) //if player is in car
{
if(GetPlayerVehicleID(i) == ccar) //if player car == ccar
{
GivePlayerMoney(i, 500); //gives player money
}
}
}
}
stock IsPlayerInCar(playerid) //function
{
new vehicleid = GetPlayerVehicleID(playerid); //gets the vehicle id
if(!IsPlayerInAnyVehicle(playerid)) return 0; //if player aint in cat, return 0;
for(new i = 0; i < 93; i++) //loop
{
if(GetVehicleModel(vehicleid) == AllCars[i]) //if the car is a car in allcars
{
return 1; //returns 1
}
}
return 0; //returns 0
}
if( GetPlayerVehicleID(playerid) == ChaseCarVariableHere || GetPlayerVehicleID(playerid) == ChaseCarVariableHere2 ) return SendClientMessage(playerid, -1, "You cant perform this while youre driving a chase car!");