How can i restrict players from entering a specific vehicle?
#21

Quote:
Originally Posted by alexjanjaj
View Post
Im trying to restrict every single hydra, how do i lock all hydras ingame and just let them unlocked for VIP Players?
I dont seem to understand it
Why so many complications with this issue?

PHP Code:
//OnPlayerStateChange
if(newstate == PLAYER_STATE_DRIVER

     new 
vehicleid GetPlayerVehicleID(playerid);
     if(
GetVehicleModel(vehicleid) == 520 && User[playerid][accountVIP] <= 0
    { 
        
RemovePlayerFromVehicle(playerid); 
        
SendClientMessage(playerid, -1"If this does not work, then there may be functions that prevent the 
        execution of this.!"
); 
    } 

Remember not to use improper returns on this callback.
Reply
#22

Quote:
Originally Posted by Undef1ned
View Post
Why so many complications with this issue?

PHP Code:
//OnPlayerStateChange
if(newstate == PLAYER_STATE_DRIVER

     new 
vehicleid GetPlayerVehicleID(playerid);
     if(
GetVehicleModel(vehicleid) == 520 && User[playerid][accountVIP] <= 0
    { 
        
RemovePlayerFromVehicle(playerid); 
        
SendClientMessage(playerid, -1"If this does not work, then there may be functions that prevent the 
        execution of this.!"
); 
    } 

Remember not to use improper returns on this callback.
Thank you, managed to make it work.
One last question, is there a way i can lock the vehicle instead of letting the player in the vehicle then kick him out?
Or just cancel the enteronvehicle animation?
Because there is a slight delay that lets the player into the vehicle(hydra) and you can just spam rockets.


Thank you everyone for your replies.
Reply
#23

Hi Alex, in OnPlayerEnterVehicle:
Code:
if(GetVehicleModel(vehicleid) == 520 && User[playerid][accountVIP] <= 0)  
{  
	TogglePlayerControllable(playerid, false);
	TogglePlayerControllable(playerid, true);
	SendClientMessage(playerid, 0xFF0000FF, "[Error] Only VIPs are allowed to use a Hydra."); 
}
No need for anything else.

Edit:
You could additionally add a timer which checks for players in a Hydra, that are not allowed to be in there and slap them out. Lag or desync might let them enter the Hydra in any case. Respawning the Hydra would be efficient in this case too.
Reply
#24

Use gettime instead of a timer, and each attempt increment the variable's count, if it equals to 3 or whatsoever kick the player.
Reply
#25

Don't.
Reply
#26

Quote:
Originally Posted by Jeffry
View Post
Don't.
Explain why not or shut the fuck up
Reply
#27

I don't see the point of kicking players for something they can't even do it's counter intuitive! In fact when we opened 420DayZ we where well aware that health hacks were completely impossible so we didn't care anymore as there was no point of punishing someone for something that does nothing. They would just try something else and eventually do something that does constitute a ban.
Reply
#28

Quote:
Originally Posted by TheToretto
View Post
Explain why not
Because it is pointless to use a counter when attempting to enter, when the player is already inside the Hydra on first try due to desync or because he used a hack to enter it, preventing the counter to count up.
Additionally, for those who can not enter due to the code above, there is no need to kick them after 3 or whatever tries, since they can't enter anyway.

I, additionally, do not see the point of using gettime here.
And finally, I used the posted code in combination with a timer on my server for over 5 years and it worked perfectly. Since Alex was playing on it for quite some time, I'm sure he can confirm this.

So: Just don't.
Reply
#29

Quote:
Originally Posted by Jeffry
View Post
Edit:
You could additionally add a timer which checks for players in a Hydra, that are not allowed to be in there and slap them out. Lag or desync might let them enter the Hydra in any case. Respawning the Hydra would be efficient in this case too.
This will not work. As the players surely have packetloss, the ideal will be locking the vehicles when they stream in.

Quote:
Originally Posted by Jeffry
View Post
Because it is pointless to use a counter when attempting to enter, when the player is already inside the Hydra on first try due to desync or because he used a hack to enter it, preventing the counter to count up.
Additionally, for those who can not enter due to the code above, there is no need to kick them after 3 or whatever tries, since they can't enter anyway.

I, additionally, do not see the point of using gettime here.
And finally, I used the posted code in combination with a timer on my server for over 5 years and it worked perfectly. Since Alex was playing on it for quite some time, I'm sure he can confirm this.

So: Just don't.
Gettime is useless for what you sayed, yes. But not for what the author requested.
Reply
#30

Quote:
Originally Posted by TheToretto
View Post
This will not work. As the players surely have packetloss, the ideal will be locking the vehicles when they stream in.
There are techniques to find out, when a player is desynced and is having packetloss (the same basically) and forcing them to rejoin (automatically) when that happens. For all the others, this will work.

Quote:
Originally Posted by TheToretto
View Post
Gettime is useless for what you sayed, yes. But not for what the author requested.
I gave Alex what he required. I see no point of using gettime here. If you do, explain - as you asked me to explain.

Also, I don't see a point of a discussion here. The solution is as simple as posted, no need for anything else.
Reply
#31

If you want to make your life ez in a long run, don't use Vehicle Models, use vehicleid's. In this case modelid might be good enough, but don't get used to it.

Yes,
You need OnPlayerEnterVehicle;
You need OnPlayerStateChange;
And yes, timer to triple check it; ( or alternatively anti-NOP's system )

You can use NOP'S, member ?... Or, jus't don't use jet's and tanks. Or any other vehicle in the game if you are not willing to put some work in to anti-cheat. Actually, don't create samp server at all, CLEO mod's are horrible these days, i wish we could go back to mod sob days...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)