IF get vehicle speed?
#6

So i added what SymonClash said.
and added what Pottus


It works. But not everything.

The full code:

Code:
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;
}

1. I have argument mismatch on:

Code:
if(GetVehicleSpeed(GetPlayerVehicleID(playerid)) <= 210)
and on:

Code:
if(GetVehicleSpeed(GetPlayerVehicleID(playerid)) >= 210)
I tried changing 210 with 210.0 and again its the same.



2. When i decrease my vehicle speed and gets below 210. it should send the message:

Code:
SendClientMessage(playerid, COLOR_RED, "You stopped driving fast, watch out for the cops");
But it doesnt work?. There is no message send
Reply


Messages In This Thread
IF get vehicle speed? - by Lixyde - 25.03.2019, 19:13
Re: IF get vehicle speed? - by Heress - 25.03.2019, 19:20
Re: IF get vehicle speed? - by 4D1L - 25.03.2019, 19:27
Re: IF get vehicle speed? - by SymonClash - 25.03.2019, 20:03
Re: IF get vehicle speed? - by Pottus - 25.03.2019, 20:27
Re: IF get vehicle speed? - by Lixyde - 26.03.2019, 18:42
Re: IF get vehicle speed? - by raydx - 26.03.2019, 19:24
Re: IF get vehicle speed? - by zepfiz - 27.03.2019, 17:29
Re: IF get vehicle speed? - by Lokii - 27.03.2019, 19:17

Forum Jump:


Users browsing this thread: 1 Guest(s)