onplayerenter deny entry -
oblexive - 24.07.2012
Hello everyone, my question is very simple.
How do I make it so when a player tries to enter a restricted vehicle, instead of clearing their animations and making them stop with a message. They instead attempt to open it but its locked to them, but still displaying the message.
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)//click
{
if(!ispassenger)
{
if(IsSkipperVeh(vehicleid) && (PlayerInfo[playerid][pJob] != JOB_SKIPPER && PlayerInfo[playerid][pVIPJob] != JOB_SKIPPER))
{
ClearAnimations(playerid);
SendClientMessage(playerid, COLOR_ORANGE, "You can't access this vehicle.");
}
}
return 1;
}
Re: onplayerenter deny entry -
ViniBorn - 24.07.2012
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)//click
{
if(!ispassenger)
{
if(IsSkipperVeh(vehicleid) && (PlayerInfo[playerid][pJob] != JOB_SKIPPER && PlayerInfo[playerid][pVIPJob] != JOB_SKIPPER))
{
new Float:VBPos[3];
GetPlayerPos(playerid,VBPos[0],VBPos[1],VBPos[2]);
SetPlayerPos(playerid,VBPos[0],VBPos[1],VBPos[2]);
SendClientMessage(playerid, COLOR_ORANGE, "You can't access this vehicle.");
}
}
return 1;
}
Re: onplayerenter deny entry -
EV007 - 24.07.2012
That code is bad, the car is still accessible from a specific point, remove him from the vehicle once his state is changed.
Re: onplayerenter deny entry -
oblexive - 24.07.2012
Hmm, I wanted to test it before I replied but im getting tag mismatch warnings when I compile..
edit: ah okay, i wasnt too sure of it either but im not a pro scripter so i wasnt sure.
If I do that, he would not look like his trying to get in it but in turn fails because he doesnt have the keys.
I mean theres got to be a way to make it so Skippers have the keys to the boats so they can use it where as
if your not, you dont have keys and you cant get in..
Re: onplayerenter deny entry -
EV007 - 24.07.2012
new VBPos[3]; isn't a defined as Float, thats why. Also it can bug your players , use new Float:VBPos[MAX_PLAYERS][3]; and use VBPos[playerid][0] etc.
Re: onplayerenter deny entry -
ViniBorn - 24.07.2012
Quote:
Originally Posted by EV007
new VBPos[3]; isn't a defined as Float, thats why. Also it can bug your players , use new Float:VBPos[MAX_PLAYERS][3]; and use VBPos[playerid][0] etc.
|
Use only new Float:VBPos[3];
[MAX_PLAYERS] isn't necessary
Re: onplayerenter deny entry -
oblexive - 24.07.2012
Yeah I edited my last post.
I basically want it so that the vehicle is locked to someone who doesnt have that particular job.
Re: onplayerenter deny entry -
EV007 - 24.07.2012
if two players access a vehicle at the same time, the result won't be the same.
i.e : I'm in LS and you're in SF, we both enter locked vehicle at the same time,some milisec difference, we can end up getting switched places, i'd be in SF, u in LS or, we both at same spot.
If this was C++, then of course it would work 100 or 99.9999%, but SAMP doesn't read this fast as that language does.
EDIT: You can just use setvehicleparamsforplayer functions, or something like that. It locks the vehicle.
Re: onplayerenter deny entry -
oblexive - 24.07.2012
oh kay sweet EV007, Would you be able to give me a quit example of what I would be trying to do in the way of using that?
Re: onplayerenter deny entry -
ViniBorn - 24.07.2012
Quote:
Originally Posted by EV007
if two players access a vehicle at the same time, the result won't be the same.
i.e : I'm in LS and you're in SF, we both enter locked vehicle at the same time,some milisec difference, we can end up getting switched places, i'd be in SF, u in LS or, we both at same spot.
|
This will not happen ...
Re: onplayerenter deny entry -
EV007 - 24.07.2012
This will happen, it happens MOST of the time when player ping is high , 150+. I have done many tests.
edit:
heres the code I got in my /lock command
pawn Code:
for(new i=0;i<MAX_PLAYERS;i++)
{
if(i != playerid)
{
SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1);
}
}
Re: onplayerenter deny entry -
oblexive - 24.07.2012
Could I just make it onplayerentervehicle, if they are restricted then:
SetVehicleParamsForPlayer(vehicleid,playerid,0,1); ?
Or maybe I can figure out a way to make it so when you become the job it unlocks then, when you quit it locks it..
Re: onplayerenter deny entry -
EV007 - 24.07.2012
The command locks the vehicle for everyone except you. you have to be in the vehicle, if you want to lock the vehicle while its unoccupied, just specify the vehicle id instead of getplayervehicleid
Re: onplayerenter deny entry -
oblexive - 24.07.2012
Couldnt I just use
SetVehicleParamsForPlayer(vehicleid,playerid,0,1);
?
Re: onplayerenter deny entry -
EV007 - 24.07.2012
It will probably lock the vehicle, but the person will still be able to enter it from FIRST time. it won't work afterwards tho.
Re: onplayerenter deny entry -
oblexive - 24.07.2012
hmm i tried it and they could enter it no matter what :/
Is there a way to get around that? To make it function correctly?
Re: onplayerenter deny entry -
EV007 - 24.07.2012
Told you, you can lock vehicles by specifying their correct vehicleid in gamemodeinit maybe, or where ever you have them added.
edit: onvehiclestreamin can work fine too
Re: onplayerenter deny entry -
oblexive - 24.07.2012
is there a certain way i need to do that?