Speed Traps
#1

I want to make it so that if a player is going over a certain speed in a zone hes fined a certain amount. How would i make it so if the player is near the point lets say 1400, -500, 12 (I made this up on the top of my head) And hes going over 90 KPH hes fined $250?
Reply
#2

Anyone?
Reply
#3

pawn Код:
if (IsPlayerInRangeOfPoint(playerid, 30.0, x, y, z)
{
    if (speed > 90)
      {
         GivePlayerMoney(playerid, -250);
         SendClientMessage(playerid, COLOR_RED, "You have been fined $250 for going over the speed limit! Please slow down");
      }
}
Reply
#4

Do i just put this anywhere or does it have to be under like OnPlayerUpdate or something?
Reply
#5

@Rokzlive, his example wont work, because his pulling "speed" out from his ass.

http://forum.sa-mp.com/showthread.ph...eed#post951796
http://forum.sa-mp.com/showthread.ph...eed#post547265
Reply
#6

Quote:
Originally Posted by Retardedwolf
Посмотреть сообщение
@Rokzlive, his example wont work, because his pulling "speed" out from his ass.

http://forum.sa-mp.com/showthread.ph...eed#post951796
http://forum.sa-mp.com/showthread.ph...eed#post547265
I'm assuming that he already has a "speed" formula defined.
Reply
#7

pawn Код:
stock GetVehicleSpeed(vehicleid)
{
    new Float:v_vX, Float:v_vY, Float:v_vZ, Float:retres;
    GetVehicleVelocity(vehicleid, v_vX, v_vY, v_vZ);
    retres = floatsqroot(floatabs(floatpower(v_vX + v_vY + v_vZ, 2)));
    return floatround(retres * 100, floatround_ceil);
}
pawn Код:
OnGameModeInit()
SetTimer("SpeedTrap",1000,true);//Setting a timer to check if the player is in that Zone with a time of 1 second (1000 ms = 1 second) and the timer will be repeated (true) if you want the timer not to be repeated (false).
pawn Код:
forward SpeedTrap(playerid,vehicleid)
public SpeedTrap(playerid,vehicleid)
{
    new pstats = GetPlayerState(playerid);//Storing GetPlayerState(playerid) in pstate
    if(pstate = PLAYER_STATE_DRIVER)
    if(IsPlayerInRangeOfPoint(playerid,10.0,x,y,z))//Replace the x,y and z with your cords
    if(GetVehicleSpeed(vehicleid) > 50))
    //SetPlayerWantedLevel(playerid,1);
    //GivePlayerCash(playerid,-250);
    return 1;
}
Not tested.
Reply
#8

Like truckmania eh?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)