Time Functions Help for REP +
#3

Quote:
Originally Posted by clarencecuzz
Посмотреть сообщение
pawn Код:
new HasAttemptedToLoadPackagesRecently[MAX_PLAYERS]; //Under Includes - Global

public OnGameModeInit() //Or FilterScriptInit() if you're using a FilterScript
{
    SetTimer("Check", 1000, true);
    return 1;
}

//LOADPACKAGES COMMAND HERE
{
//Add other code here
if(HasAttemptedToLoadPackagesRecently[playerid] > 0)
return SendClientMessage(playerid, 0xFF0000AA, "You must wait 30 minutes before attempting to load packages again.");

//When player loads the packages
HasAttemptedToLoadPackagesRecently[playerid] = 1800000;
}

forward Check();
public Check()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(HasAttemptedToLoadPackagesRecently[i] >= 1)
            {
                HasAttemptedToLoadPackagesRecently[i] --;
            }
        }
    }
    return ;
}
EDIT: Can't do it fully unless you can supply me with your LoadPackages command.
I tried setting it to 60000 milliseconds (1 minute) but the timer doesn't refresh. Here's what I have so far:

pawn Код:
new PackageLoading[MAX_PLAYERS]; // Beginning of mode with other 'new' variables

SetTimer("Check", 1000, true); // I added this under another SetTimer under OnGameModeInIt

CMD:loadpackages(playerid, params[]) // This is my /loadpackages command, everything is fine here.
{
    new string[128], packages;
    // L1: 0 | L2: 100 | L3: 300 | L4: 700 | L5: 1200
    if(PlayerInfo[playerid][pJobSkill][JOB_TRUCKER] < 100) packages = 5; //If under level 2
    else if(PlayerInfo[playerid][pJobSkill][JOB_TRUCKER] < 300) packages = 10; //If under level 3
    else if(PlayerInfo[playerid][pJobSkill][JOB_TRUCKER] < 700) packages = 15; //If under level 4
    else if(PlayerInfo[playerid][pJobSkill][JOB_TRUCKER] < 1200) packages = 20; //If under level 5
    else if(PlayerInfo[playerid][pJobSkill][JOB_TRUCKER] >= 1200) packages = 25; //If equals to or over level 5
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first before using this command.");
    if(PlayerInfo[playerid][pJob] != JOB_TRUCKER && PlayerInfo[playerid][pVIPJob] != JOB_TRUCKER) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not a Trucker.");
    if(!IsPlayerInAnyVehicle(playerid) || !IsTruckerVehicle(GetPlayerVehicleID(playerid)) || !IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not in a Trucker vehicle or you have no trailer attached.");
    if(!IsPlayerInRangeOfPoint(playerid, 5, -1037.3890,-629.9038,32.0078)) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not near a packages pickup.");
    if(PlayerInfo[playerid][pMoney] < packages*3) return SendClientMessage(playerid, COLOR_LIGHTRED, "You don't have any cash on you.");
    if(PackageLoading[playerid] > 0)
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "You need to wait for upto 30 minutes before loading more packages.");
        return 1;
    }
    PlayerInfo[playerid][pTPackages] ++;
    GiveZaiatMoney(playerid, -(packages*3));
    PlayerInfo[playerid][pDeliverTruck] = GetPlayerVehicleID(playerid);
    TruckPackages[GetPlayerVehicleID(playerid)] = playerid;
    format(string, sizeof(string), "%s has loaded %d product packages from the pickup into the truck.", RPN(playerid), packages);
    SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    format(string, sizeof(string), "You have loaded {FF6347}%d product{33CCFF} packages for {FF6347}$%d{33CCFF}, deliver them to the drop off. (Checkpoint)", packages, packages*5);
    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
    if(PlayerInfo[playerid][pTPackages] >= 1)
    {
        PackageLoading[playerid] = 60000;
    }
    SetPlayerCheckpoint(playerid, 2488.9246,-2080.2800,13.5469, 2);
    return 1;
}

// Then..

forward Check(); // I have this under where it checks if pay check is done
public Check()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(PackageLoading[i] >= 1)
            {
                PackageLoading[i] --;
            }
        }
    }
    return ;
}
I haven't tested it yet for whether the timer stays set for when a player restarts or the game mode resdtarts, but I also need it for if the timer is on like 30 seconds left, I want it to pause until the player re connects and the timer carries on from where it left off.
Reply


Messages In This Thread
Time Functions Help for REP + - by WinterAce - 12.07.2012, 13:12
Re: Time Functions Help for REP + - by clarencecuzz - 12.07.2012, 13:19
Re: Time Functions Help for REP + - by WinterAce - 12.07.2012, 14:35
Re: Time Functions Help for REP + - by clarencecuzz - 12.07.2012, 14:58
Re: Time Functions Help for REP + - by WinterAce - 12.07.2012, 15:23

Forum Jump:


Users browsing this thread: 1 Guest(s)