Score per minutes
#4

First of all you'll need to create an IsInTruck function or something, or you can easily rip one.
For this example let us assume that you have this function implented into your script.

First define the timer variable (put this under #include <a_samp>):

pawn Код:
new TruckTimer;
First we'll do OnPlayerStateChange, so that when the player becomes the driver, we'll check if the player is in a truck, then set the timer:

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        if(IsInTruck(playerid))
        {
            TruckTimer = SetTimerEx("HasDriven", 600000, false, "i", playerid);
        }
    }
    return 1;
}
Now we'll check if the player gets out during that timer:

pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(IsInTruck(playerid))
    {
        KillTimer(TruckTimer);
        SendClientMessage(playerid, 0xFF4040FF, "INFO: You haven't been driving long enough to earn points");
    }
}
Now for the HasDriven function itself:

pawn Код:
forward HasDriven(playerid);
public HasDriven(playerid)
{
    if(IsInTruck(playerid))
    {
        SendClientMessage(playerid, 0x33FF33AA, "INFO: You have driven this truck for 30 seconds, 10 points gained.");
        Account[playerid][Points] + 10; // just an example variable, put your own here.
    }  
    return 1;
}
Hope that helps.
If the player earns 10 points, and you want the player to have the ability to earn another 10, change the timer repeating to true:

pawn Код:
TruckTimer = SetTimerEx("HasDriven", 600000, true, "i", playerid);
Reply


Messages In This Thread
Score per minutes - by Puzi - 03.10.2009, 11:15
Re: Score per minutes - by Clank - 03.10.2009, 11:29
Re: Score per minutes - by Puzi - 03.10.2009, 11:46
Re: Score per minutes - by Lewwy - 03.10.2009, 12:07
Re: Score per minutes - by Puzi - 04.10.2009, 10:10
Re: Score per minutes - by MadeMan - 04.10.2009, 10:38
Re: Score per minutes - by Puzi - 04.10.2009, 10:40
Re: Score per minutes - by MadeMan - 04.10.2009, 10:54
Re: Score per minutes - by Puzi - 04.10.2009, 11:01
Re: Score per minutes - by MadeMan - 04.10.2009, 11:04

Forum Jump:


Users browsing this thread: 2 Guest(s)