Police Radio
#1

Hello, I really need some help, I have no idea how to script a radio that can used only be Police officers, if someone can help me I would be really thankfull.

If someone dosent understand exactly what I want, I want a /radio command that will allow police officers to talk between eachother. (IC)
Reply
#2

Create a variable to store whether the player is a police officer or not (if you haven't already) then create a command which stores the input of the officer's radio message, check if the params are null, then create a new string and format it however you want, then create a loop through all of the online players and checks if the player is a police officer (using the variable I told you to create) and send the message to the player if they are a police officer, and allow this to loop through all players, so all police officers will receive the message.

Example:

At the top of your script or near it:
pawn Код:
new g_iPoliceOfficer[MAX_PLAYERS];
In the area where you create your commands (note: this uses zcmd)
pawn Код:
CMD:radio(playerid, params[]) {
    if(isnull(params))
        return SendClientMessage(playerid, 0, "Syntax: /radio [message]");
       
    if(g_iPoliceOfficer[i] != 0)
        return SendClientMessage(playerid, 0, "Cops only...");
       
    new
        szMessage[128],
        szPlayerName[MAX_PLAYER_NAME];

    GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
    format(szMessage, sizeof(szMessage), "** (radio) Officer %s: %s", szPlayerName, params);
    for(new i = 0; i < MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i) && g_iPoliceOfficer[i] != 0)
            SendClientMessage(playerid, 0, szMessage);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)