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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Anti Team Jack (/showthread.php?tid=106876)



Anti Team Jack - Tigerbeast11 - 06.11.2009

Hi guys! My other post got buggy so I made a new one! And in this post, I have a question for you!

In my server, I have 2 teams (TEAM_AGENTS && TEAM_WOKERS). Is it possible to lock the doors of a car automattically so that when someone frm their own team tries to enter the car, fail...

But I want the car doors to unlock if a player from the other team jacks... Is this possible, and if yes, how?
Plz can someone write the code for me, id be really happy


Re: Anti Team Jack - Correlli - 06.11.2009

Just check for player's team at OnPlayerEnterVehicle-callback and if he's in the team for which you don't want to be able to jack the vehicle then just get his position (GetPlayerPos), store it in the float variables (x, y, z) and then set his position to stored x, y & z.


Re: Anti Team Jack - Tigerbeast11 - 06.11.2009

Can u explain in more code and detail plz?


Re: Anti Team Jack - Correlli - 06.11.2009

First, search around. This question was answered many times.


Re: Anti Team Jack - Tigerbeast11 - 06.11.2009

I did! found this:

pawn Код:
new vehicleid = GetPlayerVehicleID(playerid);
  for(new i; i < GetMaxPlayers(); i++)
  {
    if(IsPlayerConnected(i))
    {
      if(IsPlayerInVehicle(i,vehicleid) && GetPlayerState(i) == PLAYER_STATE_DRIVER && GetPlayerTeam(i) == GetPlayerTeam(playerid))
      {
                SetPlayerHealth(playerid,-9999);
      }
    }
  }
But its buggy and it kills u even if tehre is noone is the car, plz can u help me fix it?


Edit: Here is my other forum... read the last posts

http://forum.sa-mp.com/index.php?topic=1318570


Re: Anti Team Jack - MadeMan - 06.11.2009

Where is this code? Under what callback?


Re: Anti Team Jack - Tigerbeast11 - 06.11.2009

Sorry, forgot to add that bit:

Its under OnPlayerStateChange


Re: Anti Team Jack - Luka P. - 06.11.2009

pawn Код:
public OnPlayerEnterVehicle(playerid,vehicleid,ispassenger)
{
    new veh = GetPlayerVehicleID(playerid);
    new Float:x,Float:y,Float:z = GetPlayerPos(playerid,x,y,z);

    for(new i;i<MAX_PLAYERS<i++;)
    {
        if(IsPlayerInVehicle(i,veh) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
        {
            if(GetPlayerTeam(i) == GetPlayerTeam(playerid))
            {
                SetPlayerPos(playerid,x,y,z+2);                // Slap the player
                SendClientMessage(playerid,COLOR,"Do not jack team vehicle!"); // Sorry for bad English
            }
        }
    }
    return 1;
}



Re: Anti Team Jack - Tigerbeast11 - 06.11.2009

Thnx!

I changed the 2 to 12 so the slap is more effective! Hehe


Re: Anti Team Jack - Luka P. - 06.11.2009

Quote:
Originally Posted by Tigerbeast11
Thnx!

I changed the 2 to 12 so the slap is more effective! Hehe
It works?
BTW, To 12? Nice