stock GetVehicleSpeed(vehicleid) { new Float:vx, Float:vy, Float:vz, Float:vel; vel = GetVehicleVelocity(vehicleid, vx, vy, vz); vel = (floatsqroot(((vx*vx)+(vy*vy))+(vz*vz))* 181.5); return Float:vel; } public OnFilterScriptInit() { print("\n--------------------------------------"); print(" Blank Filterscript by your name here"); print("--------------------------------------\n"); return 1; } public OnFilterScriptExit() { return 1; } public VehicleSpeed(playerid) { if(IsPlayerInAnyVehicle(playerid)) { if(GetVehicleSpeed(GetPlayerVehicleID(playerid)) >= 210) { SendClientMessage(playerid, COLOR_RED, "You drive too fast, cops are going to chase you now!"); IsWanted[playerid] = 1; } } return 1; }
So i when you pass 210 KM in your car it should send the message that you are driving too fast.
I tried it, but something doesnt work. Code:
stock GetVehicleSpeed(vehicleid) { new Float:vx, Float:vy, Float:vz, Float:vel; vel = GetVehicleVelocity(vehicleid, vx, vy, vz); vel = (floatsqroot(((vx*vx)+(vy*vy))+(vz*vz))* 181.5); return Float:vel; } public OnFilterScriptInit() { print("\n--------------------------------------"); print(" Blank Filterscript by your name here"); print("--------------------------------------\n"); return 1; } public OnFilterScriptExit() { return 1; } public VehicleSpeed(playerid) { if(IsPlayerInAnyVehicle(playerid)) { if(GetVehicleSpeed(GetPlayerVehicleID(playerid)) >= 210) { SendClientMessage(playerid, COLOR_RED, "You drive too fast, cops are going to chase you now!"); IsWanted[playerid] = 1; } } return 1; } 2. It doesnt work at all, im passing 210 KMH and more, but there is no message. help? |
GetVehicleSpeed(vehicleid, type)
{
//Type 1: MPH - Any other type: KM/H
//GetVehicleSpeed(GetPlayerVehicleID(playerid), 1);
new s;
new Float:x, Float:y, Float:z;
GetVehicleVelocity(vehicleid, x, y, z);
switch(type)
{
case 1: s = floatround((floatsqroot(floatpower(x, 2) + floatpower(y, 2) + floatpower(z, 2)))*112.1577, floatround_round);
default: s = floatround((floatsqroot(floatpower(x, 2) + floatpower(y, 2) + floatpower(z, 2)))*180.5000, floatround_round);
}
return s;
}
static bool:IsSpeeding[MAX_PLAYERS]; public OnPlayerUpdate(playerid) { // Get the seat this determines everything about what the player is doing with // the vehicle and if they are even in one new seat = GetPlayerVehicleSeat(playerid); // Is the player speeding? if(IsSpeeding[playerid]) // Can't be speeding if not in a vehicle if(seat == -1) IsSpeeding[playerid] = false; // Player is driving else if(seat == 0) { // Have they stopped speeding yet? if(GetVehicleSpeed(GetPlayerVehicleID(playerid)) <= 210) { // Not speeding anymore let them know IsSpeeding[playerid] = false; SendClientMessage(playerid, COLOR_GREEN, "You have stopped speeding watch out for the cops"); } } } // Player is not speeding else { // Player is driving if(seat == 0) { // Player is speeding issue the warning set as wanted if(GetVehicleSpeed(GetPlayerVehicleID(playerid)) >= 210) { SendClientMessage(playerid, COLOR_RED, "You are drivin too fast, thw cops are going to chase you now!"); IsWanted[playerid] = 1; } } } return 1; }
new IsWanted[MAX_PLAYERS]; static bool:IsSpeeding[MAX_PLAYERS]; GetVehicleSpeed(vehicleid, type) { //Type 1: MPH - Any other type: KM/H //GetVehicleSpeed(GetPlayerVehicleID(playerid), 1); new s; new Float:x, Float:y, Float:z; GetVehicleVelocity(vehicleid, x, y, z); switch(type) { case 1: s = floatround((floatsqroot(floatpower(x, 2) + floatpower(y, 2) + floatpower(z, 2)))*112.1577, floatround_round); default: s = floatround((floatsqroot(floatpower(x, 2) + floatpower(y, 2) + floatpower(z, 2)))*180.5000, floatround_round); } return s; } public OnPlayerUpdate(playerid) { new seat = GetPlayerVehicleSeat(playerid); if(IsSpeeding[playerid]) { if(seat == -1) { IsSpeeding[playerid] = false; } if(seat == 0) { if(GetVehicleSpeed(GetPlayerVehicleID(playerid)) <= 210) { IsSpeeding[playerid] = false; SendClientMessage(playerid, COLOR_RED, "You stopped driving fast, watch out for the cops"); } } } else { if(seat == 0) { if(GetVehicleSpeed(GetPlayerVehicleID(playerid)) >= 210) { SendClientMessage(playerid, COLOR_RED, "You are drivin too fast, thw cops are going to chase you now!"); IsWanted[playerid] = 1; } } } return 1; }
if(GetVehicleSpeed(GetPlayerVehicleID(playerid)) <= 210)
if(GetVehicleSpeed(GetPlayerVehicleID(playerid)) >= 210)
SendClientMessage(playerid, COLOR_RED, "You stopped driving fast, watch out for the cops");
if(GetVehicleSpeed(GetPlayerVehicleID(playerid), 2) <= 210)
if(GetVehicleSpeed(GetPlayerVehicleID(playerid), 2) >= 210)