/GetSpeed Not workin right.
#1

I have a GetSpeed Function for my server, but i made a command, it doesnt, work right, i need someone help me fix 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;
}
This is it.
Reply
#2

Anyone ? please i need it.
Reply
#3

BUMP!, im sorry, i need it really. its one of 3 stuff that don't work in my script.
Reply
#4

What do you mean that it doesn't work? What does it say?
Reply
#5

Maybe you could post the GetSpeed function code?
Reply
#6

Getspeed function works prefect Since i have a speedo.

The Problem is it says "This can be only used in copcar" or "You aren't a cop!" or "You can't check other cops speeds!"
Reply
#7

BUMP, i waiting 3 days for this!!
Reply
#8

Uhm, you're getting the speed from the 'target' before you even know who 'target' is. i.e. You are always gettings the speed of id 0, regardless of which id you input to the function.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)