Pin Code Car
#1

Hey guys... how can I put a pin code on a car when someone enters it?
And if they enter the wrong pin, it will remove them?
Can someone please help me with this?

Example: I enter someone elses car and I am not authorized to enter it, if I enter the wrong pin or press 'Exit' I get removed from the vehicle, if I enter the pin correctly, I can then start driving the car.
Reply
#2

Try this

pawn Код:
//place this at the VERY top - With your other defines.
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_LIGHTGREEN 0x9ACD32AA
#define COLOR_LIGHTRED 0xFF6347AA


//at the top of your script, with the rest of your declarations
new PinCode[MAX_VEHICLES];
for(new v=0; v<MAX_VEHICLES; v++)
{
    PinCode[v] = 9999
}
new bool:IsPlayerAuthenticating[MAX_PLAYERS];
for(new i=0; i<MAX_PLAYERS; i++)
{
    IsPlayerAuthenticating[i] = false;
}

//inside your command for setting a pincode
new veh = GetPlayerVehicleID(playerid);
PinCode[veh] = //pincode variable here


//place this in OnPlayerEnterVehicle
new veh = GetPlayerVehicleID(playerid);
if(PinCode[veh] == 9999)
{
    TogglePlayerControllable(playerid, 0);
    IsPlayerAuthenticating[playerid] = true;
    SendClientMessage(playerid, COLOR_GREY, "Please enter the correct pincode.");
}

//place this in OnPlayerText
new tmp[256];
new idx;
if(IsPlayerAuthenticating[playerid] == true)
{
    new GivenCode;
    new veh = GetPlayerVehicleID(playerid);
    tmp = strtok(text, idx);
    GivenCode = strval(tmp);
    if(GivenCode == PinCode[veh])
    {
        TogglePlayerControllable(playerid, 1);
        SendClientMessage(playerid, COLOR_LIGHTRED, "You have entered the correct code." );
        IsPlayerAuthenticating[playerid] = false;
        return 1;
    }
    else
    {
        SendClientMessage(playerid, COLOR_LIGHTGREEN,"You have entered an incorrect code. Access Denied.");
        RemovePlayerFromVehicle(playerid);
        IsPlayerAuthenticating[playerid] = false;
        return 1;
    }
   
}

//untested, Rob
Reply
#3

I liked your code, but I only want to use it for one type of vehicle. In this case... the vehicle is called 'threshcar'

So with the GetPlayerVehicle, I only want it to pick up if they are in my car, or inside 'threshcar'.
Reply
#4

Ahh ok.
Well you need to define what car ID 'threshcar' is.
How do you create 'threshcar'?
Is it script-based? or is it created some other way (ig, through a fs)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)