08.12.2017, 20:58
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:
And this is the timer callback:
I tried to print there too (from "a" to "y" passing each condition) and doesn't pass for this one:
What can be the fail?
PS. Sorry for my bad english >.<'
Regards!
This is my OnPlayerEnterDynamicCP:
PHP Code:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
for (new i = 0; i < MAX_CONQUIST_BASES; i++)
{
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(playerid, COLOR_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", 1000, true, "i", i);
// falsh gangzone for all
GangZoneFlashForAll(_bInfo[i][G_SV_ID], 0xFF000085);
// display capture message to player
SendClientMessage(playerid, COLOR_GREEN, "Stay in the checkpoint to for 15 seconds to capture the zone.");
// display provocation message to all
new string[150];
format(string, sizeof string, "%s is trying to capture %s away from team %s.", GetClanName(_Info[playerid][pClan]), _bInfo[i][BaseName], _bInfo[i][ConquistedBy]);
SendClientMessageToAll(COLOR_TOMATO, string);
}
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(playerid, COLOR_GREEN, "Stay in the checkpoint to assist your teammate in capturing the zone.");
}
print("g");
// show progress bar and capture textdraw!
PlayerTextDrawShow(playerid, capturePlayerTextDraw[playerid]);
ShowPlayerProgressBar(playerid, capturePlayerBar[playerid]);
return 1;
}
return 1;
}
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(string, sizeof string, "Capturing Zone In %i...", CAPTURE_TIME - _bInfo[zoneid][E_CAPTURE_ZONE_COUNTDOWN]);
// update progress bar and textdraw for all players capturing
for (new i, j = GetPlayerPoolSize(); i <= j; i++)
{
if (IsPlayerInDynamicCP(i, _bInfo[zoneid][G_SV_ID]) && !IsPlayerInAnyVehicle(i))
{
PlayerTextDrawSetString(i, capturePlayerTextDraw[i], string);
SetPlayerProgressBarValue(i, capturePlayerBar[i], _bInfo[zoneid][E_CAPTURE_ZONE_COUNTDOWN]);
}
}
// zone has been captured
if (_bInfo[zoneid][E_CAPTURE_ZONE_COUNTDOWN] > CAPTURE_TIME)
{
GetPlayerName(_bInfo[zoneid][ConquistedBy], string, MAX_PLAYER_NAME);
format(string, sizeof string, "Good job. You assisted %s to capture %s. +$250", string, _bInfo[zoneid][ConquistedBy]);
for (new i, j = GetPlayerPoolSize(); i <= j; i++)
{
if (IsPlayerInDynamicCP(i, _bInfo[zoneid][G_SV_ID]) && !IsPlayerInAnyVehicle(i) && _Info[i][pClan] == _Info[_bInfo[zoneid][E_CAPTURE_ZONE_ATTACKER]][pClan])
{
PlayerTextDrawHide(i, capturePlayerTextDraw[i]);
HidePlayerProgressBar(i, capturePlayerBar[i]);
// giving reward to teammates who assisted
if (i != _bInfo[zoneid][E_CAPTURE_ZONE_ATTACKER])
{
SendClientMessage(i, COLOR_GREEN, string);
_GiveMoney(i, 250);
}
}
}
// giving reward to the attacker who startd capturing initially
_GiveMoney(_bInfo[zoneid][E_CAPTURE_ZONE_ATTACKER], 1000);
format(string, sizeof 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_GREEN, string);
// announcing capture to all players
format(string, sizeof 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(-1, string);
// 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_handle, query, sizeof(query), "UPDATE `bases` SET `ConquistedBy` = '%e' WHERE `ID` = '%d'", _bInfo[zoneid][ConquistedBy], _bInfo[zoneid][BASE_DB_ID]);
mysql_tquery(sql_handle, query);
_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;
}
PHP Code:
for (new i, j = GetPlayerPoolSize(); i <= j; i++)
{
if (IsPlayerInDynamicCP(i, _bInfo[zoneid][G_SV_ID]) && !IsPlayerInAnyVehicle(i))
{
PlayerTextDrawSetString(i, capturePlayerTextDraw[i], string);
SetPlayerProgressBarValue(i, capturePlayerBar[i], _bInfo[zoneid][E_CAPTURE_ZONE_COUNTDOWN]);
}
}
PS. Sorry for my bad english >.<'
Regards!

