Timer not repeating and not calling function
#1

So I have a timer placed under on gamemodeinit and it is not repeating

Code:
public OnGameModeInit()
{
SetTimer("checkAJail", 1000, true);
}
It is supposed to call this function

Code:
checkAJail() {
	foreach(Player, i) {
		if(GetPVarType(i, "AJailReleaseTime") != PLAYER_VARTYPE_NONE) {
			new rtime = GetPVarInt(i, "AJailReleaseTime");
			if(gettime() > rtime) {
				ReleaseAjail(i);
				DeletePVar(i, "AJailReleaseTime");
			}
		}
	}
}
However its not calling it plus its giving me a warning

Code:
LSR.pwn	16928 203 symbol is never used: "checkAJail"
Reply
#2

For timers you have to register your function by forwarding it:
PHP Code:
forward public checkAJail(); 
Then you do the function like
PHP Code:
public checkAJail()
{

->

PHP Code:
forward public checkAJail();
public 
checkAJail() {
    foreach(
Playeri) {
        if(
GetPVarType(i"AJailReleaseTime") != PLAYER_VARTYPE_NONE) {
            new 
rtime GetPVarInt(i"AJailReleaseTime");
            if(
gettime() > rtime) {
                
ReleaseAjail(i);
                
DeletePVar(i"AJailReleaseTime");
            }
        }
    }

Reply
#3

forward + public ?
Reply
#4

Thank you. Something that just went right over my head .
Reply
#5

Instead of forwarding a public function you can just change it to stuck.
Reply
#6

Quote:
Originally Posted by YouHack
View Post
Instead of forwarding a public function you can just change it to stuck.
Wtf? Are you for real? Please do a test and edit your reply when you see how stuff run.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)