Capturin zones
#1

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.
Reply
#2

Well.. use timer for 1sec. which get actived then player enter to checkpoint...After that check if player is in right place with PlayerToPoint (if u have this stock) and count seconds like:
pawn Код:
public StandInPlace(playerid)
  {
  if(TimeInPlace[playerid] < 20) // 20 - 20sec
     {
     if(PlayerToPoint(3,playerid,X,Y,Z)
       {
       TimeInPlace[playerid]++
       }
     else KillTimer(timerid);
     }
  else
     {
     TimeInPlace[playerid]=0;
     //do smth after player stand in place 20sec...
     }
  return 1;
  }
ofcourse dont foget as global
pawn Код:
TimeInPlace[MAX_PLAYERS]=0
Reply
#3

Quote:
Originally Posted by marrcko
Посмотреть сообщение
Well.. use timer for 1sec. which get actived then player enter to checkpoint...After that check if player is in right place with PlayerToPoint (if u have this stock) and count seconds like:
pawn Код:
public StandInPlace(playerid)
  {
  if(TimeInPlace[playerid] < 20) // 20 - 20sec
     {
     if(PlayerToPoint(3,playerid,X,Y,Z)
       {
       TimeInPlace[playerid]++
       }
     else KillTimer(timerid);
     }
  else
       {
       TimeInPlace[playerid]=0;
       //do smth after player stand in place 20sec...
       }
  return 1;
  }
ofcourse dont foget as global
pawn Код:
TimeInPlace[MAX_PLAYERS]=0
Thanks dude,How can i use this if someone is in checkpoint?
Reply
#4

IsPlayerInCheckpoint

pawn Код:
if(IsPlayerInCheckpoint(playerid))
{
    // function
}
Reply
#5

Quote:
Originally Posted by Pinguinn
Посмотреть сообщение
IsPlayerInCheckpoint

pawn Код:
if(IsPlayerInCheckpoint(playerid))
{
    // function
}
Yeah i know but i dont understand his code.
Reply
#6

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;
}
Reply
#7

let say u have timer named Timer_Stay[MAX_PLAYERS], then:

pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
    if(PlayertoPoint(3,playerid,X,Y,Z) // this x, y and z is coordinates from ur CP
        {
        SenClientMessage(playerid,Blue,"Stay in this pos. for 20sec to take this area");
        Timer_Stay[playerid] = SetTimerEx("StandInPlace",1000, 1, "i", playerid);
        return 1;
        }
    return 1;
}
Reply
#8

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.
Reply
#9

nop its can be 3

pawn Код:
stock PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
    if(IsPlayerConnected(playerid))
    {
        new Float:oldposx, Float:oldposy, Float:oldposz;
        new Float:tempposx, Float:tempposy, Float:tempposz;
        GetPlayerPos(playerid, oldposx, oldposy, oldposz);
        tempposx = (oldposx -x);
        tempposy = (oldposy -y);
        tempposz = (oldposz -z);
        if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
        {
            return 1;
        }
    }
    return 0;
}
now he has... besides giving all script doesn't teach him to think

BTW maybe he has cmd which create CP so its kind of protection from other players
Reply
#10

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*
Reply
#11

OK ok relax man...i get ur point....
Reply
#12

Where i need at this? And is it the good code?
Код:
SetProgressBarValue(capture, pCount[playerid]);
SetProgressBarMaxValue(capture, 20);
UpdateProgressBar(capture, pCount[playerid]);
Reply
#13

Yes.. that's a good code. Paste it in public what counting.
But this:
pawn Код:
SetProgressBarMaxValue(playerid, 20);
Put into OnPlayerSpawn callback.
Reply
#14

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?
Reply
#15

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?
Reply
#16

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]?
Reply
#17

Oh sorry.. i lost about it, progress bar got in other way values. Yes.. capture had to [playerid].
Reply
#18

If someone try to capture the zone can a team member help to capture it faster?
Reply
#19

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.
Reply
#20

CAn you give example pls?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)