Pilot Chat? Please help!
#1

Hey, I made a topic some hours ago to fix the code because it wouldnt compile...
Now when the code is fixed, it doesn't work.
I can compile, but it doesnt work ingame.
When i type /p This is NWA AirForce wondering if pilot chat works?
It does nothing.
This is what happens after ive typed it: (At the below pic i already had typed it then put it into chat box again for you to see what i typed)

Nothing! Even if i type it again and again and again, nothing! It doesnt even send a empty message!
And i have hydra defined in the loop! (doesnt work for other air vehicles as well)
Heres my code:
Код:
dcmd_p(playerid,params[])
{
  new vehicleid;
  
  for (new i = 0; i < MAX_PLAYERS; i++)
  {
    vehicleid = GetPlayerVehicleID(i);
    if(strlen(params) == 0) return SendClientMessage(playerid, red, "Usage: /p (Text)");
    if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) &&
    GetVehicleModel(vehicleid) == 417 || GetVehicleModel(vehicleid) == 425 || GetVehicleModel(vehicleid) == 447 ||
    GetVehicleModel(vehicleid) == 592 || GetVehicleModel(vehicleid) == 577 || GetVehicleModel(vehicleid) == 511 ||
    GetVehicleModel(vehicleid) == 512 || GetVehicleModel(vehicleid) == 593 || GetVehicleModel(vehicleid) == 520 ||
    GetVehicleModel(vehicleid) == 553 || GetVehicleModel(vehicleid) == 476 || GetVehicleModel(vehicleid) == 519 ||
    GetVehicleModel(vehicleid) == 460 || GetVehicleModel(vehicleid) == 513 || GetVehicleModel(vehicleid) == 548 ||
    GetVehicleModel(vehicleid) == 425 || GetVehicleModel(vehicleid) == 417 || GetVehicleModel(vehicleid) == 487 ||
    GetVehicleModel(vehicleid) == 488 || GetVehicleModel(vehicleid) == 497 || GetVehicleModel(vehicleid) == 563 ||
    GetVehicleModel(vehicleid) == 447 || GetVehicleModel(vehicleid) == 469)
    {
      new string[128];
      new plName[MAX_PLAYER_NAME];
      GetPlayerName(playerid, plName, sizeof(plName));
      format(string,sizeof(string),"Pilot Chat: %s: %s",plName, params);
      SendClientMessage(i, green, string);
    }
    return 1;
  }
  return 1;
}
Please help me fix this, Peace
Reply
#2

Bump

Please help me with this
I can't figure out what I'm doing wrong...
Reply
#3

Try without loop.
Reply
#4

I need the loop or the message won't be sent to pilots only...
Reply
#5

Heres a more efficient version of your code

As for your bug I assume you added dcmd("p",1, cmdtext); to your OnPlayerCommandText?


pawn Код:
dcmd_p(playerid,params[])
{
  new vehicleid;
  if(strlen(params) == 0) return SendClientMessage(playerid, red, "Usage: /p (Text)");
  for (new i = 0; i < GetMaxPlayers(); i++)
  {
    if(!IsPlayerConnected(i) || !IsPlayerInAnyVehicle(i)) continue;
    vehicleid = GetPlayerVehicleID(i);
    switch(GetVehicleModel(vehicleid))
    {
            case 417 ,425, 447, 592, 577, 511, 512,
            593, 520, 553, 476, 519, 460, 513, 548,
            425, 417, 487, 488, 497, 563, 447, 469:
        {
          new string[128];
          new plName[MAX_PLAYER_NAME];
          GetPlayerName(playerid, plName, sizeof(plName));
          format(string,sizeof(string),"Pilot Chat: %s: %s",plName, params);
          SendClientMessage(i, green, string);
        }
        }
    return 1;
  }
  return 1;
}
Reply
#6

Quote:
Originally Posted by mansonh
Heres a more efficient version of your code

As for your bug I assume you added dcmd("p",1, cmdtext); to your OnPlayerCommandText?


pawn Код:
dcmd_p(playerid,params[])
{
  new vehicleid;
  if(strlen(params) == 0) return SendClientMessage(playerid, red, "Usage: /p (Text)");
  for (new i = 0; i < GetMaxPlayers(); i++)
  {
    if(!IsPlayerConnected(i) || !IsPlayerInAnyVehicle(i)) continue;
    vehicleid = GetPlayerVehicleID(i);
    switch(GetVehicleModel(vehicleid))
    {
            case 417 ,425, 447, 592, 577, 511, 512,
            593, 520, 553, 476, 519, 460, 513, 548,
            425, 417, 487, 488, 497, 563, 447, 469:
        {
          new string[128];
          new plName[MAX_PLAYER_NAME];
          GetPlayerName(playerid, plName, sizeof(plName));
          format(string,sizeof(string),"Pilot Chat: %s: %s",plName, params);
          SendClientMessage(i, green, string);
        }
        }
    return 1;
  }
  return 1;
}
I already had that at OnPlayerCommandText...
But the script worked
Thanks a lot
Reply
#7

np. Just figured out what was wrong with your original script:

IsPlayerConnected(i) && IsPlayerInAnyVehicle(i) &&
GetVehicleModel(vehicleid) == 417

would only be true for vehicle 417.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)