Send a message to all players with the same skin
#1

Hi, i would like a system in my airline server so that pilots can send messages to each other.

I would like any person with skinid 61 to have the command /radio Text - this message is then set to all of the other players who have skin ID 61.

If you can create the code for me, i will be very grateful.

Thanks again.
Reply
#2

PHP код:
if(!strcmp(cmdtext"/radio"true))
{
    if(
IsPlayerConnected(playerid))
    {
        if(!(
GetPlayerSkin(playerid) == 61))
            return 
SendClientMessage(playerid, -1"You are not a pilot !");
        
#if !defined string
            
new string[128];
        
#endif
        #if !defined pName
            
new pName[MAX_PLAYER_NAME];
        
#endif
        
GetPlayerName(playeridpNameMAX_PLAYER_NAME);
        
format(string128"[Pilot %s]: %s"pNamecmdtext[6]);
        for(new 
0MAX_PLAYERSi++)
            if(
GetPlayerSkin(i) == 61// this checks IsPlayerConnected too
                
SendClientMessage(i0xFF000000string);
    }
    return 
1;

Reply
#3

Thanks for the code. When i type /radio - it says [pilot]

but when i type /radio Hello - it says unknown command. Do you know how to fix this?
Reply
#4

Wait few seconds.
Reply
#5

Okay, i changed 'cmdtext' to 'cmd' and it no longer says unknown command. When i type /radio message. it just sends the message: [Pilot] without the message.

Thanks for your help
Reply
#6

Hey, check this out:
PHP код:
if(!strcmp(cmdtext"/radio"true))
{
    if(
IsPlayerConnected(playerid))
    {
        if(!
cmdtext[6])
            return 
SendClientMessage(playerid, -1"USAGE: /radio [text]");
        
        
enum A_P_Info
        
{
            
A_P_Name[30],
            
A_P_ID
        
}
        
        static const 
Airplanes[][A_P_Info] =
        {
            {
"Andromada"592}, {"AT-400"577}, {"Beagle"511}, {"Cropduster"512},
            {
"Dodo"593}, {"Hydra"520}, {"Nevada"553}, {"Rustle"476},
            {
"Shamal"519}, {"Skimmer"460}, {"Stuntplane"513}, {"Cargobob"548},
            {
"Hunter"425}, {"Leviathan"417}, {"Maverick"487}, {"News Maverick"488},
            {
"Police Maverick"497}, {"Raindance"563}, {"Seasparrow"447}, {"Sparrow"469}
        };
    
        if(!(
GetPlayerSkin(playerid) == 61))
            return 
SendClientMessage(playerid, -1"You are not a pilot !");
        
#if !defined string
            
new string[128];
        
#endif
        #if !defined pName
            
new pName[MAX_PLAYER_NAME];
        
#endif
        
new Airplane_name[30], vehidmodelbool:check false;
        
vehid GetPlayerVehicleID(playerid);
        
model GetVehicleModel(vehid);
        
        for(new 
0sizeof(Airplanes); ji++)
            if(
model == Airplanes[i][A_P_ID])
            {
                
format(Airplane_name30"%s"Airplanes[i][A_P_Name]);
                
check true;
                break;
            }
            
        if(!
check)
            return 
SendClientMessage(playerid, -1"[ERROR]: You are not in a airplane or in a helicopter !");
        
GetPlayerName(playeridpNameMAX_PLAYER_NAME);
        
format(string128"[Pilot %s - from %s]: %s"pNameAirplane_namecmdtext[7]);
        for(new 
0MAX_PLAYERSi++)
            if(
GetPlayerSkin(i) == 61)
                
SendClientMessage(i0xFF000000string);
    }
    return 
1;

Reply
#7

1. Disconnected player cant type commands
2.
pawn Код:
if(!strcmp(cmdtext, "/radio", true, 6))
3.
pawn Код:
if(!strcmp(cmdtext, "/radio", true, 6))
{
    if(!(GetPlayerSkin(playerid) == 61))
        return SendClientMessage(playerid, -1, "You are not a pilot !");
       
    if(!cmdtext[7])
        return SendClientMessage(playerid, -1, "USAGE: /radio [text]");
       
    #if !defined string
        new string[128];
    #endif
    #if !defined pName
        new pName[MAX_PLAYER_NAME];
    #endif

    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    format(string, sizeof(string), "[Pilot %s]: %s", pName, cmdtext[7]);
    for(new i,g=GetMaxPlayers(); i < g; i++)
        if(GetPlayerSkin(i) == 61) // this checks IsPlayerConnected too
            SendClientMessage(i, 0xFF000000, string);
    return 1;
}
Reply
#8

Quote:
Originally Posted by Jefff
Посмотреть сообщение
1. Disconnected player cant type commands
2.
pawn Код:
if(!strcmp(cmdtext, "/radio", true, 6))
3.
pawn Код:
if(!strcmp(cmdtext, "/radio", true, 6))
{
    if(!(GetPlayerSkin(playerid) == 61))
        return SendClientMessage(playerid, -1, "You are not a pilot !");
       
    if(!cmdtext[7])
        return SendClientMessage(playerid, -1, "USAGE: /radio [text]");
       
    #if !defined string
        new string[128];
    #endif
    #if !defined pName
        new pName[MAX_PLAYER_NAME];
    #endif

    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    format(string, sizeof(string), "[Pilot %s]: %s", pName, cmdtext[7]);
    for(new i,g=GetMaxPlayers(); i < g; i++)
        if(GetPlayerSkin(i) == 61) // this checks IsPlayerConnected too
            SendClientMessage(i, 0xFF000000, string);
    return 1;
}
You wrong. This:
pawn Код:
if(!cmdtext[7])
        return SendClientMessage(playerid, -1, "USAGE: /radio [text]");
must be:
pawn Код:
if(!cmdtext[6])
        return SendClientMessage(playerid, -1, "USAGE: /radio [text]");
Reply
#9

No it mustn't, because that would mean it accepts:
"/radio ", when you want it to send the message if they send "/radio "
Reply
#10

WOW! The script from MoroDan did not work. But i took the script from Jefff and then added the extra Airplane_name Function. It now works great!

Thanks everyone for your wonderful help!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)