SetpVarInt and GetpVarInt - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: SetpVarInt and GetpVarInt (
/showthread.php?tid=278127)
Timer SetpVarInt and GetpVarInt -
Admigo - 20.08.2011
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?
Re: SetpVarInt and GetpVarInt -
Lorenc_ - 20.08.2011
You relise you did your loop terribly wrong.
Re: SetpVarInt and GetpVarInt -
[HiC]TheKiller - 21.08.2011
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.
Re: SetpVarInt and GetpVarInt -
Admigo - 21.08.2011
Quote:
Originally Posted by [HiC]TheKiller
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?
Re: SetpVarInt and GetpVarInt -
Lorenc_ - 21.08.2011
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.