Anti Team Jack
#1

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
Reply
#2

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.
Reply
#3

Can u explain in more code and detail plz?
Reply
#4

First, search around. This question was answered many times.
Reply
#5

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
Reply
#6

Where is this code? Under what callback?
Reply
#7

Sorry, forgot to add that bit:

Its under OnPlayerStateChange
Reply
#8

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;
}
Reply
#9

Thnx!

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)