Beacon from cop backup showing to all players
#1

When a cop types /bk it beacons for the whole server to see. How can I make it that it shows for SAPD only? Thanks!

pawn Код:
CMD:bk(playerid,params[])
{
    new string[128];
    new oname[24];
    new playerb;
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(!IsACop(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not an SAPD Oficer.");
    if(ReqBkRecent[playerid] == 1)
    {
        SendClientMessage(playerid, COLOR_BLUE, "You have asked for backup recently. Please wait before asking for backup again");
        return 1;
    }
    GetPlayerName(playerid,oname, 24);
    for(new i=0;i<GetMaxPlayers();i++)
    format(string, sizeof(string), "ALL UNITS: %s is requesting backup! They have been marked on your GPS in blue.", RPN(playerid), RPN(playerb));
    SendCopMessage(COLOR_DARKRED, string);
    ReqBk[playerid] =1;
    SetPlayerColor(playerid,COLOR_PURPLE);
    SetTimer("CopBackUpColour", 10000, 0);
    ReqBkRecent[playerid] =1;
    SetTimerEx("ReqBkRecentTime",50000,0,"i",playerid);
    return 1;
}
Reply
#2

Also, here are the Public Function/Variable things:

pawn Код:
forward ReqBkRecentTime(playerid);
public ReqBkRecentTime(playerid)
{
    ReqBkRecent[playerid] =0;
}
Reply
#3

This?
pawn Код:
CMD:bk(playerid,params[])
{
    new string[128];
    new oname[24];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(!IsACop(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not an SAPD Oficer.");
    if(ReqBkRecent[playerid] == 1)
    {
        SendClientMessage(playerid, COLOR_BLUE, "You have asked for backup recently. Please wait before asking for backup again");
        return 1;
    }
    GetPlayerName(playerid,oname, 24);
    format(string, sizeof(string), "ALL UNITS: %s is requesting backup! They have been marked on your GPS in blue.", oname);
    SendCopMessage(COLOR_DARKRED, string);
    ReqBk[playerid] =1;
    SetPlayerColor(playerid,COLOR_PURPLE);
    SetTimer("CopBackUpColour", 10000, 0);
    ReqBkRecent[playerid] =1;
    SetTimerEx("ReqBkRecentTime",50000,0,"i",playerid);
    return 1;
}

stock SendCopMessage(color, const string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsACop(i))
            {
                SendClientMessage(i, color, string);
            }
        }
    }
    return 1;
}
Reply
#4

It is the beacon on the minimap that shows for everyone not the message but I will try that..
Reply
#5

Just replace he's SendClientMessage to SetPlayerCheckpoint or whatever you use to locate that person.
Reply
#6

Quote:
Originally Posted by Kitten
Посмотреть сообщение
Just replace he's SendClientMessage to SetPlayerCheckpoint or whatever you use to locate that person.
You mean like this? I am sorry. I am really bad when it comes to this.

pawn Код:
stock SendCopMessage(color, const string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsACop(i))
            {
                SetPlayerCheckpoint(i, color, string);
            }
        }
    }
    return 1;
}
Reply
#7

Oh... you should have explained it in more detail.

Try this one:
pawn Код:
CMD:bk(playerid,params[])
{
    new string[128];
    new oname[24];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(!IsACop(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not an SAPD Oficer.");
    if(ReqBkRecent[playerid] == 1)
    {
        SendClientMessage(playerid, COLOR_BLUE, "You have asked for backup recently. Please wait before asking for backup again");
        return 1;
    }
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerName(playerid,oname, 24);
    format(string, sizeof(string), "ALL UNITS: %s is requesting backup! Their location has been marked on your GPS.", oname);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsACop(i))
            {
                SendClientMessage(i, COLOR_DARKRED, string);
                SetPlayerMapIcon(i, 1, X, Y, Z, ,20, 0, MAPICON_GLOBAL);
                SetTimerEx("RemoveBeacon", 30000, false, "i", i);
            }
        }
    }
    ReqBk[playerid] =1;
    SetPlayerColor(playerid,COLOR_PURPLE);
    SetTimer("CopBackUpColour", 10000, 0);
    ReqBkRecent[playerid] =1;
    SetTimerEx("ReqBkRecentTime",50000,0,"i",playerid);
    return 1;
}

forward RemoveBeacon(playerid);
public RemoveBeacon(playerid)
{
    RemovePlayerMapIcon(playerid, 1);
    return 1;
}
EDIT: With this code, you can remove the SendCopMessage stock function.
Reply
#8

Thanks! The only error I get while compiling is this:

Quote:

C:\Users\Grant\Desktop\zGamingRoleplay\gamemodes\Z RP.pwn(5779) : error 017: undefined symbol "X"
C:\Users\Grant\Desktop\zGamingRoleplay\gamemodes\Z RP.pwn(5779) : warning 215: expression has no effect
C:\Users\Grant\Desktop\zGamingRoleplay\gamemodes\Z RP.pwn(5779) : warning 215: expression has no effect
C:\Users\Grant\Desktop\zGamingRoleplay\gamemodes\Z RP.pwn(5779) : warning 215: expression has no effect
C:\Users\Grant\Desktop\zGamingRoleplay\gamemodes\Z RP.pwn(5779) : error 001: expected token: ";", but found ")"
C:\Users\Grant\Desktop\zGamingRoleplay\gamemodes\Z RP.pwn(5779) : error 029: invalid expression, assumed zero
C:\Users\Grant\Desktop\zGamingRoleplay\gamemodes\Z RP.pwn(5779) : fatal error 107: too many error messages on one line

EDIT: It is these lines:

pawn Код:
{
        if(IsPlayerConnected(i))
        {
            if(IsACop(i))
            {
                SendClientMessage(i, COLOR_DARKRED, string);
                SetPlayerMapIcon(i, 1, X, Y, Z, ,20, 0, MAPICON_GLOBAL);
                SetTimerEx("RemoveBeacon", 30000, false, "i", i);
            }
        }
    }
Reply
#9

Sorry, just edited my post above like 20 seconds ago, pasted the wrong code.
Reply
#10

Only errors I get now are these ones:

Quote:

C:\Users\Grant\Desktop\zGamingRoleplay\gamemodes\Z RP.pwn(5782) : error 029: invalid expression, assumed zero
C:\Users\Grant\Desktop\zGamingRoleplay\gamemodes\Z RP.pwn(5782) : warning 215: expression has no effect
C:\Users\Grant\Desktop\zGamingRoleplay\gamemodes\Z RP.pwn(5782) : warning 215: expression has no effect
C:\Users\Grant\Desktop\zGamingRoleplay\gamemodes\Z RP.pwn(5782) : warning 215: expression has no effect
C:\Users\Grant\Desktop\zGamingRoleplay\gamemodes\Z RP.pwn(5782) : error 001: expected token: ";", but found ")"
C:\Users\Grant\Desktop\zGamingRoleplay\gamemodes\Z RP.pwn(5782) : error 029: invalid expression, assumed zero
C:\Users\Grant\Desktop\zGamingRoleplay\gamemodes\Z RP.pwn(5782) : fatal error 107: too many error messages on one line

Line 5782:
pawn Код:
SetPlayerMapIcon(i, 1, X, Y, Z, ,20, 0, MAPICON_GLOBAL);
Reply
#11

Oops. An extra comma :P

pawn Код:
SetPlayerMapIcon(i, 1, X, Y, Z, 20, 0, MAPICON_GLOBAL);
Reply
#12

Quote:
Originally Posted by clarencecuzz
Посмотреть сообщение
Oops. An extra comma :P

pawn Код:
SetPlayerMapIcon(i, 1, X, Y, Z, 20, 0, MAPICON_GLOBAL);
How did I not see that? xD. Thanks for your amazing help. +1 REP
Reply
#13

One more thing on another CMD... When I /checkbelt it should say the persons name that I checked when it actually says mine (eg. thepersonwhotypedthecommandname is Using his Belt/Helmet Correctly) Could you help me fix it please?

pawn Код:
CMD:checkbelt(playerid, params[])
    {
        new string[128], giveplayerid;
        if(IsPlayerConnected(playerid))
        {
            if(!IsACop(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not an SAPD Oficer.");
            if(PlayerInfo[playerid][pFacDuty] != 1)
            {
                SendClientMessage(playerid, COLOR_GREY, "** You are not on Duty!");
                return 1;
            }
            if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /checkbelt [playerid/part of name]");
            if(IsPlayerConnected(giveplayerid))
            {
                if(giveplayerid != INVALID_PLAYER_ID)
                {
                    if(IsPlayerInAnyVehicle(giveplayerid))
                    {
                        if (ProxDetectorS(5.0, playerid, giveplayerid))
                        {
                            if(UsingBelt[giveplayerid] == 1)
                            {
                                format(string, sizeof(string), "%s is Using his Belt/Helmet Correctly.", RPN(playerid));
                            }
                            else if(UsingBelt[giveplayerid] == 0)
                            {
                                format(string, sizeof(string), "%s is Not Using his Belt/Helmet.", RPN(playerid));
                            }
                            SendClientMessage(playerid, COLOR_GREY, string);
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOR_GREY, "* You must be Near the Player To Search him!");
                            return 1;
                        }
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GREY, "** Player is not on a Vehicle!");
                        return 1;
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "** Invalid Player ID!");
                    return 1;
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "** Not Connected Player!");
                return 1;
            }
        }
        return 1;
    }
Reply
#14

Change RPN(playerid) to RPN(giveplayerid).

EDIT:
pawn Код:
CMD:checkbelt(playerid, params[])
    {
        new string[128], giveplayerid;
        if(IsPlayerConnected(playerid))
        {
            if(!IsACop(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not an SAPD Oficer.");
            if(PlayerInfo[playerid][pFacDuty] != 1)
            {
                SendClientMessage(playerid, COLOR_GREY, "** You are not on Duty!");
                return 1;
            }
            if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /checkbelt [playerid/part of name]");
            if(IsPlayerConnected(giveplayerid))
            {
                if(giveplayerid != INVALID_PLAYER_ID)
                {
                    if(IsPlayerInAnyVehicle(giveplayerid))
                    {
                        if (ProxDetectorS(5.0, playerid, giveplayerid))
                        {
                            if(UsingBelt[giveplayerid] == 1)
                            {
                                format(string, sizeof(string), "%s is Using his Belt/Helmet Correctly.", RPN(giveplayerid));
                            }
                            else if(UsingBelt[giveplayerid] == 0)
                            {
                                format(string, sizeof(string), "%s is Not Using his Belt/Helmet.", RPN(giveplayerid));
                            }
                            SendClientMessage(playerid, COLOR_GREY, string);
                        }
                        else
                        {
                            SendClientMessage(playerid, COLOR_GREY, "* You must be Near the Player To Search him!");
                            return 1;
                        }
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GREY, "** Player is not on a Vehicle!");
                        return 1;
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "** Invalid Player ID!");
                    return 1;
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "** Not Connected Player!");
                return 1;
            }
        }
        return 1;
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)