SetpVarInt and GetpVarInt
#1

Heey guys,
I made a 20 seconds timer with pvarint.
onplayerpickup
Code:
if(pickupid==areap)
	{
		if(gTeam[playerid]==TEAM_EUROPE)
		{
			for(new i; i < MAX_PLAYERS; i++)
			{
				//GangZoneShowForAll(area,GZ_YELLOW);
				capturezone=SetTimer("capturezones",1000,1);
				SetPVarInt(i, "europe_area51", 1);
			}
		}
	}
timer
Code:
forward capturezones();
public capturezones()
{
	counter++;
	for(new i; i < MAX_PLAYERS; i++)
	{
		if(counter== 20 && (GetPVarInt(i, "europe_area51") == 1))
		{
				GangZoneShowForAll(area,GZ_YELLOW);
				counter=0;
				KillTimer(capturezone);
		}
	}

}
ontopofscript
counter=0;

And if i pickup the pickup i dont need to wait 20 seconds i just get the gangzone.
What i did wrong?
Reply
#2

You relise you did your loop terribly wrong.
Reply
#3

You ran that timer 500 times, so I'm really not surprised.

pawn Code:
if(pickupid==areap && gTeam[playerid]==TEAM_EUROPE)
{
    capturezone=SetTimer("capturezones",1000,1);
    SetPVarInt(playerid, "europe_area51", 1);
}
pawn Code:
forward capturezones();
public capturezones()
{
    counter++;
    if(counter== 20)
    {
        GangZoneShowForAll(area,GZ_YELLOW);
        counter=0;
        KillTimer(capturezone);
    }
    return 1; //Always return 1 on a timer.
}
Give that a go.
Reply
#4

Quote:
Originally Posted by [HiC]TheKiller
View Post
You ran that timer 500 times, so I'm really not surprised.

pawn Code:
if(pickupid==areap && gTeam[playerid]==TEAM_EUROPE)
{
    capturezone=SetTimer("capturezones",1000,1);
    SetPVarInt(playerid, "europe_area51", 1);
}
pawn Code:
forward capturezones();
public capturezones()
{
    counter++;
    if(counter== 20)
    {
        GangZoneShowForAll(area,GZ_YELLOW);
        counter=0;
        KillTimer(capturezone);
    }
    return 1; //Always return 1 on a timer.
}
Give that a go.
What i need to do with the GetpVarint?
Reply
#5

pawn Code:
for(new i; i < MAXPLAYERS; i++)
{
    if(!IsPlayerConnected(i)) continue;
    if(GetPVarInt(i, "europe_area51") != 1) continue;
    SetPVarInt(i, "europe_area51", 0);
}
Try something like this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)