Other teams can use the megaphone
#1

This is the code i have
pawn Код:
if(text[0] == '!')
{
  //if(!IsPlayerCop(playerid) || IsACopCar(GetPlayerVehicleID(playerid))) return SendClientMessage(playerid, COLOR_RED, "You are not a cop and/or not in a cop car");
  if(IsPlayerCop(playerid) || IsACopCar(GetPlayerVehicleID(playerid)))
    {
    new string[128];  GetPlayerName(playerid, string, sizeof(string));
    format(string, sizeof(string), ">>>Megaphone [%s]: >>%s!!!", string, text[1]);
    printf("%s", string);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    if(IsPlayerConnected(i))
    if(GetDistanceBetweenPlayers(playerid, i) < 7.0)
    {
    SendClientMessage(i, COLOR_YELLOW, string);
    }
    }
    }
    }
return 0;
}
And if im a cop and i say !Test, It says im not a cop and/or not in a car,
So if i get in the car then say it, It works,
But that was when i was testing with 1 team,
Now i have 2, And i spawn as the 2nd team ( Crooks )
And type the !Test on foot,
And it works, It lets that team do the megaphone., But it shouldnt,
same when there in a car,
How to stop that,

If you need more code, Just ask
Reply
#2

First of all:

Is your IsPlayerCop public correct?
pawn Код:
if(IsPlayerCop(playerid) || IsACopCar(GetPlayerVehicleID(playerid)))
This '||' means OR so the player doesn't have to be a cop or being in a car.
Eventually it should look like this (if i'm right):
pawn Код:
if(IsPlayerCop(playerid) && IsPlayerInVehicle(playerid) && IsACopCar(GetPlayerVehicleID(playerid)))
Second,

for sake stop bumping within 12 hours, this makes you look 'special' to others in this community.

edit:
you want it to work without the players has to be in the car?
Reply
#3

I want it so you need to be a cop and need to be in a cop car to use the megaphone

EDIT:

Код:
C:\Program Files\Rockstar Games\GTA San Andreas\sa-mp\gamemodes\gamemode.pwn(188) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
Reply
#4

My mistake:

pawn Код:
if(IsPlayerCop(playerid) && IsPlayerInAnyVehicle(playerid) && IsACopCar(GetPlayerVehicleID(playerid)))
Reply
#5

Now its not working wether im on foot or in a cop car,
While im on cop team
Reply
#6

More explanation needed,

does it say anything like u aren't in the cop team or what?
Reply
#7

No,

If i type !Test it says nothing while on foot
If i type !Test it says nothing while in car

Both trying on cop team and cop car, And crook car, And crook team,
Reply
#8

pawn Код:
if(text[0] == '!')
{
  if(IsPlayerCop(playerid) && IsPlayerInAnyVehicle(playerid) && IsACopCar(GetPlayerVehicleID(playerid))) {
    new string[128];  GetPlayerName(playerid, string, sizeof(string));
    format(string, sizeof(string), ">>>Megaphone [%s]: >>%s!!!", string, text[1]);
    printf("%s", string);
    for(new i = 0; i < MAX_PLAYERS; i++) {
      if(IsPlayerConnected(i))
      print("Player: %d is checked for connected or not",i);
      if(GetDistanceBetweenPlayers(playerid, i) < 7.0) {
        printf("Player: %d is being called and sended a message",i);
        SendClientMessage(i, COLOR_YELLOW, string);
      }
    }
  }
}
return 0;
}
debugged it. tell me the results. + Paste your IsACop public here and what variable are you using to save the players team/faction?
Reply
#9

pawn Код:
public IsACopCar(vehicleid)
{
   if(GetVehicleModel(vehicleid) == 597)
   {
      return 1;
   }
   else return 0;
}

public IsPlayerCop(playerid)
{
   if (gTeam[playerid] == TEAM_POLICELS)
   {
      return 1;
   }
   else return 0;
}
And erm what you mean?
Btw where are my server_log located
Reply
#10

pawn Код:
if(text[0] == '!')
{
  if(!IsPlayerCop(playerid) return SendClientMessage(playerid,color,"You are not a cop");
  if(IsPlayerCop(playerid) && IsPlayerInAnyVehicle(playerid) && IsACopCar(GetPlayerVehicleID(playerid))) {
    new string[128];  GetPlayerName(playerid, string, sizeof(string));
    format(string, sizeof(string), ">>>Megaphone [%s]: >>%s!!!", string, text[1]);
    printf("%s", string);
    for(new i = 0; i < MAX_PLAYERS; i++) {
      if(IsPlayerConnected(i))
      print("Player: %d is checked for connected or not",i);
      if(GetDistanceBetweenPlayers(playerid, i) < 7.0) {
        printf("Player: %d is being called and sended a message",i);
        SendClientMessage(i, COLOR_YELLOW, string);
      }
    }
  }
}
return 0;
}
Go in-game with THIS script, not the one I posted above I edited something, and tell me what it does. Also post the results of the server log here. It's located in your servers' folder.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)