faction radio
#1

Код:
CMD:cr(playerid, params[]) return cmd_radio(playerid, params);
CMD:radio(playerid, params[])
{
    new string[128], text[128], ctext[60], pname[MAX_PLAYER_NAME+1];//establishes a few things needed to tell the players name, rank, and the text he has written.
    GetPlayerName(playerid, pname, sizeof(pname));//gets the name of the player using /radio
    if(pInfo[playerid][Faction] == 1)//checks if the player is in the first faction
    if(sscanf(params, "s[128]", text)) return SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} /r(adio) [text]");//if /r is not used correctly it will tell you the correct way to use it
    {

        if(pInfo[playerid][FactionTier] == 1){ ctext = "Chief"; }//all of these check the players rank and
        if(pInfo[playerid][FactionTier] == 2){ ctext = "Deputy Chief"; }// sets each rank to a specific name
        if(pInfo[playerid][FactionTier] == 3){ ctext = "Squad Commander"; }
        if(pInfo[playerid][FactionTier] == 4){ ctext = "Traffic Squad Commander"; }
        if(pInfo[playerid][FactionTier] == 5){ ctext = "S.W.A.T Squad Commander"; }
        if(pInfo[playerid][FactionTier] == 6){ ctext = "Public Relations Officer"; }
        if(pInfo[playerid][FactionTier] == 7){ ctext = "Traffic Officer"; }
        if(pInfo[playerid][FactionTier] == 8){ ctext = "S.W.A.T Unit"; }
        if(pInfo[playerid][FactionTier] == 9){ ctext = "Senior Officer"; }
        if(pInfo[playerid][FactionTier] == 10){ ctext = "Trainee Officer"; }
        format(string, sizeof(string), "(Radio) %s %s: %s", ctext, pname, text);
        if(pInfo[playerid][Faction] > 0)//if the player is not in a faction it will not send him any messages
        {
            SendCopMessage(COLOR_PDRAD, string);//calls a stock below that checks who the /r should be sent to
        }
    }
    return 1;
}

CMD:er(playerid, params[]) return cmd_emsradio(playerid, params);
CMD:emsradio(playerid, params[])
{
    new string[128], text[128], pname[MAX_PLAYER_NAME+1];//establishes a few things needed to tell the players name, rank, and the text he has written.
    GetPlayerName(playerid, pname, sizeof(pname));//gets the name of the player using /radio
    if(pInfo[playerid][Faction] == 2)//checks if the player is in the first faction
    if(sscanf(params, "s[128]", text)) return SendClientMessage(playerid, COLOR_WHITE, "SERVER:{FFFFFF} /r(adio) [text]");//if /r is not used correctly it will tell you the correct way to use it
    {
    format(string, sizeof(string), "(Radio) %s: %s", pname, text);
    if(pInfo[playerid][Faction] == 2)
	 //if the player is not in a faction it will not send him any messages
        {
            SendEMSMessage(COLOR_RED, string);//calls a stock below that checks who the /r should be sent to
        }

    }
    return 1;
}
can someone show me how to convert this code so i can put both factions into one radio cmd?

so i dont have to make a new radio cmd for each faction i mean...
Reply
#2

You could do a switch(pInfo[playerid][Faction])
then
case 1: { } // All the police radio code here
case 2: { } // All of the EMS code here.
Reply
#3

Could you show me how that would be written please as i am still learning some of these function and how to use switch

would that be the switch( rbid )?
Reply
#4

PHP код:
CMD:radio(playeridparams[])
{
    if (!
pInfo[playerid][Faction]) return 1;
    if (
isnull(params)) return SendClientMessage(playeridCOLOR_WHITE"SERVER:{FFFFFF} /r(adio) [text]");
    
    new 
string[144], pname[MAX_PLAYER_NAME+1];
    
GetPlayerName(playeridpnamesizeof(pname));
    
    switch (
pInfo[playerid][Faction])
    {
        case 
1:
        {
            new 
rnk_name[][] = {"Chief","Deputy Chief","Squad Commander","Traffic Squad Commander","S.W.A.T Squad Commander","Public Relations Officer","Traffic Officer","S.W.A.T Unit","Senior Officer","Trainee Officer"};
            
format(stringsizeof(string), "(Radio) %s %s: %s", (<= pInfo[playerid][FactionTier] <= 10) ? rnk_name[pInfo[playerid][FactionTier]-1] : ("N/A"), pnameparams);
            
SendCopMessage(COLOR_PDRADstring);
        }
        case 
2:
        {
            
format(stringsizeof(string), "(Radio) %s: %s"pnameparams);
            
SendEMSMessage(COLOR_REDstring);
        }
    }
    return 
1;

Reply
#5

Check this post Here
Reply
#6

Quote:
Originally Posted by Vanter
Посмотреть сообщение
Check this post Here
He already did that, he wants them both in the same command.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)