17.03.2016, 00:25
^^ Where is the rest of the code ?
Loaded log file: "server_log.txt". ---------- SA-MP Dedicated Server ---------------------- v0.3.7-R2, ©2005-2015 SA-MP Team [07:34:36] filterscripts = "" (string) [07:34:36] [07:34:36] Server Plugins [07:34:36] -------------- [07:34:36] Loading plugin: streamer [07:34:36] *** Streamer Plugin v2.8.2 by Incognito loaded *** [07:34:36] Loaded. [07:34:36] Loading plugin: sscanf [07:34:36] [07:34:36] =============================== [07:34:36] sscanf plugin loaded. [07:34:36] Version: 2.8.1 [07:34:36] © 2012 Alex "Y_Less" Cole [07:34:36] =============================== [07:34:36] Loaded. [07:34:36] Loading plugin: Whirlpool [07:34:36] [07:34:36] ================== [07:34:36] [07:34:36] Whirlpool loaded [07:34:36] [07:34:36] ================== [07:34:36] [07:34:36] Loaded. [07:34:36] Loading plugin: MapAndreas [07:34:36] Loaded. [07:34:36] Loaded 4 plugins. [07:34:36] [07:34:36] Filterscripts [07:34:36] --------------- [07:34:36] Loaded 0 filterscripts. [07:34:36] Script[gamemodes/CPTZ.amx]: Run time error 20: "Invalid index parameter (bad entry point)" [07:34:36] Number of vehicle models: 0 |
I did everything as it comes in the tutorial and got an error.
|
main( ) { }
Sorry for bumping, just an simple question
- Is there any bugs or something where i must be carefull by doing such thing. Is this way of doing team and zones still trust worth ? Thanks |
Of course. It has no bugs, none reported and i have been using this in 2 of my popular gamemodes: ww3 and ww4
I would suggest you one thing about the "team array". If you have team data in an array/enum already, then you don't need to create a separate one like this tutorial does. You can use that instead. |
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;
}
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;
}
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]);
}
}