Posts: 1,840
Threads: 399
Joined: Oct 2010
Reputation:
0
Heey guys,
I want to make that you can capturing zones if you are in a checkpoint.
And that you have to stay 20 seconds in the checkpoint but i dont know how to make this.
Pls Help me.
Posts: 1,767
Threads: 124
Joined: Mar 2010
pawn Код:
#include "a_samp"
new pCount[MAX_PLAYERS];
new pTimer[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
pCount[playerid] = 0;
return true;
}
public OnPlayerDisconnect(playerid, reason)
{
pCount[playerid] = 0;
return true;
}
public OnPlayerEnterCheckpoint(playerid)
{
pTimer[playerid] = SetTimerEx("CapturinZones", 1000, true, "d", playerid);
return true;
}
public OnPlayerLeaveCheckpoint(playerid)
{
KillTimer(pTimer[playerid]);
return true;
}
forward CapturinZones(playerid);
public CapturinZones(playerid)
{
pCount[playerid] += 1;
switch(pCount[playerid])
{
case 20:
{
// Your code to Capture zone.
pCount[playerid] = 0;
KillTimer(pTimer[playerid]);
}
}
return true;
}
Posts: 1,767
Threads: 124
Joined: Mar 2010
He don't have function:
pawn Код:
if(PlayertoPoint(3,playerid, X, Y, Z)
so stop copying your stupid codes and it's a float. It can't be 3, should be 3.0.
pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 3.0, X, Y, Z))
And he doesn't need it because only one checkpoint can be created so OnPlayerEnterCheckpoint will check it automaticly. IsPlayerInRangeOfPoint should be used if he wanted to create more checkpoints.
Posts: 1,767
Threads: 124
Joined: Mar 2010
He don't need this 'a lot of memory' using function from GodFather gamemode. IsPlayerInRangeOfPoint is included into SA-MP and it's a lot faster than PlayerToPoint. He doesn't need it. And i don't think so he got command to create Checkpoint because he don't know how to make Checkpoint with counting (without offending him). And if float can be 3 then float saving should be 3 not 3.0000[...]. Of course it can be 3 but for saving his server from bugs i rather use 3.0.
*stop spamming*
Posts: 82
Threads: 27
Joined: Aug 2010
Reputation:
0
OK ok relax man...i get ur point....
Posts: 1,767
Threads: 124
Joined: Mar 2010
Yes.. that's a good code. Paste it in public what counting.
But this:
pawn Код:
SetProgressBarMaxValue(playerid, 20);
Put into OnPlayerSpawn callback.
Posts: 1,840
Threads: 399
Joined: Oct 2010
Reputation:
0
capture is the progess bar. It needs to be capture[playerid]? or just capture?
Because it can gives problems if we capture a capture on same time?
Posts: 1,767
Threads: 124
Joined: Mar 2010
Eh..
pawn Код:
forward CapturinZones(playerid);
public CapturinZones(playerid)
{
pCount[playerid] += 1;
switch(pCount[playerid])
{
case 20:
{
// Your code to Capture zone.
pCount[playerid] = 0;
KillTimer(pTimer[playerid]);
}
}
SetProgressBarValue(playerid, pCount[playerid]);
UpdateProgressBar(playerid, pCount[playerid]);
return true;
}
See what i mean?
Posts: 1,840
Threads: 399
Joined: Oct 2010
Reputation:
0
I mean this is the bar: capture = CreateProgressBar(50.0, 300.0, _, _, 0xFF0000FF, 100.0);
U see capture. It needs to be capture or capture[playerid]?
Posts: 1,767
Threads: 124
Joined: Mar 2010
Oh sorry.. i lost about it, progress bar got in other way values. Yes.. capture had to [playerid].
Posts: 1,840
Threads: 399
Joined: Oct 2010
Reputation:
0
If someone try to capture the zone can a team member help to capture it faster?
Posts: 1,767
Threads: 124
Joined: Mar 2010
Add to some variable +1 when player enter. When second player enter there'll be obviously +2 then change SetProgressBarValue to your own with two players.
Posts: 1,840
Threads: 399
Joined: Oct 2010
Reputation:
0
CAn you give example pls?