Timer save glitch/missing lines
#1

Scripted the missing things but still timer aint saving in user file but user file is being updated with info that i have added new timer.What could be the reason that it doesent save in user file after using the cmd?

So this is all what i have:

PHP код:
pFishingTime,
PlayerInfo[playerid][pFishingTime] = 0;
dini_IntSet(file"FishingTime"PlayerInfo[playerid][pFishingTime]);
PlayerInfo[playerid][pFishingTime] = dini_Int(file"FishingTime");
    if(
Fished[playerid] >= 5)
    {
        
Fished[playerid] = 0;
        
FishTime[playerid] = 60*5;
        
SetTimerEx("FishingTime"1000false"i"playerid);
    }
    return 
1;
forward FishingTime(playerid);
public 
FishingTime(playerid)
{
    
FishTime[playerid] --;
    if(
FishTime[playerid] < 0)
    {
        
FishTime[playerid] = 0;
    }
    if(
FishTime[playerid] > 0)
    {
        
SetTimerEx("FishingTime"1000false"i"playerid);
    }
    return 
1;

CMD itself:

PHP код:
CMD:fish(playeridparams[])
{
    new 
string[128], donefish;
       if(!
IsPlayerLoggedIn(playerid)) return SendClientMessage(playeridCOLOR_GREY"You need to login first before using any command.");
    if(!
IsPlayerNearWater(playerid)) return SendClientMessage(playeridCOLOR_GREY"You are not near water to catch fish.(You need to stand in water)");
    if(
FishTime[playerid])
    {
        
format(stringsizeof(string), "You need to wait %d more seconds before fishing again."FishTime[playerid]);
        
SendClientMessage(playeridCOLOR_GREYstring);
        return 
1;
    }
    for(new 
i=0i<5i++) // Fish
    
{
        if(!
done)
        {
            if(!
PlayerInfo[playerid][pFish][i]) done i+1;
        }
    }
    if(!
done) return SendClientMessage(playeridCOLOR_GREY"You can't carry anymore fishes.");
    
done done-1;
    
// Catching
    
if(strval(RPJL(playeridJOB_FISHER)) == 1fish random(25)+1;
    else if(
strval(RPJL(playeridJOB_FISHER)) == 2fish random(26)+5;
    else if(
strval(RPJL(playeridJOB_FISHER)) == 3fish random(31)+10;
    else if(
strval(RPJL(playeridJOB_FISHER)) == 4fish random(36)+15;
    else if(
strval(RPJL(playeridJOB_FISHER)) == 5fish random(41)+25;
    
PlayerInfo[playerid][pFish][done] = fish;
    
format(stringsizeof(string), "* %s attempts to catch a fish using the fishing rod."RPN(playerid));
     
SendNearbyMessage(playerid15stringCOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLECOLOR_PURPLE);
    
format(stringsizeof(string), " You have caught a %d lbs fish."fish);
    
SendClientMessage(playeridCOLOR_LIGHTBLUEstring);
    
// Leveling
    
new oldj strval(RPJL(playeridJOB_FISHER));
    
PlayerInfo[playerid][pJobSkill][JOB_FISHER] ++;
    if(
DayRespect == 1)
    {
      
PlayerInfo[playerid][pJobSkill][JOB_FISHER] ++;
    }
    new 
newj strval(RPJL(playeridJOB_FISHER));
    if(
oldj newj)
    {
        
format(stringsizeof(string), "** Your Fisher level is now %d, you can now catch heavier fishes. **"newj);
        
SendClientMessage(playeridCOLOR_YELLOWstring);
    }
    
Fished[playerid] ++;
    if(
Fished[playerid] >= 5)
    {
        
Fished[playerid] = 0;
        
FishTime[playerid] = 60*5;
        
SetTimerEx("FishingTime"1000false"i"playerid);
    }
    return 
1;

Reply
#2

Short: PlayerInfo[playerid][pFishingTime] is not the same as FishTime[playerid]. You are only updating FishTime[playerid], but saving/loading PlayerInfo[playerid][pFishingTime].
Reply
#3

So how can i fix it ? I need to do the same with FishTime ?

EDIT:

You mean i need to do it like this ?

dini_IntSet(file, "FishingTime", PlayerInfo[playerid][pFishTime]);
Reply
#4

You can get rid of pFishTime, and simply
pawn Код:
//change
dini_IntSet(file, "FishingTime", PlayerInfo[playerid][pFishingTime]);
//to
dini_IntSet(file, "FishingTime", FishTime[playerid]);

//and
PlayerInfo[playerid][pFishingTime] = dini_Int(file, "FishingTime");
//to
FishTime[playerid] = dini_Int(file, "FishingTime");
Also in OnPlayerLogin or something similar add
pawn Код:
SetTimerEx("FishingTime", 1000, false, "i", playerid);
Reply
#5

Wow thank you so much but i wanted to ask one more thing

Same problem with dropcar :/

As this is different type code i am facing the same problem again :/

All about the timer itself:
PHP код:
PlayerInfo[playerid][pCountDown] = 0;
dini_IntSet(file"CountDown"PlayerInfo[playerid][pCountDown]);
PlayerInfo[playerid][pCountDown] = dini_Int(file"CountDown");
forward CountDown(playerid);
public 
CountDown(playerid)
{
    
g_var[playerid] = 0;


CMD and OnPlayerEnterCP
PHP код:
CMD:dropcar(playeridparams[])
{
    new 
vehicleid GetPlayerVehicleID(playerid);
    if(
g_var[playerid] == 1) return SendClientMessage(playerid,COLOR_GREY,"**You need to wait 20 minutes to use this command again.");
    if(!
IsPlayerLoggedIn(playerid)) return SendClientMessage(playeridCOLOR_GREY"**You need to login first before using any command.");
    if(!
vehicleid) return SendClientMessage(playeridCOLOR_GREY"**You must be inside a vehicle to use this command.");
    if(
GetPlayerVehicleID(playerid) != 0)
    {
        
DisablePlayerCheckpoint(playerid);
        
SetPlayerCheckpoint(playerid,  2789.6619, -2517.810516.15095);
        
SendClientMessage(playeridCOLOR_LIGHTBLUE"*Deliver car to the Los Santos docks to recive your pay!");
    if(
PointInfo[4][pOwner])
    {
        new 
idx PointInfo[4][pOwner];
        
FamInfo[idx][fMoney] += 1*2;
        
PointInfo[4][pProfit] += 1*2;
    }
    }
    return 
1;

PHP код:
{
    new 
vehicleid GetPlayerVehicleID(playerid);
    if(!
vehicleid) return SendClientMessage(playeridCOLOR_GREY"**You must be inside a vehicle.");
    if(
g_var[playerid] == && IsPlayerInRangeOfPoint(playerid5,  2789.6619, -2517.810516.1509))
    {
            
DisablePlayerCheckpoint(playerid);
            new 
string[128], amount;
            
amount 100+random(250);
            
format(stringsizeof(string), "*You've earned {FF6347}$%d{33CCFF} from dropping a car!"amount);
            
SendClientMessage(playeridCOLOR_LIGHTBLUEstring);
            
GiveDodMoney(playeridamount);
            
SetVehicleToRespawn(vehicleid);
            
g_var[playerid] = 1;
            
SetTimerEx("CountDown",1200*1000false"d"playerid);
        } 
Reply
#6

This is a little bit more complex, but not too much. You need to store the time remaining, so:

pawn Код:
//change
if(g_var[playerid] == 1)
//to
if(PlayerInfo[playerid][pCountDown])

//change
if(g_var[playerid] == 0 //(... rest of the line)
//to
if(!PlayerInfo[playerid][pCountDown] //(...)

//change
SetTimerEx("CountDown",1200*1000, false, "d", playerid);
//to
PlayerInfo[playerid][pCountDown] = 20 * 60; //time stored in seconds
SetTimerEx("CountDown", 1000, false, "d", playerid);

//change
public CountDown(playerid)
{
    g_var[playerid] = 0;
}
//to
public CountDown(playerid)
{
    if(PlayerInfo[playerid][pCountDown]-- > 0) {
        SetTimerEx("CountDown", 1000, false, "d", playerid);
    }
}

//In OnPlayerLogin or similar
if(PlayerInfo[playerid][pCountDown]) {
    SetTimerEx("CountDown", 1000, false, "d", playerid);
}
Reply
#7

Thanks but fixed it on my own using the technique u gave me earlyer recoded the dropcar on the same basis as the fishing but now the timers are freezing on relogging so what could couse it ?


EDIT:
Still giving Rep as you are the only one helping me here

EDIT2: Can't give you at the moment as i have given ya recently :C
Reply
#8

Did you add SetTimerEx'es to your function called after login? You have to start them manually
Reply
#9

You mean "stock LoadChar(playerid)"?

Cuz i dont have such a function :/

EDIT:
public OnPlayerConnect(playerid)
public OnPlayerRequestClass(playerid, classid)
public OnPlayerSpawn(playerid)


Or these ones ?

EDIT2: FIXED!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)