31.12.2010, 00:39
I have a GetSpeed Function for my server, but i made a command, it doesnt, work right, i need someone help me fix it
This is it.
pawn Code:
dcmd_speed(playerid,params[])
{
new
target, string[128], speed, Float:x, Float:y, Float:z, vehan = GetPlayerVehicleID(playerid);
speed = GetSpeed(target);
if(PlayerInfo[playerid][IsCop] == 0)
return SendClientMessage(playerid,red,"You aren't a cop!");
if(sscanf(params,"u",target))
return SendClientMessage(playerid,red,"USAGE: /speed [ID]");
if(target == INVALID_PLAYER_ID)
return SendClientMessage(playerid,red,"Invalid playerid or name!");
if(GetVehicleModel(vehan) == 596 || GetVehicleModel(vehan) == 597 || GetVehicleModel(vehan) == 598)
return SendClientMessage(playerid,red,"This can be only used in copcar!");
if(PlayerInfo[target][IsCop] == 1)
return SendClientMessage(playerid,red,"You can't check other cops speeds!");
if(!IsPlayerInAnyVehicle(target))
return SendClientMessage(playerid,red,"Targets must be in a vehicle!");
GetPlayerPos(target,x,y,z);
if(!IsPlayerInRangeOfPoint(playerid,20,x,y,z))
return SendClientMessage(playerid,red,"You are too far away!");
format(string,sizeof(string),"%s is driving %d km/h",PlayerName(target),speed);
SendClientMessage(playerid,COLOR_WHITE,string);
if(speed >= 0 && speed <= 79) return 0;
else if(speed >= 80 && speed <= 139)
return SetPlayerColor(target,COLOR_YELLOW),
SendClientMessage(playerid,red,"That speed is good, no action needed");
else if(speed >= 140 && speed <= 199)
return SetPlayerColor(target,orange),
SendClientMessage(playerid,red,"That speed is little too fast, go give him a ticket!"), GivePlayerWantedLevel(target,3);
else if(speed >= 200)
return SetPlayerColor(target,red),
SendClientMessage(playerid,red,"That speed is too fast, arrest him!"),
GivePlayerWantedLevel(target,10);
else if(speed >= 240)
return SetPlayerColor(target,red),
SendClientMessage(playerid,red,"He is Going To Fast ARREST HIM!"),
GivePlayerWantedLevel(target,15);
return true;
}