[Help] SetTimer - OnGameModeInit
#1

This is my OnGameModeInit:
pawn Код:
public OnGameModeInit()
{
mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
mysql_debug(1); // Debugging enabled
DisableInteriorEnterExits();
ManualVehicleEngineAndLights();
ShowPlayerMarkers(0);
ResetObjectsOpen();

SetTimer("moneyfix", 500, true);
SetTimer("trailer", 1000, 1);
SetTimer("checkpoint", 1500, 1);
SetTimer("alarme", 2000, 1);

// NPCs
// NPCs
ConnectNPC("Policial","motorista1");
ConnectNPC("Mendigo","a1");

AddPlayerClass(0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0,0, 0, 0);

SetGameModeText("Brasil Country Roleplay");

print("=====================================================================");
AddVehiclesFromFile();
AddPickupFromFile();
AddLabelsFromFile();
AddMapIconFromFile();
AddBizFromFile();
AddObjectsFromFile();
AddFactionsFromFile();
print("=====================================================================\n");

return 1;
}
None of this Timers are working... Look at one of them, for example.
pawn Код:
forward moneyfix(playerid);
public moneyfix(playerid){
if(GetPlayerMoney(playerid)==PVar[playerid][pMoney]){
return 1;
}
else{
SendClientMessage(playerid, COLOR_GREY, "[INFO] Dinheiro nгo sincronizado, corrigindo o valor...");
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid,PVar[playerid][pMoney]);
}
return 0;
}
They were working before, something i added made them stop working, can you help me figuring out what?
Reply
#2

Try to return public 'moneyfix(playerid)' as true?
Reply
#3

Sorry rider, i didn't understand what you are saying!
Moneyfix is already a public function, i tried both true and 1 on repeat but it still does not works.
Reply
#4

he meant
pawn Код:
return 1;
at the
pawn Код:
moneyfix(playerid)
Reply
#5

Still does not works.

I don't know what to do, i'm scripting this gamemode almost from scrap for almost 2 weeks, these timers were working nicely...
Reply
#6

Edit: Ignore this post...fail... -.-"
Reply
#7

I've tried disabling all the possible other functions on OnGameModeInit but nothing... I also tried adding them to OnPlayerConnect and nothing...

Maybe do is it some other function that is blocking the timers? Maybe because of not having a "return 1;"?
Reply
#8

The problem is i'm using the playerid on the timers

like

public moneyfix(playerid);

How to add the playerid as a variable to the moneyfix function using SetTimer?
Reply
#9

To functions without parameters, you have to use SetTimer.

Example:
pawn Код:
LoL(/*No Parameteres here*/) return 1;
And, to functions with parameters like moneyfix(playerid), you have to use SetTimerEx.


If you want to use SetTimer in OnGameModeInit callback, you have to do a loop to it checks all the players.


I hope that i have helped
Reply
#10

rjjj:

You helped a lot, that was exactly the problem!
I think i'll just add a loop on each of the timers
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)