Stop people from using hydra/hunter/rhino when outside a dm
#1

im trying to implement a function to remove players from the Rhino, Hunter or Hydra when theyre not in a DmZone.

Below is the code i have added to OnPlayerEnterVehicle, the script compiles no problem except when i tested it to see if it worked, the script didn't actually remove me from said vehicle.

Quote:

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(GetPlayerVehicleID(vehicleid) == 432)
{
if(DMZone[playerid] == 0)
{
RemovePlayerFromVehicle(playerid);
return 1;
}
}

if(GetPlayerVehicleID(vehicleid) == 425)
{
if(DMZone[playerid] == 0)
{
RemovePlayerFromVehicle(playerid);
return 1;
}
}

if(GetPlayerVehicleID(vehicleid) == 520)
{
if(DMZone[playerid] == 0)
{
RemovePlayerFromVehicle(playerid);
return 1;
}
}

return 1;
}

What am i missing or need to have in my script to get this to work?
Reply
#2

Show me the code that sets the DMZone values.
Reply
#3

Quote:
Originally Posted by Skaty
Show me the code that sets the DMZone values.
Got this at the top of the GM
Quote:

new DMZone[MAX_PLAYERS];

This is in OnPlayerConnect
Quote:

DMZone[playerid] = 0;

When someone joins a dm, it sets this..
Quote:

DMZone[playerid] = 1;

Reply
#4

You can either set the vehicle params so the DM players can enter the vehicle but others can't (vehicle locked).

Or use the code you already have but place it in OnPlayerStateChange instead.

You'll need to check newstate == PLAYER_STATE_DRIVER

then check the vehicle model, and if the player ain't in DM you can remove them from the vehicle.

OnPlayerEnterVehicle is called the moment the player hits F or Enter, so the removal from the vehicle at that time is impossible since their state is PLAYER_STATE_ONFOOT

Reply
#5

put DMzone[playerid] = 0; in onplayerconnect

and for eg if you prepare a command /joindm
so add these lines to it DMzone[playerid] = 1;

and when player /leavedm
so add this lines to it DMzone[playerid] = 0;
Reply
#6

Quote:
Originally Posted by _Saif_
put DMzone[playerid] = 0; in onplayerconnect

and for eg if you prepare a command /joindm
so add these lines to it DMzone[playerid] = 1;

and when player /leavedm
so add this lines to it DMzone[playerid] = 0;
i already have a leave dm command.
Reply
#7

Quote:
Originally Posted by chaosnz
Quote:
Originally Posted by _Saif_
put DMzone[playerid] = 0; in onplayerconnect

and for eg if you prepare a command /joindm
so add these lines to it DMzone[playerid] = 1;

and when player /leavedm
so add this lines to it DMzone[playerid] = 0;
i already have a leave dm command.
did u added DMzone[playerid] = 0; in onplayerconnect ?
Reply
#8

Quote:
Originally Posted by _Saif_
Quote:
Originally Posted by chaosnz
Quote:
Originally Posted by _Saif_
put DMzone[playerid] = 0; in onplayerconnect

and for eg if you prepare a command /joindm
so add these lines to it DMzone[playerid] = 1;

and when player /leavedm
so add this lines to it DMzone[playerid] = 0;
i already have a leave dm command.
did u added DMzone[playerid] = 0; in onplayerconnect ?
look at the 3rd post... I said i had DMzone[playerid] = 0; on onplayerconnect..
Reply
#9

How about SetPlayerHealth(playerid,0.0); at OnPlayerEnterVehicle

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
  if((GetPlayerVehicleID(vehicleid) == 432)||(GetPlayerVehicleID(vehicleid) == 425)||(GetPlayerVehicleID(vehicleid) == 520)
  {
     if(DMZone[playerid] == 0)
     {
      SetPlayerHealth(playerid,0.0);
      SendClientMessage(playerid,0xFFFFFFAA,"SERVER: You cannot enter this vehicle while not in the /dm zone.");
      return 1;
   }
  }


  return 1;
}
A bit noobish, but it will do what it should, and after a couple if kills the player should have understood to stay away.
Reply
#10

Why the hell are you trying to get a vehicleid FROM a vehicleid ?
And 432, 425 and 520 are vehicle models, not IDs
https://sampwiki.blast.hk/wiki/GetVehicleModel
pawn Код:
if(GetPlayerVehicleID(vehicleid) == 432)
Reply
#11

Quote:
Originally Posted by Outbreak
You can either set the vehicle params so the DM players can enter the vehicle but others can't (vehicle locked).

Or use the code you already have but place it in OnPlayerStateChange instead.

You'll need to check newstate == PLAYER_STATE_DRIVER

then check the vehicle model, and if the player ain't in DM you can remove them from the vehicle.

OnPlayerEnterVehicle is called the moment the player hits F or Enter, so the removal from the vehicle at that time is impossible since their state is PLAYER_STATE_ONFOOT

Reply
#12

pawn Код:
if(GetVehicleModel(vehicleid) == XX)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)