SA-MP Forums Archive
I saw someone asked for this!! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: I saw someone asked for this!! (/showthread.php?tid=255804)



I saw someone asked for this!! - Cjgogo - 17.05.2011

I don't remeber exactly whoa sked for this but I know someone asked for an arresting command for a button so here it is:

pawn Код:
if(newkeys == KEY_LOOK_BEHIND)
    {
      if(gTeam[playerid] == TEAM_COPS)
      {
        new p1;
        new p2;
        GetDistanceBetweenPlayers(p1,p2);
        if(GetDistanceBetweenPlayers(p1,p2) > 5) return SendClientMessage(p1,COLOR_WHITE,"Nobody is close enough");
        if(GetDistanceBetweenPlayers(p1,p2) < 5)
        {
          GetPlayerWantedLevel(p2);
          if(GetPlayerWantedLevel(p2) == 0) return SendClientMessage(p1,COLOR_WHITE,"The player is not wanted");
          if(GetPlayerWantedLevel(p2) > 0)
          {
            TogglePlayerControllable(p2,0);
            SendClientMessageToAll(COLOR_GREEN,"Officer %s has arrested %s");
            GivePlayerMoney(p1,1000);
          }
        }
      }
      if(gTeam[playerid] == TEAM_ROBBERS || gTeam[playerid] == TEAM_MEDICS || gTeam == TEAM_FIREFIGHTERS) return SendClientMessage(playerid,COLOR_RED,"This command is only for a cop");
    }
There are no errors when compiling,of course you set your colors and Teams,but the only thing I forgot is how to define the "%s" when it says Officer %s has arrested %s I want copname,wantedname.


Re: I saw someone asked for this!! - Seven_of_Nine - 17.05.2011

What is line 11? xD


Re: I saw someone asked for this!! - Cjgogo - 17.05.2011

wait a moment I know how to make that,and what do you mean sven?


Re: I saw someone asked for this!! - Cjgogo - 17.05.2011

ok here it is:

pawn Код:
if(gTeam[playerid] == TEAM_COPS)
      {
        new p1;
        new p2;
        GetDistanceBetweenPlayers(p1,p2);
        if(GetDistanceBetweenPlayers(p1,p2) > 5) return SendClientMessage(p1,COLOR_WHITE,"Nobody is close enough");
        if(GetDistanceBetweenPlayers(p1,p2) < 5)
        {
          GetPlayerWantedLevel(p2);
          if(GetPlayerWantedLevel(p2) == 0) return SendClientMessage(p1,COLOR_WHITE,"The player is not wanted");
          if(GetPlayerWantedLevel(p2) > 0)
          {
            TogglePlayerControllable(p2,0);
            new copname[24];
            new wantedname[24];
            new string[128];
            format(string,sizeof(string),"Officer %s has arrested %s",copname,wantedname);
            SendClientMessageToAll(COLOR_GREEN,string);
            GivePlayerMoney(p1,1000);
          }
        }
      }
      if(gTeam[playerid] == TEAM_ROBBERS || gTeam[playerid] == TEAM_MEDICS || gTeam == TEAM_FIREFIGHTERS) return SendClientMessage(playerid,COLOR_RED,"This command is only for a cop");
    }
OK,for the moment I can test it,so if someone could test it for me it would be nice.(LOL SVEN LINE 11 in gamemodes is empty :P)

SOMEONE TRY IT FOR ME!!(please)


Re: I saw someone asked for this!! - xir - 17.05.2011

You only defined the names? You need to GetThePlayer name aswell


Re: I saw someone asked for this!! - Cjgogo - 17.05.2011

What a noob am I,thanks xir,now here's the re-re-writed command:

pawn Код:
if(newkeys == KEY_LOOK_BEHIND)
    {
      if(gTeam[playerid] == TEAM_COPS)
      {
        new p1;
        new p2;
        GetDistanceBetweenPlayers(p1,p2);
        if(GetDistanceBetweenPlayers(p1,p2) > 5) return SendClientMessage(p1,COLOR_WHITE,"Nobody is close enough");
        if(GetDistanceBetweenPlayers(p1,p2) < 5)
        {
          GetPlayerWantedLevel(p2);
          if(GetPlayerWantedLevel(p2) == 0) return SendClientMessage(p1,COLOR_WHITE,"The player is not wanted");
          if(GetPlayerWantedLevel(p2) > 0)
          {
            TogglePlayerControllable(p2,0);
            new copname[24];
            new wantedname[24];
            GetPlayerName(p1,copname,sizeof(copname));
            GetPlayerName(p2,wantedname,sizeof(wantedname));
            new string[128];
            format(string,sizeof(string),"Officer %s has arrested %s",copname,wantedname);
            SendClientMessageToAll(COLOR_GREEN,string);
            GivePlayerMoney(p1,1000);
          }
        }
      }
      if(gTeam[playerid] == TEAM_ROBBERS || gTeam[playerid] == TEAM_MEDICS || gTeam[playerid] == TEAM_FIREFIGHTERS) return SendClientMessage(playerid,COLOR_RED,"This command is only for a cop");
    }
If someone could make time to test it for me,it woudl be nice,if no,just take a look at the script and do this,please:

Workage rate = ?% where ? is your opinion,but if you can and have time test it for me.


Re: I saw someone asked for this!! - Seven_of_Nine - 17.05.2011

Quote:
Originally Posted by Cjgogo
Посмотреть сообщение
What a noob am I,thanks xir,now here's the re-re-writed command:
pawn Код:
GetDistanceBetweenPlayers(p1,p2);
    GetPlayerWantedLevel(p2);
WTF are these lines? You don't really need them. Only if they like:
pawn Код:
new distane,wanted;
distance = GetDistanceBetweenPlayers(p1,p2);
wanted = GetPlayerWantedLevel(p2);
Because what you wrote down is useless. It returns a value for nothing.

I wouldn't like to rewrite this code, especially if it works without those lines - good luck.