SA-MP Forums Archive
Stop people from using hydra/hunter/rhino when outside a dm - 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: Stop people from using hydra/hunter/rhino when outside a dm (/showthread.php?tid=111643)



Stop people from using hydra/hunter/rhino when outside a dm - chaosnz - 03.12.2009

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?


Re: Stop people from using hydra/hunter/rhino when outside a dm - Skaty - 03.12.2009

Show me the code that sets the DMZone values.


Re: Stop people from using hydra/hunter/rhino when outside a dm - chaosnz - 03.12.2009

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;




Re: Stop people from using hydra/hunter/rhino when outside a dm - Outbreak - 03.12.2009

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




Re: Stop people from using hydra/hunter/rhino when outside a dm - Deat_Itself - 03.12.2009

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;


Re: Stop people from using hydra/hunter/rhino when outside a dm - chaosnz - 03.12.2009

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.



Re: Stop people from using hydra/hunter/rhino when outside a dm - Deat_Itself - 03.12.2009

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 ?


Re: Stop people from using hydra/hunter/rhino when outside a dm - chaosnz - 03.12.2009

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..


Re: Stop people from using hydra/hunter/rhino when outside a dm - EirikhO - 03.12.2009

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.


Re: Stop people from using hydra/hunter/rhino when outside a dm - dice7 - 03.12.2009

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)



Re: Stop people from using hydra/hunter/rhino when outside a dm - Outbreak - 03.12.2009

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




Re: Stop people from using hydra/hunter/rhino when outside a dm - Grim_ - 03.12.2009

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