Radio System
#1

Hey,

So I was wondering, Is there already a system out there that allows Different Emergency Services to choose Channels.

EG:
Channel 1 = Police
Channel 2 = EMS
Channel 3 = Fire
Channel 4 = State Police.

Say, I'm a cop and I need EMS. I can change from Channel 4 to Channel 2 and call for EMS then switch back to the Police Channel ( 4 ) and talk on the Police Span.

If not, Any ideas on how/where I should start.
Reply
#2

I have an idea but not tested it so it might not work.
Top with other variables
pawn Code:
new channel[MAX_PLAYERS];
Then make a command (im usng zcmd)
pawn Code:
COMMAND:channel(playerid,params[])//use sscanf or strval on this command to make more channels
{
    channel[playerid]= 1;//very basic example you will obviously need to do a bit more coding.
    return 1;
}
Then playertext
pawn Code:
public OnPlayerText(playerid, text[])
{
    if(channel[playerid] == 1)//if the channel is 1
    {
        for(new i; i < MAX_PLAYERS,i++)
        {
            if(GetPlayerTeam(i) == TEAM_POLICE)
            {
                SendClientMessage(i,TEAM_COLOR,text);//you'll probably want to format this message to include the players name.
            }
        }
        return 0;
    }
    return 1;
}
There might be something i missed but you should get the idea.
Reply
#3

Thanks Iggy, I'll have a look and let you know If I get a working Version
Reply
#4

I got most of it working, The part thats annoying is using a command to send teh message to the team, If its using OnPlayerText, That affects normal text and would require another cmd to turn off the radio which would be annoying,
Reply
#5

You could use a system like this (anything after '1' is printed for a certain team).
pawn Code:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '1' && GetPlayerTeam(playerid) == TEAM_POLICE)//if the first charachter is 1 ie.... "1 hello" will print "hello"
    {                                                           // to the sceen for team Police.
        for(new i; i < MAX_PLAYERS,i++)
        {
            if(GetPlayerTeam(i) == TEAM_POLICE)
            {
                SendClientMessage(i,TEAM_COLOR,text);
            }
        }
        return 0;
    }
    return 1;
}
Reply
#6

Quote:
Originally Posted by iggy1
View Post
You could use a system like this (anything after '1' is printed for a certain team).
pawn Code:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '1' && GetPlayerTeam(playerid) == TEAM_POLICE)//if the first charachter is 1 ie.... "1 hello" will print "hello"
    {                                                           // to the sceen for team Police.
        for(new i; i < MAX_PLAYERS,i++)
        {
            if(GetPlayerTeam(i) == TEAM_POLICE)
            {
                SendClientMessage(i,TEAM_COLOR,text);
            }
        }
        return 0;
    }
    return 1;
}
Edited and either:

A: Showed the message to everyone

B: Didnt show anything I typed at all, Even with out the 1.
Reply
#7

Hmm sorry about that i realy thought it would work.
Was you in the correct team when writing?
Reply
#8

Yeah, Even normal people cant type anything
Reply
#9

I made this:

It dosent show what the player typed at all:

pawn Code:
#define FILTERSCRIPT

    #include <a_samp>

#if defined FILTERSCRIPT

new channel[MAX_PLAYERS];
new PlayerTeam[MAX_PLAYERS];

    // ========= TEAMS START =================

    #define Team_Civ 0
    #define Team_LVPD 1
    #define Team_NSP 2
    #define Team_EMS 3
    #define Team_Fire 4
    #define Team_Admin 5
    #define Team_Jail 6
    #define Team_Taxi 7

    // =========== TEAMS END ===========-====

    // =========== NEWS ==============
public OnPlayerText(playerid, text[])
{
if(text[0] == '!')
    {
        new string[256],name3[24];
        GetPlayerName(playerid,name3,24);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if(PlayerTeam[playerid] == Team_NSP && channel[playerid] == 1 || PlayerTeam[playerid] == Team_LVPD && channel[playerid] == 1 || PlayerTeam[playerid] == Team_EMS && channel[playerid] == 1 || PlayerTeam[playerid] == Team_Fire && channel[playerid] == 1)
                format(string,sizeof string,"(NSP): %s: %s",name3,text);
                SendClientMessage(i, 0xB4B5B7AA, string);
            }
        }
        return 0;
    }
    return 1;
}
    // =================== COLORS ======================
    #define COLOR_RED 0xAA3333AA
    #define COLOR_YELLOW 0xFFFF00AA


public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" VCRP Radio System");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#endif

public OnGameModeInit()
{

    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    channel[playerid] = 0;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    channel[playerid] = 0;
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/pdradio", true) == 0)
    {
    channel[playerid] = 1;
    return 1;
    }
    return 0;
}

/*
if(channel[playerid] == 1)//if the channel is 1
    {
        for(new i=0; i<MAX_PLAYERS; i++) {
        {
        if(PlayerTeam[playerid] == Team_NSP || PlayerTeam[playerid] == Team_LVPD || PlayerTeam[playerid] == Team_Fire || PlayerTeam[playerid] == Team_EMS)
            {
                SendClientMessage(i,COLOR_INDIGO,text);
            }
        }
        return 0;
    }
    }
*/


public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}
Reply
#10

This might work and be a bit clearer,
pawn Code:
#define FILTERSCRIPT

#include <a_samp>

// ========= TEAMS START =================
#define Team_Civ 0
#define Team_LVPD 1
#define Team_NSP 2
#define Team_EMS 3
#define Team_Fire 4
#define Team_Admin 5
#define Team_Jail 6
#define Team_Taxi 7


#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA

new PlayerTeam[MAX_PLAYERS];

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" VCRP Radio System");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    if(text[0] == '!' && PlayerTeam[playerid] == Team_LVPD || PlayerTeam[playerid] == Team_NSP || PlayerTeam[playerid] == Team_EMS || PlayerTeam[playerid] == Team_Fire))
    {
        MessageToCivilTeams(text);
        return 0;
    }
    return 1;
}

stock MessageToCivilTeams(message[])
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i))continue;
        if(PlayerTeam[i] == Team_LVPD || PlayerTeam[i] == Team_NSP || PlayerTeam[i] == Team_EMS ||PlayerTeam[i] == Team_Fire)
        {
            SendClientMessage(i,0xB4B5B7AA,message);
        }
    }
}
I hope it works for you. I should of made an "IsPlayerCivilTeam" lol would make that a bit shorter.
Oh and btw i didn't see any code where you set the players team or at least the PlayerTeam variable i hope you have that in the original code :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)