DCMD+OnPlayerKeyStateChange+Cop cars
#1

Hey All!
I have a problem. I have this code:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
    {
    new vehicleid = GetPlayerVehicleID(playerid);
    if ((newkeys==KEY_SUBMISSION)&&(IsPlayerInAnyVehicle(playerid))&&(GetPlayerState(playerid)==PLAYER_STATE_DRIVER))
      {
      if (GetVehicleModel(vehicleid) == 405 && IsCIA(playerid) && IsPolice(playerid) && IsFBI(playerid) && IsArmy(playerid) || GetVehicleModel(vehicleid) == 421 && IsCIA(playerid) && IsPolice(playerid) && IsFBI(playerid) && IsArmy(playerid) || GetVehicleModel(vehicleid) == 490 && IsCIA(playerid) && IsPolice(playerid) && IsFBI(playerid) && IsArmy(playerid)) // CIA VEHICLES
        {
        if (GetVehicleModel(vehicleid) == 497 && IsCIA(playerid) && IsPolice(playerid) && IsFBI(playerid) && IsArmy(playerid) || GetVehicleModel(vehicleid) == 523 && IsCIA(playerid) && IsPolice(playerid) && IsFBI(playerid) && IsArmy(playerid) || GetVehicleModel(vehicleid) == 528 && IsCIA(playerid) && IsPolice(playerid) && IsFBI(playerid) && IsArmy(playerid))
        {
        if (GetVehicleModel(vehicleid) == 598 && IsCIA(playerid) && IsPolice(playerid) && IsFBI(playerid) && IsArmy(playerid) || GetVehicleModel(vehicleid) == 596 && IsCIA(playerid) && IsPolice(playerid) && IsFBI(playerid) && IsArmy(playerid) || GetVehicleModel(vehicleid) == 597 && IsCIA(playerid) && IsPolice(playerid) && IsFBI(playerid) && IsArmy(playerid))
        {
        for(new i=0; i<MAX_PLAYERS; i++)
        {
        if(GetDistanceBetweenPlayers(playerid, i) < 6 && i != playerid) //Distance of 5 in-game meters
        {
    dcmd_arrest(playerid, IntToStr(i));
    return dcmd_ticket(playerid, IntToStr(i));
    }
    }
    }
        }
        }
    return SendClientMessage(playerid, RED, "Nincs elйg kцzel jбtйkos.");
    }
    return 1;
    }
But its not works fine because when I'm a cop and I'm not in cop car the button works... I want the 2 button works for only cops and in cop cars.
Another problem:
When a player near to me and the player has wanted level i can't give ticket or i can't arrest him when im a cop and im in cop car. It says: No player close enogh.
Whats wrong?
Here is my dcmd_arrest and dcmd_ticket code:
pawn Код:
dcmd_arrest(playerid, params[])
{
  new targetid = strval(params);
  if (!Player[playerid][HasSpawnedYet])
    {
      SendClientMessage(playerid, RED, "Nem tudod hasznбlni ezt a parancsot, ha halott vagy.");
        return 1;
    }
    if(!IsPolice(playerid) && !IsFBI(playerid) && !IsArmy(playerid) && !IsCIA(playerid))
    {
        format(myString, sizeof(myString), "Csak a rendőrцk tudnak letartуztatni embereket. Hasznбld a /107 parancsot, hogy hнvd a rendőrцket.");
        SendClientMessage(playerid, RED, myString);
      return 1;
  }
  if (GetPlayerWantedLevel(playerid) > 0)
  {
        SendClientMessage(playerid, RED, "Nem tudsz letartуztatni embereket, ha kцrцzйsed van.");
      return 1;
  }
  if(strlen(params) == 0)
  {
      for(new i=0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if(GetPlayerWantedLevel(i) > 3)
                {
                    if(GetPlayerState(i) == 1 && ArePlayersInSameCar(playerid, i))
                    {
                      if(IsPlayerNearPlayer(12, playerid, i))
                      {
                          GetPlayerName(i, targetName, sizeof(targetName));
                          GetPlayerName(playerid, playerName, sizeof(playerName));

                            format(myString, sizeof(myString), "%s (%i) jбtйkost letartуztatta %s (%i) rendőr!", targetName, i, playerName, playerid);
                            SendClientMessageToAll(ANNOUNCEMENT, myString);

                            if(GetPlayerWantedLevel(i) == 6)
                            {
                                GivePlayerMoney(playerid, 5000);
                                format(myString, sizeof(myString), "Letartуztattad %s (%i) jбtйkost! Jutalmad: $5000", targetName, i);
                                SendClientMessage(playerid, GREEN, myString);
                                format(myString, sizeof(myString), "~b~%s letartoztatva", targetName);
                                GameTextForPlayer(playerid,myString,3000,4);

                                format(myString, sizeof(myString), "Letartуztattak! Bьntetйsed: 3 perc bцrtцn йs $10000 pйnzbьntetйs.");
                                SendClientMessage(i, ORANGE, myString);
                                GivePlayerMoney(i, -10000);
                                SetPlayerInterior(i, 3);
                                SetPlayerPos(i, 198.0301, 161.8855, 1003.0234);
                            Player[i][JailTime] = 180000;
                                ResetPlayerWeapons(i);
                            }
                            if(GetPlayerWantedLevel(i) == 5)
                            {
                                GivePlayerMoney(playerid, 5000);
                                format(myString, sizeof(myString), "Letartуztattad %s (%i) jбtйkost! Jutalmad: $5000", targetName, i);
                                SendClientMessage(playerid, GREEN, myString);

                                format(myString, sizeof(myString), "Letartуztattak! Bьntetйsed: 2 perc bцrtцn йs $5000 pйnzbьntetйs.");
                                SendClientMessage(i, ORANGE, myString);
                                GivePlayerMoney(i, -5000);
                                SetPlayerInterior(i, 3);
                                SetPlayerPos(i, 193.8692, 174.4870, 1003.0234);
                                Player[i][JailTime] = 120000;
                                ResetPlayerWeapons(i);
                            }
                            if(GetPlayerWantedLevel(i) == 4)
                            {
                                GivePlayerMoney(playerid, 5000);
                                format(myString, sizeof(myString), "Letartуztattad %s (%i) jбtйkost! Jutalmad: $5000", targetName, i);
                                SendClientMessage(playerid, GREEN, myString);

                                format(myString, sizeof(myString), "Letartуztattak! Bьntetйsed: 1 perc bцrtцn йs $2500 pйnzbьntetйs.");
                                SendClientMessage(i, ORANGE, myString);
                                GivePlayerMoney(i, -2500);
                                SetPlayerInterior(i, 3);
                                SetPlayerPos(i, 198.0729, 174.4870, 1003.0234);
                                Player[i][JailTime] = 60000;
                                ResetPlayerWeapons(i);
                            }
                            TogglePlayerControllable(i, 1);
                            dUserSetINT(PlayerName(playerid)).("TimesArrested",dUserINT(PlayerName(playerid)).("TimesArrested") + 1);
                            dUserSetINT(PlayerName(i)).("TimesBeenArrested",dUserINT(PlayerName(i)).("TimesBeenArrested") + 1);
                            ChangePlayerWantedLevel(i, 0);
                            Player[i][JailCounter] = SetTimerEx("ReleasePlayerFromJail", 1000, false, "i", i);
                            oscore = GetPlayerScore(playerid);
                            SetPlayerScore(playerid, oscore +1);
                            oscore = GetPlayerScore(playerid);
                            SetPlayerScore(playerid, oscore -1);
                            return 1;
                        }
                    }
                }
            }
        }
        format(myString, sizeof(myString), "Nincs kцrцzцtt jбtйkos elйg kцzel.");
        SendClientMessage(playerid, RED, myString);
      return 1;
  }

  GetPlayerName(playerid, playerName, sizeof(playerName));
  GetPlayerName(targetid, targetName, sizeof(targetName));

  if(!IsPlayerConnected(targetid))
    {
      format(myString, sizeof(myString), "%i egy йrvйnytelen jбtйkos.", targetid);
      SendClientMessage(playerid, RED, myString);
        return 1;
    }
    if(GetPlayerWantedLevel(targetid) < 4)
    {
      format(myString, sizeof(myString), "%s (%i) jбtйkosnak nincs elйg nagy kцrцzйse. Hasznбld a /tk parancsot!", targetName, targetid);
      SendClientMessage(playerid, RED, myString);
      return 1;
    }
    if(GetPlayerState(targetid) != 1 && !ArePlayersInSameCar(playerid, targetid))
    {
      format(myString, sizeof(myString), "%s (%i) egy jбrműben van, ezйrt nem tudod letartуztatni.", targetName, targetid);
      SendClientMessage(playerid, RED, myString);
      return 1;
    }
  if(!IsPlayerNearPlayer(12, playerid, targetid))
  {
    format(myString, sizeof(myString), "%s (%i) tъl messze van.", targetName, targetid);
      SendClientMessage(playerid, RED, myString);
      return 1;
  }

    format(myString, sizeof(myString), "%s (%i) jбtйkost letartуztatta %s (%i) rendőr!", targetName, targetid, playerName, playerid);
    SendClientMessageToAll(ANNOUNCEMENT, myString);
  if(strlen(params) == 0)
  {
  for(new i=0; i < MAX_PLAYERS; i++)
    {
    if(IsPlayerConnected(i))
    {
    if(GetPlayerWantedLevel(targetid) == 6)
    {
        GivePlayerMoney(playerid, 5000);
        format(myString, sizeof(myString), "Letartуztattad %s (%i) jбtйkost! Jutalmad: $5000", targetName, i);
        SendClientMessage(playerid, GREEN, myString);

        format(myString, sizeof(myString), "Letartуztattak! Bьntetйsed: 3 perc bцrtцn йs $10000 pйnzbьntetйs.");
        SendClientMessage(targetid, ORANGE, myString);
        GivePlayerMoney(targetid, -10000);
        SetPlayerInterior(targetid, 3);
        SetPlayerPos(targetid, 198.0301, 161.8855, 1003.0234);
    Player[targetid][JailTime] = 180000;
        ResetPlayerWeapons(targetid);
    }
    if(GetPlayerWantedLevel(targetid) == 5)
    {
        GivePlayerMoney(playerid, 5000);
        format(myString, sizeof(myString), "Letartуztattad %s (%i) jбtйkost! Jutalmad: $5000", targetName, i);
        SendClientMessage(playerid, GREEN, myString);

        format(myString, sizeof(myString), "Letartуztattak! Bьntetйsed: 2 perc bцrtцn йs $5000 pйnzbьntetйs.");
        SendClientMessage(targetid, ORANGE, myString);
        GivePlayerMoney(targetid, -5000);
        SetPlayerInterior(targetid, 3);
        SetPlayerPos(targetid, 193.8692, 174.4870, 1003.0234);
        Player[targetid][JailTime] = 120000;
        ResetPlayerWeapons(targetid);
    }
    if(GetPlayerWantedLevel(targetid) == 4)
    {
        GivePlayerMoney(playerid, 5000);
        format(myString, sizeof(myString), "Letartуztattad %s (%i) jбtйkost! Jutalmad: $5000", targetName, i);
        SendClientMessage(playerid, GREEN, myString);

        format(myString, sizeof(myString), "Letartуztattak! Bьntetйsed: 1 perc bцrtцn йs $2500 pйnzbьntetйs.");
        SendClientMessage(targetid, ORANGE, myString);
        GivePlayerMoney(targetid, -2500);
        SetPlayerInterior(targetid, 3);
        SetPlayerPos(targetid, 198.0729, 174.4870, 1003.0234);
        Player[targetid][JailTime] = 60000;
        ResetPlayerWeapons(targetid);
    }
    }
    }
    }
    TogglePlayerControllable(targetid, 1);
    dUserSetINT(PlayerName(playerid)).("TimesArrested",dUserINT(PlayerName(playerid)).("TimesArrested") + 1);
    dUserSetINT(PlayerName(targetid)).("TimesBeenArrested",dUserINT(PlayerName(targetid)).("TimesBeenArrested") + 1);
    ChangePlayerWantedLevel(targetid, 0);
    Player[targetid][JailCounter] = SetTimerEx("ReleasePlayerFromJail", 1000, false, "i", targetid);
    return 1;
}
pawn Код:
dcmd_ticket(playerid, params[])
{
  new targetid = strval(params);
  if (!Player[playerid][HasSpawnedYet])
    {
      SendClientMessage(playerid, RED, "Nem tudod hasznбlni ezt a parancsot, ha halott vagy.");
        return 1;
    }
  if(strlen(params) == 0)
  {
        if (!IsPolice(playerid) && !IsFBI(playerid) && !IsArmy(playerid) && !IsCIA(playerid))
        {
            format(myString, sizeof(myString), "Csak a rendőrцk tudnak bьntetйst kiszabni embereknek. Hasznбld a /107 parancsot, hogy hнvd a rendőrцket.");
            SendClientMessage(playerid, RED, myString);
          return 1;
      }
      if (GetPlayerWantedLevel(playerid) > 0)
      {
            SendClientMessage(playerid, RED, "Nem tudsz bьntetйst kiszabni embereknek, ha kцrцzйsed van.");
          return 1;
      }
      for(new i=0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if(GetPlayerWantedLevel(i) < 4 && i > playerid || GetPlayerWantedLevel(i) < 4 && i < playerid)
                {
                  if(IsPlayerNearPlayer(12, playerid, i))
                  {
                    GetPlayerName(playerid, playerName, sizeof(playerName));
                        GetPlayerName(i, targetName, sizeof(targetName));

                        if(GetPlayerWantedLevel(i) == 3)
                        {
                            GivePlayerMoney(playerid, 1000);
                            format(myString, sizeof(myString), "Kiszabtбl bьntetйst %s (%i) jбtйkosnak. Bьntetйse: $1000. Jutalmad: $1000", targetName, i);
                            SendClientMessage(playerid, GREEN, myString);

                            format(myString, sizeof(myString), "Megbьntetett tйged %s (%i) rendőr. Bьntetйs: $1000", playerName, playerid);
                            SendClientMessage(i, YELLOW, myString);
                            GivePlayerMoney(i, -1000);
                        }

                        if(GetPlayerWantedLevel(i) == 2)
                        {
                            GivePlayerMoney(playerid, 1000);
                            format(myString, sizeof(myString), "Kiszabtбl bьntetйst %s (%i) jбtйkosnak. Bьntetйse: $500. Jutalmad: $1000", targetName, i);
                            SendClientMessage(playerid, GREEN, myString);

                            format(myString, sizeof(myString), "Megbьntetett tйged %s (%i) rendőr. Bьntetйs: $500", playerName, playerid);
                            SendClientMessage(i, YELLOW, myString);
                            GivePlayerMoney(i, -500);
                        }

                        if(GetPlayerWantedLevel(i) == 1)
                        {
                            GivePlayerMoney(playerid, 1000);
                            format(myString, sizeof(myString), "Kiszabtбl bьntetйst %s (%i) jбtйkosnak. Bьntetйse: $250. Jutalmad: $1000", targetName, i);
                            SendClientMessage(playerid, GREEN, myString);

                            format(myString, sizeof(myString), "Megbьntetett tйged %s (%i) rendőr. Bьntetйs: $250", playerName, playerid);
                            SendClientMessage(i, YELLOW, myString);
                            GivePlayerMoney(i, -250);
                        }
            dUserSetINT(PlayerName(playerid)).("TimesTicketed",dUserINT(PlayerName(playerid)).("TimesTicketed") + 1);
                        dUserSetINT(PlayerName(i)).("TimesBeenTicketed",dUserINT(PlayerName(i)).("TimesBeenTicketed") + 1);
                        ChangePlayerWantedLevel(i, 0);
                        return 1;
                    }
                }
            }
        }
        format(myString, sizeof(myString), "Nincs elйg kцzel bьntethető jбtйkos.");
        SendClientMessage(playerid, RED, myString);
      return 1;
    }

    GetPlayerName(playerid, playerName, sizeof(playerName));
    GetPlayerName(targetid, targetName, sizeof(targetName));

    if(!IsPlayerConnected(targetid))
    {
      format(myString, sizeof(myString), "%i egy йrvйnytelen jбtйkos.", targetid);
      SendClientMessage(playerid, RED, myString);
        return 1;
    }
    if(GetPlayerWantedLevel(targetid) > 3)
    {
      format(myString, sizeof(myString), "%s (%i) jбtйkosnak tъl nagy a kцrцzйse a bьntetйs kiszabбsбhoz. Hasznбld a /ar parancsot!", targetName, targetid);
      SendClientMessage(playerid, RED, myString);
      return 1;
    }
    if(GetPlayerWantedLevel(targetid) == 0)
    {
      format(myString, sizeof(myString), "%s (%i) бrtatlan, nem kell bьntetйst kiszabni neki.", targetName, targetid);
      SendClientMessage(playerid, RED, myString);
      return 1;
    }
  if(!IsPlayerNearPlayer(12, playerid, targetid))
  {
    format(myString, sizeof(myString), "%s (%i) tъl messze van.", targetName, targetid);
      SendClientMessage(playerid, RED, myString);
      return 1;
  }

  if(GetPlayerWantedLevel(targetid) == 3)
    {
        GivePlayerMoney(playerid, 1000);
        format(myString, sizeof(myString), "Kiszabtбl bьntetйst %s (%i) jбtйkosnak. Bьntetйse: $1000. Jutalmad: $1000", targetName, targetid);
        SendClientMessage(playerid, GREEN, myString);

        format(myString, sizeof(myString), "Megbьntetett tйged %s (%i) rendőr. Bьntetйs: $1000", playerName, playerid);
        SendClientMessage(targetid, YELLOW, myString);
        GivePlayerMoney(targetid, -1000);
    }

    if(GetPlayerWantedLevel(targetid) == 2)
    {
        GivePlayerMoney(playerid, 1000);
        format(myString, sizeof(myString), "Kiszabtбl bьntetйst %s (%i) jбtйkosnak. Bьntetйse: $500. Jutalmad: $1000", targetName, targetid);
        SendClientMessage(playerid, GREEN, myString);

        format(myString, sizeof(myString), "Megbьntetett tйged %s (%i) rendőr. Bьntetйs: $500", playerName, playerid);
        SendClientMessage(targetid, YELLOW, myString);
        GivePlayerMoney(targetid, -500);
    }

    if(GetPlayerWantedLevel(targetid) == 1)
    {
        GivePlayerMoney(playerid, 1000);
        format(myString, sizeof(myString), "Kiszabtбl bьntetйst %s (%i) jбtйkosnak. Bьntetйse: $250. Jutalmad: $1000", targetName, targetid);
        SendClientMessage(playerid, GREEN, myString);

        format(myString, sizeof(myString), "Megbьntetett tйged %s (%i) rendőr. Bьntetйs: $250", playerName, playerid);
        SendClientMessage(targetid, YELLOW, myString);
        GivePlayerMoney(targetid, -250);
    }
  dUserSetINT(PlayerName(playerid)).("TimesTicketed",dUserINT(PlayerName(playerid)).("TimesTicketed") + 1);
    dUserSetINT(PlayerName(targetid)).("TimesBeenTicketed",dUserINT(PlayerName(targetid)).("TimesBeenTicketed") + 1);
    ChangePlayerWantedLevel(targetid, 0);
    return 1;
}
Thanks!
Reply
#2

Please help me! It's very important for me
Reply
#3

***BUMP!***
Reply
#4

Please help me!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)