[Help] Lock player into vehicle
#1

Hello, i want to know how to lock player into vehicle when he types command.
i tried
Код:
TogglePlayerControllable
but player can still exit vehicle.
And i also need system that locks car from outside also, so nobody can drag player out of car.
Reply
#2

PHP код:
public OnPlayerExitVehicle(playeridvehicleid)
{
    if(
VARIABLE[playerid] == 1)
    {
        
SendClientMessage(playerid0xFF0000FF"You can not leave the vehicle.");
        
PutPlayerInVehicle(playeridvehicleidGetPlayerVehicleSeat(playerid));
    }
    return 
1;

Reply
#3

I don't understand what is
pawn Код:
if(VARIABLE[playerid] == 1)
but my system is like this

when player types command like /hotwire he has case 1: to start engine and case 2: to start alarm and lock player into vehicle for 10 seconds and then doors unlock and he can leave car.
Reply
#4

Still need help :/
(really sorry for bump but i need help )
Reply
#5

Write on the top of your script:
pawn Код:
new VARIABLE[MAX_PLAYERS];
when they write /hotwire add:

VARIABLE[playerid] = 1;

and then if(variable[playerid] ==1)
then his code

and if they sucsess hotwire then VARIABLE[playerid] = 0;
Reply
#6

Change the 'VARIABLE' with your set variable. Whether it's stored in an enum or what-ever, simply replace it.

Example, in your enum you have lets say 'pLocked', it would then be:

pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(pLocked[playerid] == 1)
    {
        SendClientMessage(playerid, 0xFF0000FF, "You can not leave the vehicle.");
        PutPlayerInVehicle(playerid, vehicleid, GetPlayerVehicleSeat(playerid));
    }
    return 1;
}
Reply
#7

can i use this plz like so if i just copy this code and paste it in pawn and complie and then put it in my server.cfg and it would work if i type /plocked (ID)

Код:
public OnPlayerExitVehicle(playerid, vehicleid){    if(pLocked[playerid] == 1)    {        SendClientMessage(playerid, 0xFF0000FF, "You can not leave the vehicle.");        PutPlayerInVehicle(playerid, vehicleid, GetPlayerVehicleSeat(playerid));    }    return 1;}
like this code exacly the same way just paste and play will it work ??
Reply
#8

No, it won't work unless you make a command which locks and unlocks and changes the variable, if you do that then it might work, but you even don't know what to do or how to do so that would be hard for you, I guess.
Reply
#9

i tried with and without return 1; --- This way it compiles but it won't do anything
pawn Код:
if(Lukus[playerid] == 1)
    {
        SendClientMessage(playerid, 0xFF0000FF, "Auto uksed on lukus.");
        PutPlayerInVehicle(playerid, vehicleid, GetPlayerVehicleSeat(playerid));
    }
This way i get 17 errors..
pawn Код:
if(Lukus[playerid] == 1)
    {
        SendClientMessage(playerid, 0xFF0000FF, "Auto uksed on lukus.");
        PutPlayerInVehicle(playerid, vehicleid, GetPlayerVehicleSeat(playerid));
    }
    return 1;
}
And this should set Lukus[playerid] = 1;
pawn Код:
case 9,10,11,12,13,14,15:
                        {
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, "Alarm kдivitus ja sa jдid autosse kinni!");
                            gEngine[playerid] = 0;
                            SetTimerEx("AutoAlarm", 10000, false, "i", playerid);
                            Lukus[playerid] = 1;
                        }
And this one should set Lukus[playerid] = 0;
pawn Код:
public AutoAlarm(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        Lukus[playerid] = 0;
        SendClientMessage(playerid, TEAM_AZTECAS_COLOR, "Alarm jдi vait ja uksed avanesid imekombel!");
    }
}
Reply
#10

i have another option;

i tried it once under OnPlayerKeyStateChange

if a player has a variable ..such as being a prisoner and he presses the key to enter/exit vehicle
it sends you a message that you cant exit the vehicle.
It worked but im not sure if its needed to put the player back in the vehicle if he tries to get out.

Its worth a try i guess..have fun
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)