[HELP]Timer Bug
#1

Hi,

So i made a script for my RPG/DM server, the script is working fine, but the timer buggs a little.
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new playerState;
    playerState = GetPlayerState(playerid);
    if(Shipment == 1)
    {
        if(playerState == 2)
        {
            if(Full != 100)
            {
                    new string[128];
                TextDrawShowForPlayer(playerid,Textdraw1[playerid]);
                filling = SetTimer("Filling", 5000, true);
                format(string, 64, "~w~Filling: ~g~~h~%d~w~%.",Full);
                TextDrawSetString(Textdraw1[playerid], string);
            }
            else if(Full == 100)
            {
                return 1;
            }
        }
        else
        {
            return 1;
        }
    }
    else
    {
        SendClientMessage(playerid,COLOR_YELLOW,"The Ship didn't bring the cargo yet!");
        RemovePlayerFromVehicle(playerid);
    }
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    TextDrawHideForPlayer(playerid,Textdraw1[playerid]);
    KillTimer(punjenje);
    return 1;
}

public Filling(playerid)
{
    new string[128];
    if(Full == 98)
    {
        Full = 100;
        SendClientMessage(playerid, COLOR_YELLOW, "The truck is full, now hit to the Headquarters!");
        TextDrawHideForPlayer(playerid,Textdraw1[playerid]);
        KillTimer(filling);
        SetPlayerCheckpoint(playerid,2217.5591,-1165.9092,25.7266,7.0);
    }
    else
    {
        Full += 2;
        format(string, 64, "~w~Filling: ~g~~h~%d~w~%.", Full);
        TextDrawSetString(Textdraw1[playerid], string);
    }
    return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
    if(Full == 100 && IsPlayerInRangeOfPoint(playerid,7.0,2217.5591,-1165.9092,25.7266))
    {
        DisablePlayerCheckpoint(playerid);
        SendClientMessage(playerid,COLOR_GREEN,"You have successfully delivered the cargo to your Headquarters!");
        Shipment = 0;
        shipment = SetTimer("Shipment",1800000,false); // so half hour
    }
    return 1;
}
Now, the 'Filling:%d' is doing well untill it comes to 50, then it jumps every 5 seconds over 6 or 8 percent(so adding percentage very fast).
That's the bug.... Anyone knows whats the problem?

Tnx.

EDIT: Oh, and yes i forwarded the functions, no errors no warnings.
Reply
#2

Well, first of all you're calling the timer with:
pawn Код:
SetTimer("Filling", 5000, true);
But your function requires playerid parameter.
Код:
 Filling(playerid)
You should use SetTimerEx instead to pass the playerid parameter.
Reply
#3

Try using
Код:
SetTimerEx("Filling", 5000, true, "i", playerid);
Reply
#4

thanks it helped, but have a new problem with this same script...
how to check if the player entered a vehicle?
i tried:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(GetVehicleModel(498))
    {
        //script...
    }
    return 1;
}
this doesn't trigger the script another solutions to check it? and the timer should start only when the player is in the vehicle, not when entering, because when you hit enter and hold forward the timer starts, but you aren't in the vehicle...

help plz!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)