SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 18/02/2019, 02:31 AM   #11
Kasichok
Little Clucker
 
Kasichok's Avatar
 
Join Date: Sep 2018
Location: weed farm
Posts: 41
Reputation: 12
Default Re: How can i restrict players from entering a specific vehicle?

GetPlayerVehicleID is same as playerid just for vehicles and GetVehicleModel is same as GetPlayerSkin just for vehicles

if you want only the admins to use skin_id 299 which function would you use?

PHP Code:
if(GetPlayerSkin(playerid) == playerid
or

PHP Code:
if(GetPlayerSkin(playerid) == 299
__________________



STRESSED? TRY KASICHOK AND RELAX


Kasichok is offline   Reply With Quote
Old 18/02/2019, 02:36 AM   #12
ConnorW
Huge Clucker
 
ConnorW's Avatar
 
Join Date: Apr 2012
Location: Los Santos
Posts: 224
Reputation: 71
Default Re: How can i restrict players from entering a specific vehicle?

It's basically the same..
__________________
retired
ConnorW is offline   Reply With Quote
Old 18/02/2019, 05:19 AM   #13
Kane_
Gangsta
 
Kane_'s Avatar
 
Join Date: Sep 2012
Posts: 840
Reputation: 120
Default Re: How can i restrict players from entering a specific vehicle?

You don't need to use state change, OnPlayerEnterVehicle is fine.

Simply get their position and set it to current.

pawn Code:
new Float:PosX,
    Float:PosY;
    Float:PosZ;

GetPlayerPos(playerid, PosX, PosY, PosZ);

SetPlayerPos(playerid, PosX, PosY, PosZ);

You could still do it in OnPlayerStateChange aswell for an anti-cheat measure if you'd like.
__________________
Los Santos Roleplay - Development team
@ls-rp.io
Kane_ is online now   Reply With Quote
Old 18/02/2019, 06:22 AM   #14
BigETI
High-roller
 
BigETI's Avatar
 
Join Date: Mar 2010
Location: Germany
Posts: 1,067
Reputation: 357
Default Re: How can i restrict players from entering a specific vehicle?

"OnPlayerEnterVehicle" is called when a player attempts to enter a vehicle. It doesn't mean that the player is already inside the vehicle. However "OnPlayerEnterVehicle" is not called, if a player ports into a vehicle by calling "PutPlayerInVehicle" or with cheats. The definitive answer to restrict vehicle access is actually to use "OnPlayerStateChange" and also "SetVehicleParamsForPlayer" just for a better user experience. I feel the entire thread just makes my brain loose cells while reading.
__________________

BigETI is online now   Reply With Quote
Old 18/02/2019, 06:27 AM   #15
[HLF]Southclaw
Godfather
 
[HLF]Southclaw's Avatar
 
Join Date: Apr 2009
Location: England
Posts: 5,020
Reputation: 1598
Default Re: How can i restrict players from entering a specific vehicle?

Simply lock the vehicle for that specific player. https://wiki.sa-mp.com/wiki/SetVehicleParamsForPlayer
__________________
Tools:

Plugins:

Links:

[HLF]Southclaw is offline   Reply With Quote
Old 18/02/2019, 07:58 PM   #16
alexjanjaj
Little Clucker
 
Join Date: May 2015
Posts: 17
Reputation: 0
Default Re: How can i restrict players from entering a specific vehicle?

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
alexjanjaj is offline   Reply With Quote
Old 18/02/2019, 08:32 PM   #17
TheToretto
Gangsta
 
TheToretto's Avatar
 
Join Date: Jul 2015
Posts: 515
Reputation: 52
Default Re: How can i restrict players from entering a specific vehicle?

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
Quote:
Originally Posted by [HLF]Southclaw View Post
Simply lock the vehicle for that specific player. https://wiki.sa-mp.com/wiki/SetVehicleParamsForPlayer
This combined with OnPlayerEnterVehicle or I'd rather use OnVehicleStreamIn for that, if you're not planning to change constantly the user's VIP level, else it would have some issues returning false positives. Then basically you're going to check if the player is vip, if so do nothing, else execute the code :

Code:
SetVehicleParamsForPlayer(vehicleid, playerid,0,1);
__________________






Toretto#9902

Rest in peace grandpa, 03 November 2018
TheToretto is offline   Reply With Quote
Old 18/02/2019, 08:40 PM   #18
Kasichok
Little Clucker
 
Kasichok's Avatar
 
Join Date: Sep 2018
Location: weed farm
Posts: 41
Reputation: 12
Default Re: How can i restrict players from entering a specific vehicle?

PHP Code:
public OnPlayerStateChange(playeridnewstateoldstate)
{
    if(
GetVehicleModel(GetPlayerVehicleID(playerid)) == 520 && User[playerid][accountVIP] == 0)
    {
        if(
newstate == || newstate == 2)
        {
            
ClearAnimations(playerid);
            
SendClientMessage(playerid, -1"I'm sorry, but this car has been reserved for Admins only!");
        }
    }
    return 
1;

__________________



STRESSED? TRY KASICHOK AND RELAX


Kasichok is offline   Reply With Quote
Old 18/02/2019, 08:55 PM   #19
ConnorW
Huge Clucker
 
ConnorW's Avatar
 
Join Date: Apr 2012
Location: Los Santos
Posts: 224
Reputation: 71
Default Re: How can i restrict players from entering a specific vehicle?

Quote:
Originally Posted by Kasichok View Post
PHP Code:
public OnPlayerStateChange(playeridnewstateoldstate)
{
    if(
User[playerid][accountVIP] == 0) return 1;
    if(
GetVehicleModel(GetPlayerVehicleID(playerid)) == 520)
    {
        if(
newstate == || newstate == 2)
        {
            
ClearAnimations(playerid);
            
SendClientMessage(playerid, -1"I'm sorry, but this car has been reserved for Admins only!");
        }
    }
    return 
1;

yea sure
pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(User[playerid][accountVIP] == 0) return 1;
__________________
retired
ConnorW is offline   Reply With Quote
Old 18/02/2019, 09:03 PM   #20
Kasichok
Little Clucker
 
Kasichok's Avatar
 
Join Date: Sep 2018
Location: weed farm
Posts: 41
Reputation: 12
Default Re: How can i restrict players from entering a specific vehicle?

Quote:
Originally Posted by ConnorW View Post
yea sure
pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(User[playerid][accountVIP] == 0) return 1;
fixed.
__________________



STRESSED? TRY KASICHOK AND RELAX


Kasichok is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Restrict Siren(object) to specific cars, +rep DemME Scripting Help 3 20/06/2016 01:12 AM
Players goes out of sync when entering vehicle jeffery30162 Scripting Help 16 09/02/2015 08:09 PM
Restrict from spawning as team without specific score. Eminem 2ka9 Scripting Help 3 28/03/2013 10:56 PM
Restrict anyone from spawning as specific team without 2000 score. Eminem 2ka9 Scripting Help 5 28/03/2013 12:54 AM
Players may temporarily spawn a random weapon while entering a vehicle BigETI Bug Reports 15 17/07/2012 08:00 PM


All times are GMT. The time now is 07:53 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.