Script help
#1

When I Play Gta offline i saw a rocket shoot when Plane or helicopter pass in LV Army can you help me with this cript ( active it with command) If possible canyou help me with the Plane,Helicopter chat system ( people in helicopter or plane can chat togethere) tks very much sorry i'm bad at Eng
Reply
#2

so you are asking us to make a chat for pilots ?
Reply
#3

Quote:
Originally Posted by Sands
Посмотреть сообщение
so you are asking us to make a chat for pilots ?
yes can you help me with this
Reply
#4

pawn Код:
CMD:pchat (playerid, params [])
{
    new msg[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    if(IsPlayerInAnyVehicle(playerid) && GetPlayerVehicleID(playerid) == 417 || 425 || 447 || 460 || 469 || 476 || 487 ||488 || 489 || 511 || 512 || 513 ||519 || 520 || 548 || 553 || 563 || 577 || 592 || 593)
    {
        if (isnull (params)) return SendClientMessage(playerid, -1, "Usage: /pchat [msg]");
        else
        {
             for(new i = 0; i<MAX_PLAYERS; i++)
            {
                 if( GetPlayerVehicleID(i) == 417 || 425 || 447 || 460 || 469 || 476 || 487 ||488 || 489 || 511 || 512 || 513 ||519 || 520 || 548 || 553 || 563 || 577 || 592 || 593)
                {
                    format(msg, sizeof(msg), "Pilot %s : %s", name, params)
                    SendClientMessage(i, -1, msg);
                }
            }
        }
    }
    else {SendClientMessage(playerid, -1 , "You Need to be in a air vehicle to use Pilot's chat"); }
    return 1;
}
i prefer u to add #pragma tabsize 0 on top of the script and below includes to prevent loose indention warning.
Im using ZCMD here.
Add this script anywhere and not inside any callback and place the script below main()
Reply
#5

Sure, Easy. I'll write the code and explain it:

pawn Код:
CMD:airchat(playerid, params[]) // airchat is the name of the command, you can change it to whatever you want.
{
new text[126]; // text is a string variable
if(sscanf2(params, "s", text)) return SendClientMessage(playerid, COLOR, "Usage: /airchat [text]"); // if the player didn't enter the string parameter (text) then you will send him a message showing him how to use the command
if(pInfo[playerid][pilot] == 0 || pInfo[playerid][helicopter] == 0) // Your enum could be different, from mine. I used pInfo though.
return SendClientMessage(playerid, COLOR, "You need to be a pilot/helicopter to use this radio!"); // If he's not a pilot, then he can't use the radio
else
{ // He will now be able to use the radio
new pilotname[MAX_PLAYER_NAME], pilotrank[25], msg[144]; // pilotname is the name of the player using the radio, pilotrank is the rank of the pilot. { According to your rank system }, msg[144] is the mesage that will be sent to all players.
format(msg, sizeof(msg), "[RADIO] %s %s : %s", pilotrank, GetPlayerName(playerid, pilotname, sizeof(pilotname)), text);
SendClientMessageToAir(COLOR, msg); // Send The Message ONLY to Air Units, which we will define.
}
return 1; // When returning 1, it prevents the server from sending "Unknown Message"
}

// Now, we need to define SendClientMessageToAir, which will Send Message ONLY to pilots/Helicopters.
forward SendClientMessageToAir(COLOR, text[144]); // Forward the function. Learn more here --> https://sampwiki.blast.hk/wiki/Public_functions
public SendClientMessageToAir(COLOR, text[144]) // Name of the function
{
new i; // integer Variable, which will be used as the player IDs
for(i = 0; i < MAX_PLAYERS; i++) // i = 0 at first, begging to check from player ID 0 until the Last player (MAX_PLAYERS)
{
if(IsPlayerConnected(i)) // Checks if the player is connected.
{
if(pInfo[i][pilot] !=0 || pInfo[i][helicopter] != 0) // Checks if the player is an air unit (helicopter or pilot) --> AGAIN! Use your own enum, it could be different from the one I'm using.
{
SendClientMessage(i, COLOR, text); // Send Every Person who is a pilot this message
}
}
}
return 1;
}
Hope that helps! --> Ask me if you have any questions.
+rep if it did
Reply
#6

Ur code doesn't need sscanf, mine has no error msg's but i will edit it :P
Reply
#7

Quote:
Originally Posted by newbie scripter
Посмотреть сообщение
pawn Код:
CMD:pchat (playerid, params [])
{
    new msg[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    if(IsPlayerInAnyVehicle(playerid) && GetPlayerVehicleID(playerid) == 417 || 425 || 447 || 460 || 469 || 476 || 487 ||488 || 489 || 511 || 512 || 513 ||519 || 520 || 548 || 553 || 563 || 577 || 592 || 593)
    {
        if (isnull (params)) return SendClientMessage(playerid, -1, "Usage: /pchat [msg]");
        else
        {
             for(new i = 0; i<MAX_PLAYERS; i++)
            {
                 if( GetPlayerVehicleID(i) == 417 || 425 || 447 || 460 || 469 || 476 || 487 ||488 || 489 || 511 || 512 || 513 ||519 || 520 || 548 || 553 || 563 || 577 || 592 || 593)
                {
                    format(msg, sizeof(msg), "Pilot %s : %s", name, params)
                    SendClientMessage(i, -1, msg);
                }
            }
        }
    }
    else {SendClientMessage(playerid, -1 , "You Need to be in a air vehicle to use Pilot's chat"); }
    return 1;
}
i prefer u to add #pragma tabsize 0 on top of the script and below includes to prevent loose indention warning.
Im using ZCMD here.
Add this script anywhere and not inside any callback and place the script below main()
Quote:
Originally Posted by newbie scripter
Посмотреть сообщение
pawn Код:
CMD:pchat (playerid, params [])
{
    new msg[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    if(IsPlayerInAnyVehicle(playerid) && GetPlayerVehicleID(playerid) == 417 || 425 || 447 || 460 || 469 || 476 || 487 ||488 || 489 || 511 || 512 || 513 ||519 || 520 || 548 || 553 || 563 || 577 || 592 || 593)
    {
        if (isnull (params)) return SendClientMessage(playerid, -1, "Usage: /pchat [msg]");
        else
        {
             for(new i = 0; i<MAX_PLAYERS; i++)
            {
                 if( GetPlayerVehicleID(i) == 417 || 425 || 447 || 460 || 469 || 476 || 487 ||488 || 489 || 511 || 512 || 513 ||519 || 520 || 548 || 553 || 563 || 577 || 592 || 593)
                {
                    format(msg, sizeof(msg), "Pilot %s : %s", name, params)
                    SendClientMessage(i, -1, msg);
                }
            }
        }
    }
    else {SendClientMessage(playerid, -1 , "You Need to be in a air vehicle to use Pilot's chat"); }
    return 1;
}
i prefer u to add #pragma tabsize 0 on top of the script and below includes to prevent loose indention warning.
Im using ZCMD here.
Add this script anywhere and not inside any callback and place the script below main()
Quote:
Originally Posted by Elie1996
Посмотреть сообщение
Sure, Easy. I'll write the code and explain it:

pawn Код:
CMD:airchat(playerid, params[]) // airchat is the name of the command, you can change it to whatever you want.
{
new text[126]; // text is a string variable
if(sscanf2(params, "s", text)) return SendClientMessage(playerid, COLOR, "Usage: /airchat [text]"); // if the player didn't enter the string parameter (text) then you will send him a message showing him how to use the command
if(pInfo[playerid][pilot] == 0 || pInfo[playerid][helicopter] == 0) // Your enum could be different, from mine. I used pInfo though.
return SendClientMessage(playerid, COLOR, "You need to be a pilot/helicopter to use this radio!"); // If he's not a pilot, then he can't use the radio
else
{ // He will now be able to use the radio
new pilotname[MAX_PLAYER_NAME], pilotrank[25], msg[144]; // pilotname is the name of the player using the radio, pilotrank is the rank of the pilot. { According to your rank system }, msg[144] is the mesage that will be sent to all players.
format(msg, sizeof(msg), "[RADIO] %s %s : %s", pilotrank, GetPlayerName(playerid, pilotname, sizeof(pilotname)), text);
SendClientMessageToAir(COLOR, msg); // Send The Message ONLY to Air Units, which we will define.
}
return 1; // When returning 1, it prevents the server from sending "Unknown Message"
}

// Now, we need to define SendClientMessageToAir, which will Send Message ONLY to pilots/Helicopters.
forward SendClientMessageToAir(COLOR, text[144]); // Forward the function. Learn more here --> https://sampwiki.blast.hk/wiki/Public_functions
public SendClientMessageToAir(COLOR, text[144]) // Name of the function
{
new i; // integer Variable, which will be used as the player IDs
for(i = 0; i < MAX_PLAYERS; i++) // i = 0 at first, begging to check from player ID 0 until the Last player (MAX_PLAYERS)
{
if(IsPlayerConnected(i)) // Checks if the player is connected.
{
if(pInfo[i][pilot] !=0 || pInfo[i][helicopter] != 0) // Checks if the player is an air unit (helicopter or pilot) --> AGAIN! Use your own enum, it could be different from the one I'm using.
{
SendClientMessage(i, COLOR, text); // Send Every Person who is a pilot this message
}
}
}
return 1;
}
Hope that helps! --> Ask me if you have any questions.
+rep if it did
Thank for two script can you also help me with the rocket too
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)