[Tutorial] [New] How to make capture zone system (no more code repeating)
#29

Nice tutorial, I'm trying to do this in my GM, but the problem is when a player get in the CP, doesn't pass for the progress bar string condition, I don't find what's wrong, if someone could help me.. I only can offer +rep XD


This is my OnPlayerEnterDynamicCP:

PHP Code:
public OnPlayerEnterDynamicCP(playeridcheckpointid)
{
    for (new 
0MAX_CONQUIST_BASESi++)
    {
        print(
"a");
        if(!
_bInfo[i][Exists] || checkpointid != _bInfo[i][E_CAPTURE_ZONE_CP]) continue;
        
        print(
"b");
        if (
IsPlayerInAnyVehicle(playerid)) // this little check disallows the player to capture in a vehicle
        
{
            
SendClientMessage(playeridCOLOR_TOMATO"You cannot capture a zone in a vehicle.");
            return 
1;
        }
        print(
"c");
        if (
_bInfo[i][E_CAPTURE_ZONE_ATTACKER] == INVALID_PLAYER_ID// this check tells us that gangzone is not under attack so we can proceed with start attacking here!
        
{
            print(
"d");
            if (
_Info[playerid][pClan] > 0// here the team ids play its role, we check the index is valid - The second part is if whether the player isn't of team that zone owner is
            
{
                print(
"e");
                
_bInfo[i][E_CAPTURE_ZONE_ATTACKER] = playerid;
                
_bInfo[i][E_CAPTURE_ZONE_PLAYERS_IN_ZONE] = 1;
                
_bInfo[i][E_CAPTURE_ZONE_COUNTDOWN] = 0;
                
KillTimer(_bInfo[i][E_CAPTURE_ZONE_TIMER]);
                
_bInfo[i][E_CAPTURE_ZONE_TIMER] = SetTimerEx("OnCaptureZoneUpdate"1000true"i"i);
                
// falsh gangzone for all
                
GangZoneFlashForAll(_bInfo[i][G_SV_ID], 0xFF000085);
                
// display capture message to player
                
SendClientMessage(playeridCOLOR_GREEN"Stay in the checkpoint to for 15 seconds to capture the zone.");
                
// display provocation message to all
                
new string[150];
                
format(stringsizeof string"%s is trying to capture %s away from team %s."GetClanName(_Info[playerid][pClan]), _bInfo[i][BaseName], _bInfo[i][ConquistedBy]);
                
SendClientMessageToAll(COLOR_TOMATOstring);
            }
            else return 
1;
        }
        else if (
_Info[playerid][pClan] == _Info[_bInfo[i][E_CAPTURE_ZONE_ATTACKER]][pClan]) // already being captured and player is of the same team that of attacker is
        
{
            print(
"f");
            
// increase number of players capturing
            
_bInfo[i][E_CAPTURE_ZONE_PLAYERS_IN_ZONE]++;
            
SendClientMessage(playeridCOLOR_GREEN"Stay in the checkpoint to assist your teammate in capturing the zone.");
        }
        print(
"g");
        
// show progress bar and capture textdraw!
        
PlayerTextDrawShow(playeridcapturePlayerTextDraw[playerid]);
        
ShowPlayerProgressBar(playeridcapturePlayerBar[playerid]);
        return 
1;
    }
    return 
1;

And this is the timer callback:

PHP Code:
forward OnCaptureZoneUpdate(zoneid);
public 
OnCaptureZoneUpdate(zoneid)
{
    
// the zone capture rate depends on the number of players capturing it
    // so if its "1", the capture time taken will be 30s
    // if its "2", the capture time decreases to half i.e. 15s
    // given you set the CAPTURE_TIME to 30
    
_bInfo[zoneid][E_CAPTURE_ZONE_COUNTDOWN] += _bInfo[zoneid][E_CAPTURE_ZONE_PLAYERS_IN_ZONE];
    new 
string[150];
    
format(stringsizeof string"Capturing Zone In %i..."CAPTURE_TIME _bInfo[zoneid][E_CAPTURE_ZONE_COUNTDOWN]);
    
// update progress bar and textdraw for all players capturing
    
for (new iGetPlayerPoolSize(); <= ji++)
    {
        if (
IsPlayerInDynamicCP(i_bInfo[zoneid][G_SV_ID]) && !IsPlayerInAnyVehicle(i))
        {
            
PlayerTextDrawSetString(icapturePlayerTextDraw[i], string);
            
SetPlayerProgressBarValue(icapturePlayerBar[i], _bInfo[zoneid][E_CAPTURE_ZONE_COUNTDOWN]);
        }
    }
    
// zone has been captured
    
if (_bInfo[zoneid][E_CAPTURE_ZONE_COUNTDOWN] > CAPTURE_TIME)
    {
        
GetPlayerName(_bInfo[zoneid][ConquistedBy], stringMAX_PLAYER_NAME);
        
format(stringsizeof string"Good job. You assisted %s to capture %s. +$250"string_bInfo[zoneid][ConquistedBy]);
        for (new 
iGetPlayerPoolSize(); <= ji++)
        {
            if (
IsPlayerInDynamicCP(i_bInfo[zoneid][G_SV_ID]) && !IsPlayerInAnyVehicle(i) && _Info[i][pClan] == _Info[_bInfo[zoneid][E_CAPTURE_ZONE_ATTACKER]][pClan])
               {
                
PlayerTextDrawHide(icapturePlayerTextDraw[i]);
                
HidePlayerProgressBar(icapturePlayerBar[i]);
                
// giving reward to teammates who assisted
                
if (!= _bInfo[zoneid][E_CAPTURE_ZONE_ATTACKER])
                {
                    
SendClientMessage(iCOLOR_GREENstring);
                    
_GiveMoney(i250);
                }
            }
        }
        
// giving reward to the attacker who startd capturing initially
        
_GiveMoney(_bInfo[zoneid][E_CAPTURE_ZONE_ATTACKER], 1000);
        
format(stringsizeof string"Good job. You successfully captured %s from %s. +1 Score, +$1000"_bInfo[zoneid][BaseName], _bInfo[zoneid][ConquistedBy]);
        
SendClientMessage(_bInfo[zoneid][E_CAPTURE_ZONE_ATTACKER], COLOR_GREENstring);
        
// announcing capture to all players
        
format(stringsizeof string"<Capture Zone>: Team %s have captured %s from %s."GetClanName(_Info[_bInfo[zoneid][E_CAPTURE_ZONE_ATTACKER]][pClan]), _bInfo[zoneid][BaseName], _bInfo[zoneid][ConquistedBy]);
        
SendClientMessageToAll(-1string);
        
// reset capture zone variables and modify Owner to attacker's team id
        
_bInfo[zoneid][ConquistedBy][0] = EOS;
        
strcat(_bInfo[zoneid][ConquistedBy], GetClanName(_Info[_bInfo[zoneid][E_CAPTURE_ZONE_ATTACKER]][pClan]), 30);
        new 
query[128];
        
mysql_format(sql_handlequerysizeof(query), "UPDATE `bases` SET `ConquistedBy` = '%e' WHERE `ID` = '%d'"_bInfo[zoneid][ConquistedBy], _bInfo[zoneid][BASE_DB_ID]);
        
mysql_tquery(sql_handlequery);
        
        
_bInfo[zoneid][E_CAPTURE_ZONE_ATTACKER] = INVALID_PLAYER_ID;
        
        
KillTimer(_bInfo[zoneid][E_CAPTURE_ZONE_TIMER]);
        
GangZoneStopFlashForAll(_bInfo[zoneid][G_SV_ID]);
        
GangZoneShowForAll(_bInfo[zoneid][G_SV_ID], -1601993835);
    }
    return 
1;

I tried to print there too (from "a" to "y" passing each condition) and doesn't pass for this one:

PHP Code:
for (new iGetPlayerPoolSize(); <= ji++)
    {
        if (
IsPlayerInDynamicCP(i_bInfo[zoneid][G_SV_ID]) && !IsPlayerInAnyVehicle(i))
        {
            
PlayerTextDrawSetString(icapturePlayerTextDraw[i], string);
            
SetPlayerProgressBarValue(icapturePlayerBar[i], _bInfo[zoneid][E_CAPTURE_ZONE_COUNTDOWN]);
        }
    } 
What can be the fail?

PS. Sorry for my bad english >.<'
Regards!
Reply


Messages In This Thread
[New] How to make capture zone system (no more code repeating) - by Gammix - 23.08.2015, 09:25
Re: [New] How to make capture zone system (no more code repeating) - by Hemeei - 23.08.2015, 09:29
Re: [New] How to make capture zone system (no more code repeating) - by Karan007 - 23.08.2015, 09:34
Re: [New] How to make capture zone system (no more code repeating) - by jamesmith12 - 23.08.2015, 12:27
Re: [New] How to make capture zone system (no more code repeating) - by Hemeei - 23.08.2015, 12:32
Re: [New] How to make capture zone system (no more code repeating) - by Viki - 23.08.2015, 18:27
Re: [New] How to make capture zone system (no more code repeating) - by Cassy_ - 25.08.2015, 10:38
Re: [New] How to make capture zone system (no more code repeating) - by SEIFOUNE123 - 25.08.2015, 11:02
Re: [New] How to make capture zone system (no more code repeating) - by jamesmith12 - 25.08.2015, 14:15
Re: [New] How to make capture zone system (no more code repeating) - by HydraHumza - 25.08.2015, 17:05
Re: [New] How to make capture zone system (no more code repeating) - by N0FeaR - 13.12.2015, 21:31
Re: [New] How to make capture zone system (no more code repeating) - by Counterafk - 03.01.2016, 23:27
Re: [New] How to make capture zone system (no more code repeating) - by Gammix - 04.01.2016, 03:54
Re: [New] How to make capture zone system (no more code repeating) - by CrunchxNoy - 04.01.2016, 06:34
Re: [New] How to make capture zone system (no more code repeating) - by Counterafk - 04.01.2016, 14:43
Re: [New] How to make capture zone system (no more code repeating) - by aloveliday - 04.01.2016, 15:42
Re: [New] How to make capture zone system (no more code repeating) - by Gammix - 05.01.2016, 09:04
Re: [New] How to make capture zone system (no more code repeating) - by stormchaser206 - 16.03.2016, 02:35
Re: [New] How to make capture zone system (no more code repeating) - by Gammix - 16.03.2016, 02:47
Re: [New] How to make capture zone system (no more code repeating) - by stormchaser206 - 16.03.2016, 21:51
Re: [New] How to make capture zone system (no more code repeating) - by Gammix - 17.03.2016, 00:25
Re: [New] How to make capture zone system (no more code repeating) - by stormchaser206 - 17.03.2016, 02:33
Re: [New] How to make capture zone system (no more code repeating) - by Yultranions - 29.09.2016, 10:46
Re: [New] How to make capture zone system (no more code repeating) - by FreAkeD - 29.09.2016, 12:12
Re: [New] How to make capture zone system (no more code repeating) - by Hunud - 10.06.2017, 13:36
Re: [New] How to make capture zone system (no more code repeating) - by Gammix - 10.06.2017, 14:58
Re: [New] How to make capture zone system (no more code repeating) - by Hunud - 10.06.2017, 15:08
Re: [New] How to make capture zone system (no more code repeating) - by Gammix - 12.09.2017, 18:38
Re: [New] How to make capture zone system (no more code repeating) - by Psycho96 - 08.12.2017, 20:58
Re: [New] How to make capture zone system (no more code repeating) - by Gammix - 08.12.2017, 23:13

Forum Jump:


Users browsing this thread: 1 Guest(s)