Timer save glitch/missing lines -
weedxd - 08.01.2015
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", 1000, false, "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", 1000, false, "i", playerid);
}
return 1;
}
CMD itself:
PHP код:
CMD:fish(playerid, params[])
{
new string[128], done, fish;
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(!IsPlayerNearWater(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not near water to catch fish.(You need to stand in water)");
if(FishTime[playerid])
{
format(string, sizeof(string), "You need to wait %d more seconds before fishing again.", FishTime[playerid]);
SendClientMessage(playerid, COLOR_GREY, string);
return 1;
}
for(new i=0; i<5; i++) // Fish
{
if(!done)
{
if(!PlayerInfo[playerid][pFish][i]) done = i+1;
}
}
if(!done) return SendClientMessage(playerid, COLOR_GREY, "You can't carry anymore fishes.");
done = done-1;
// Catching
if(strval(RPJL(playerid, JOB_FISHER)) == 1) fish = random(25)+1;
else if(strval(RPJL(playerid, JOB_FISHER)) == 2) fish = random(26)+5;
else if(strval(RPJL(playerid, JOB_FISHER)) == 3) fish = random(31)+10;
else if(strval(RPJL(playerid, JOB_FISHER)) == 4) fish = random(36)+15;
else if(strval(RPJL(playerid, JOB_FISHER)) == 5) fish = random(41)+25;
PlayerInfo[playerid][pFish][done] = fish;
format(string, sizeof(string), "* %s attempts to catch a fish using the fishing rod.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
format(string, sizeof(string), " You have caught a %d lbs fish.", fish);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
// Leveling
new oldj = strval(RPJL(playerid, JOB_FISHER));
PlayerInfo[playerid][pJobSkill][JOB_FISHER] ++;
if(DayRespect == 1)
{
PlayerInfo[playerid][pJobSkill][JOB_FISHER] ++;
}
new newj = strval(RPJL(playerid, JOB_FISHER));
if(oldj < newj)
{
format(string, sizeof(string), "** Your Fisher level is now %d, you can now catch heavier fishes. **", newj);
SendClientMessage(playerid, COLOR_YELLOW, string);
}
Fished[playerid] ++;
if(Fished[playerid] >= 5)
{
Fished[playerid] = 0;
FishTime[playerid] = 60*5;
SetTimerEx("FishingTime", 1000, false, "i", playerid);
}
return 1;
}
Re: Timer save glitch/missing lines -
Misiur - 08.01.2015
Short: PlayerInfo[playerid][pFishingTime] is not the same as FishTime[playerid]. You are only updating FishTime[playerid], but saving/loading PlayerInfo[playerid][pFishingTime].
Re: Timer save glitch/missing lines -
weedxd - 08.01.2015
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]);
Re: Timer save glitch/missing lines -
Misiur - 08.01.2015
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);
Re: Timer save glitch/missing lines -
weedxd - 08.01.2015
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(playerid, params[])
{
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(playerid, COLOR_GREY, "**You need to login first before using any command.");
if(!vehicleid) return SendClientMessage(playerid, COLOR_GREY, "**You must be inside a vehicle to use this command.");
if(GetPlayerVehicleID(playerid) != 0)
{
DisablePlayerCheckpoint(playerid);
SetPlayerCheckpoint(playerid, 2789.6619, -2517.8105, 16.1509, 5);
SendClientMessage(playerid, COLOR_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(playerid, COLOR_GREY, "**You must be inside a vehicle.");
if(g_var[playerid] == 0 && IsPlayerInRangeOfPoint(playerid, 5, 2789.6619, -2517.8105, 16.1509))
{
DisablePlayerCheckpoint(playerid);
new string[128], amount;
amount = 100+random(250);
format(string, sizeof(string), "*You've earned {FF6347}$%d{33CCFF} from dropping a car!", amount);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
GiveDodMoney(playerid, amount);
SetVehicleToRespawn(vehicleid);
g_var[playerid] = 1;
SetTimerEx("CountDown",1200*1000, false, "d", playerid);
}
Re: Timer save glitch/missing lines -
Misiur - 08.01.2015
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);
}
Re: Timer save glitch/missing lines -
weedxd - 08.01.2015
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
Re: Timer save glitch/missing lines -
Misiur - 08.01.2015
Did you add SetTimerEx'es to your function called after login? You have to start them manually
Re: Timer save glitch/missing lines -
weedxd - 08.01.2015
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!