SA-MP Forums Archive
Anti Team Jack - 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)
+--- Thread: Anti Team Jack (/showthread.php?tid=638074)



Anti Team Jack - Sting. - 26.07.2017

Well guys, I need your help on Anti Team jack. Can someone provide me the code to do so? I have set the teams with SetPlayerTeam(playerid, IDs). I just need help now, on making it Anti-Team jack. +REP for those who help with this. My hands are just tied with other things. Thanks in advance.


Re: Anti Team Jack - xMoBi - 26.07.2017

The code will go under OnPlayerEnterVehicle, loop the players, if the team mate in the vehicle is a driver, break the loop and stop him.


Re: Anti Team Jack - Sting. - 26.07.2017

But could you provide the code, that would be big help. Thanks.


Re: Anti Team Jack - StrikerZ - 26.07.2017

PHP код:
stock GetDriverID(vehicleid)
{
    for(new 
0MAX_PLAYERSi++) if(IsPlayerConnected(i)) //Loops through all players
    
{
        if(
GetPlayerVehicleID(i) == vehicleid && GetPlayerState(i) == PLAYER_STATE_DRIVER) return i;
    }
    return 
1;
}
public 
OnPlayerEnterVehicle(playeridvehicleidispassenger)
{
  new 
id GetDriverID(vehicleid);
  if(
IsPlayerInAnyVehicle(id) && !ispassenger && GetPlayerTeam(playerid) == GetPlayerTeam(id))
  {
    
// your code to kick him out
  
}
  return 
1;




Re: Anti Team Jack - Sting. - 26.07.2017

My code to kick him out, was just ClearAnimations(playerid); so that the animation will stop. I placed the stock below my script, compiled it and found no errors. Problem is can't test, how it works fine.


Re: Anti Team Jack - StrikerZ - 26.07.2017

It'll work.


Re: Anti Team Jack - Sting. - 26.07.2017

Alright, +REP to you guys. I will be able to try this weekend, if I find errors, I'll repost here. Thanks to both of ya'll.


Re: Anti Team Jack - R4nd4ll - 26.07.2017

Quote:
Originally Posted by Sting.
Посмотреть сообщение
Alright, +REP to you guys. I will be able to try this weekend, if I find errors, I'll repost here. Thanks to both of ya'll.
I know its a dumb suggestion, But it can add a cool feature to your script.

Add SendClienMessage to it

So it will be :
PHP код:
public OnPlayerEnterVehicle(playeridvehicleidispassenger

  new 
id GetDriverID(vehicleid); 
  if(
IsPlayerInAnyVehicle(id) && !ispassenger && GetPlayerTeam(playerid) == GetPlayerTeam(id)) 
  { 
    
Clearplayeranimation(playerid);
    
Sendclientmessage(PlayeridCOLOR_RED"Don't Ninja Jack your teammates"); //You need to define COLOR_RED to 0xAA3333FF, Or just replace It with another color, Or just put the hex directly
  

  return 
1




Re: Anti Team Jack - Sting. - 26.07.2017

Yea mate, I used GameTextForPlayer instead but thanks. +REP for looking out.


Re: Anti Team Jack - R4nd4ll - 26.07.2017

Quote:
Originally Posted by Sting.
Посмотреть сообщение
Yea mate, I used GameTextForPlayer instead but thanks. +REP for looking out.
Thx, I will +Rep you back.

Btw, You can use both.
They would be awesome together.