Creating System
#1

Hello.
Today i decided to create a Car License System.
What i want to do?
When player enters any car without license, will be ejected.
When player enters a Drive test car, he's have to do test.
And Save system, i will try to make it, i hope some help

Lets try..

Код:
#include <a_samp>
#include <YSI/y_ini>

new examCar1;
new examCar2;
new examCar3;
new examCar4;
new examCar5;

public OnFilterScriptInit()

//Exam Cars

   	examCar1 = AddStaticVehicle(405,2052.531494,-1903.692016,13.243583,1,1,15);
   	examCar2 = AddStaticVehicle(405,2055.949951,-1903.704101,13.243331,1,1,15);
   	examCar3 = AddStaticVehicle(405,2059.206787,-1903.883056,13.243336,1,1,15);
   	examCar4 = AddStaticVehicle(405,2062.361328,-1903.624877,13.243142,1,1,15);
   	examCar5 = AddStaticVehicle(405,2065.629150,-1903.980712,13.243326,1,1,15);

//Information Pickup "i will change x y z, its an example"

pickup = CreatePickup(1242, 2, 1503.3359, 1432.3585, 10.1191, -1);

//When player enter car without lincese.. WARN ME IF I USE WRONG FUNCTION..

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new string[128];
//" CHECK IF PLAYER HAS LICENSE"
    RemovePlayerFromVehicle(playerid);
    return 1;
}
What's next. what i did wrong?
Waiting for your help .
Reply
#2

OnPlayerEnterVehicle:
Quote:

This callback is called when a player starts to enter a vehicle, meaning the player is not in vehicle yet at the time this callback is called.

The player is not in the vehicle so RemovePlayerFromVehicle won't work. Use OnPlayerStateChange instead.
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
    {
        //if player does not have license -> RemovePlayerFromVehicle(playerid);
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
OnPlayerEnterVehicle:

The player is not in the vehicle so RemovePlayerFromVehicle won't work. Use OnPlayerStateChange instead.
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
    {
        //if player does not have license -> RemovePlayerFromVehicle(playerid);
    }
    return 1;
}
Now i need input this somewhere:

if(car == examCar1 || car == examCar2 || car == examCar3 || car == examCar4 || car == examCar5)
Reply
#4

What those vehicles are for? Drive test or just vehicles to see if it works?
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
What those vehicles are for? Drive test or just vehicles to see if it works?
Drive Test Vehicles, to do the exam.
Reply
#6

pawn Код:
public OnPlayerStateChange( playerid, newstate, oldstate )
{
    if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
    {
        new
            veh = GetPlayerVehicleID( playerid )
        ;
        switch( veh )
        {
            case examCar1, examCar2, examCar3, examCar4, examCar5:
            {
                // Force him to do the test
            }
        }
        //if player does not have license -> RemovePlayerFromVehicle(playerid);
    }
    return 1;
}
Reply
#7

Now the code looks like:

pawn Код:
#include <a_samp>
#include <YSI/y_ini>
#include <zcmd>

#define COLOR_GREEN 0x00FF00FF

new examCar1;
new examCar2;
new examCar3;
new examCar4;
new examCar5;
new CP[MAX_PLAYERS];

public OnFilterScriptInit()

//Exam Cars

    examCar1 = AddStaticVehicle(405,2052.531494,-1903.692016,13.243583,1,1,15);
    examCar2 = AddStaticVehicle(405,2055.949951,-1903.704101,13.243331,1,1,15);
    examCar3 = AddStaticVehicle(405,2059.206787,-1903.883056,13.243336,1,1,15);
    examCar4 = AddStaticVehicle(405,2062.361328,-1903.624877,13.243142,1,1,15);
    examCar5 = AddStaticVehicle(405,2065.629150,-1903.980712,13.243326,1,1,15);

//Information Pickup "i will change x y z, its an example"

pickup = CreatePickup(1242, 2, 1503.3359, 1432.3585, 10.1191, -1);

//When player enter car without lincese

public OnPlayerStateChange( playerid, newstate, oldstate )
{
    if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
    {
        new
            veh = GetPlayerVehicleID( playerid )
        ;
        switch( veh )
        {
            case examCar1, examCar2, examCar3, examCar4, examCar5:
            {
    SendClientMessage(playerid, COLOR_GREEN, "Use /exam to start drive test");
            }
        }
        //if player does not have license -> RemovePlayerFromVehicle(playerid);
    }
    return 1;
}

//When player writes /exam in examcars..

CMD:exam(playerid, params[])
{
    if(IsPlayerInVehicle(playerid,examCar1) || IsPlayerInVehicle(playerid,examCar2) || IsPlayerInVehicle(playerid,examCar3) || IsPlayerInVehicle(playerid,examCar4) || IsPlayerInVehicle(playerid,examCar5))
    {
        TogglePlayerControllable(playerid, 1);
        CP[playerid] = 200;
        SetPlayerCheckpoint(playerid, 2073.780029,-1912.620361,13.244957, 4.0);
  SendClientMessage(playerid, COLOR_GREEN, "Be Careful");
    }
    else return SendClientMessage(playerid, COLOR_GREEN,"You not in exam car");
    return 1;
}
Next step i think, to add cp's
Reply
#8

Use this callback: https://sampwiki.blast.hk/wiki/OnPlayerEnterCheckpoint. Once they enter a checkpoint, then you can set their next checkpoint with a different CP ID, and once they get to the last checkpoint, you can give them a drivers license. Understanding how to use OnPlayerEnterCheckpoint would easily increase your knowledge and understanding how to make jobs as well, i.e. trucker jobs to drive to a place.
Reply
#9

Tryed to add some cp's am i wrong ?

pawn Код:
#include <a_samp>
#include <YSI/y_ini>
#include <zcmd>

#define COLOR_GREEN 0x00FF00FF

new examCar1;
new examCar2;
new examCar3;
new examCar4;
new examCar5;
new Ccp[MAX_PLAYERS];

public OnFilterScriptInit()

//Exam Cars

    examCar1 = AddStaticVehicle(405,2052.531494,-1903.692016,13.243583,1,1,15);
    examCar2 = AddStaticVehicle(405,2055.949951,-1903.704101,13.243331,1,1,15);
    examCar3 = AddStaticVehicle(405,2059.206787,-1903.883056,13.243336,1,1,15);
    examCar4 = AddStaticVehicle(405,2062.361328,-1903.624877,13.243142,1,1,15);
    examCar5 = AddStaticVehicle(405,2065.629150,-1903.980712,13.243326,1,1,15);

//Information Pickup "i will change x y z, its an example"

pickup = CreatePickup(1242, 2, 1503.3359, 1432.3585, 10.1191, -1);

//When player enter car without lincese

public OnPlayerStateChange( playerid, newstate, oldstate )
{
    if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
    {
        new
            veh = GetPlayerVehicleID( playerid )
        ;
        switch( veh )
        {
            case examCar1, examCar2, examCar3, examCar4, examCar5:
            {
    SendClientMessage(playerid, COLOR_GREEN, "Use /exam to start drive test");
            }
        }
        //if player does not have license -> RemovePlayerFromVehicle(playerid);
    }
    return 1;
}

//When player writes /exam in examcars..

CMD:exam(playerid, params[])
{
 if(IsPlayerInVehicle(playerid, examCar1) || IsPlayerInVehicle(playerid, examCar2) || IsPlayerInVehicle(playerid,examCar3) || IsPlayerInVehicle(playerid,examCar4) || IsPlayerInVehicle(playerid,examCar5))
    {
        Ccp[playerid] = 1;
        SetPlayerCheckpoint(playerid, 2073.780029,-1912.620361,13.244957, 5.0);
        SendClientMessage(playerid, COLOR_GREEN, "Be careful");
    }
    else return SendClientMessage(playerid, COLOR_GREEN, "You not in exam car");
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    if(Ccp[playerid] == 1)
    {
        DisablePlayerCheckpoint(playerid);
        Ccp[playerid] = 2;
        SetPlayerCheckpoint(playerid, 2079.123291,-1871.586303,13.048537, 5.0);
        return 1;
    }
    if(Ccp[playerid] == 2)
    {
        DisablePlayerCheckpoint(playerid);
        Ccp[playerid] = 3;
        SetPlayerCheckpoint(playerid, 2079.742431,-1802.388427,13.081876, 5.0);
    }
        if(Ccp[playerid] == 3)
    {
        DisablePlayerCheckpoint(playerid);
        Ccp[playerid] = 4;
        SetPlayerCheckpoint(playerid, 2087.171142,-1763.789306,13.093797, 5.0);
    }
    return 1;
}
Reply
#10

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
OnPlayerEnterVehicle:

The player is not in the vehicle so RemovePlayerFromVehicle won't work. Use OnPlayerStateChange instead.
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
    {
        //if player does not have license -> RemovePlayerFromVehicle(playerid);
    }
    return 1;
}
You can use OnPlayerEnterVehicle, just get the player pos and set that to their pos to stop them from entering
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)