26.12.2011, 21:10
hi all i want to make a radar gun that police only can have , i want it to work off a timer and to be useable by using is player in range of another player i was told.
something like this but needs a timer to be used of 1 second
something like this but needs a timer to be used of 1 second
pawn Код:
stock GetVehicleSpeed(vehicleid)
{
if(vehicleid != INVALID_VEHICLE_ID)
{
new Float:Pos[3],Float:VS ;
GetVehicleVelocity(vehicleid, Pos[0], Pos[1], Pos[2]);
VS = floatsqroot(Pos[0]*Pos[0] + Pos[1]*Pos[1] + Pos[2]*Pos[2])*200;
return floatround(VS,floatround_round);
}
return INVALID_VEHICLE_ID;
}
stock GetPlayerSpeed(playerid)
{
if(playerid != INVALID_PLAYER_ID)
{
new Float:Pos[3],Float:PS;
GetPlayerVelocity(playerid, Pos[0], Pos[1], Pos[2]);
PS = floatsqroot(Pos[0]*Pos[0] + Pos[1]*Pos[1] + Pos[2]*Pos[2])*200;
return floatround(PS,floatround_round);
}
return INVALID_PLAYER_ID;
}
CMD:radargun(playerid,params[])
{
new Float:playerposx,Float:playerposy,Float:playerposz,wantedlevel;
if(ClassPolice && GetPlayerWeapon(playerid) == 43)
{
GetPlayerPos(playerid,playerposx,playerposy,playerposz);
{
if (IsPlayerConnected(playerid))
{
SetTimerEx("radargun",1000,0,"%d",playerid);
if (IsPlayerInRangeOfPoint(playerid,playerposx,playerposy,playerposz,60.0) && GetPlayerSpeed(playerid) <= 120)
{
SetPlayerWantedLevel(playerid,wantedlevel+1);
}
}
}
}
return 1;
}