Help editing this Radar Detector Command
#1

Ok so someone helped me put together this Radar Detector command (it will detect Poice Officers in the area).

My question is how can I make it constantly check when they type /detector instead of just doing one check. I want it so that /detector begins checking and /detectoroff stope the detection. I think I need to make a timer for this, but I have no idea how to. I also want it to be on a player message and not a dialoge. Can someone help me finish this code?

Thanks: jakejohnsonusa


Here is what I have:
pawn Код:
if (strcmp("/detector", cmdtext, true, 10) == 0)
    {
        new counter = 0, player[268];
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerInRangeOfPoint(i, 30.0, x, y, z) && i != playerid && IsPlayerConnected(i) && IsACop(i))
            {
                counter++;
            }
        }
        if(counter == 0) return SendClientMessage(playerid, 0xFF0000FF, "No one is in your range.");
        strdel(string, 0, strlen(string));
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerInRangeOfPoint(i, 30.0, x, y, z) && i != playerid && IsPlayerConnected(i) && IsACop(i))
            {
                format(player, sizeof(player), "%s (%d)\n", Nick(i), i);
                strins(string, player, strlen(string), sizeof(string));
            }
        }
        ShowPlayerDialog(playerid, 1592, DIALOG_STYLE_MSGBOX, "Radar", string, "Okay", "");
        strdel(string, 0, strlen(string));
        return 1;
    }
pawn Код:
stock Nick(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
Reply
#2

Anyone know?
Reply
#3

put the current code into a public
then just run a TimerEx calling the callback
edit give me a few mins i will make it.
Reply
#4

Ok I will try, but I am a relatively new scripter...
Reply
#5

EDITED i shorten the code
pawn Код:
//at the top
new DetectorTimer[MAX_PLAYERS];

if (strcmp("/detectoron", cmdtext, true, 10) == 0)
    {
        if(DetectorTimer[playerid] != -1) KillTimer(DetectorTimer[playerid]);
        DetectorTimer[playerid] = SetTimerEx("RunDetector", 2000, true, "i", playerid);
        SendClientMessage(playerid,-1,"Detector On");
        return 1;
    }
if (strcmp("/detectoroff", cmdtext, true, 10) == 0)
    {
        SendClientMessage(playerid,-1,"Detector OFF");
        KillTimer(DetectorTimer[playerid]);
        return 1;
    }

forward RunDetector(playerid)
public RunDetector(playerid)
{
        new counter = 0, string[128];
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerInRangeOfPoint(i, 30.0, x, y, z) && i != playerid && IsPlayerConnected(i) && IsACop(i))
            {
                format(string, sizeof(string), "%s (%d)", Nick(i), i);
                SendClientMessage(playerid,-1,string);
                counter++;
            }
        }
        if(counter == 0) return SendClientMessage(playerid, 0xFF0000FF, "No one is in your range.");
        return 1;
}
that should do it
I have not compiled it,but should have no problem!
Reply
#6

THANK YOU +1 REP... I will test now and edit this post if it works well or not.
Reply
#7

Quote:
Originally Posted by park4bmx
Посмотреть сообщение
pawn Код:
// CODE
1. The "/detectoron" command would always return the message
2. You never assign a value to the variable DetectorTimer
3. Both commands are missing their returns
Reply
#8

What do you mean by "You never assign a value to the variable DetectorTimer"
Reply
#9

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
1. The "/detectoron" command would always return the message
2. You never assign a value to the variable DetectorTimer
3. Both commands are missing their returns
Quote:
Originally Posted by jakejohnsonusa
Посмотреть сообщение
What do you mean by "You never assign a value to the variable DetectorTimer"
hes right didnt think about it that way
i edited it
but your prob going on need a new variable to check if its on/off
Reply
#10

EDIT:

Sweet, but I just tried it and I did /detectoron and then /detectoroff and I get "Detector Already On" everytime...

To make this be awesome (so it doesn't clutter up the chat messages) is there a way to make this a textdraw under the chat messages?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)