14.12.2013, 14:07
i have tried to add points system to my script,code:
and i have points.cfg in scriptfiles
and it not wrong,i mean the points.cfg,but when i do /points ig it shows:

and i cant claim at the entrance in points.cfg
pawn Код:
//===============================[Points]=======================================
public CaptureTimer(point)
{
new string[128];
new fam;
if(Points[point][TimeToClaim])
{
new claimer = Points[point][ClaimerId];
new Float: x, Float: y, Float: z;
GetPlayerPos(claimer, x, y, z);
if (Points[point][Capturex] != x || Points[point][Capturey] != y || Points[point][Capturez] != z || GetPVarInt(Points[point][ClaimerId],"Injured") == 1)
{
SendClientMessage(Points[point][ClaimerId], COLOR_LIGHTBLUE, "You failed to capture. You either moved or died while attempting to capture.");
Points[point][ClaimerId] = INVALID_PLAYER_ID;
Points[point][TimeToClaim] = 0;
}
else
{
if(Points[point][Vulnerable] > 0)
{
SendClientMessage(Points[point][ClaimerId], COLOR_LIGHTBLUE, "You failed to capture. The point was already captured.");
Points[point][ClaimerId] = INVALID_PLAYER_ID;
Points[point][TimeToClaim] = 0;
return 1;
}
fam = PlayerInfo[claimer][pFMember];
format(string, sizeof(string), "%s has attempted to take control of the %s for %s, it will be theirs in %d minutes.", Points[point][PlayerNameCapping], Points[point][Name], FamilyInfo[fam][FamilyName]);
SendClientMessageToAll(COLOR_YELLOW, string);
if(Points[point][CaptureProccessEx] >= 1)
{
UpdateDynamic3DTextLabelText(Points[point][CaptureProccess], COLOR_YELLOW, string);
Points[point][CaptureProccessEx] = 2;
}
Points[point][TakeOverTimerStarted] = 1;
Points[point][TakeOverTimer] = 10;
Points[point][ClaimerId] = INVALID_PLAYER_ID;
Points[point][ClaimerTeam] = fam;
Points[point][TimeToClaim] = 0;
if(Points[point][CaptureTimerEx2] != -1) KillTimer(Points[point][CaptureTimerEx2]);
Points[point][CaptureTimerEx2] = SetTimerEx("CaptureTimerEx", 60000, 1, "d", point);
}
}
return 1;
}
//================================
public CaptureTimerEx(point)
{
new string[128];
new fam;
if (Points[point][TakeOverTimerStarted])
{
fam = Points[point][ClaimerTeam];
if (Points[point][TakeOverTimer] > 0)
{
Points[point][TakeOverTimer]--;
format(string, sizeof(string), "%s has successfully attempted to take over of %s for %s, it will be theirs in %d minutes!",
Points[point][PlayerNameCapping], Points[point][Name], FamilyInfo[fam][FamilyName], Points[point][TakeOverTimer]);
UpdateDynamic3DTextLabelText(Points[point][CaptureProccess], COLOR_YELLOW, string);
}
else
{
Points[point][ClaimerTeam] = INVALID_PLAYER_ID;
Points[point][TakeOverTimer] = 0;
Points[point][TakeOverTimerStarted] = 0;
Points[point][Announced] = 0;
Points[point][Vulnerable] = NEW_VULNERABLE;
DestroyDynamic3DTextLabel(Points[point][CaptureProccess]);
Points[point][CaptureProccessEx] = 0;
strmid(Points[point][Owner], FamilyInfo[fam][FamilyName], 0, 32, 32);
strmid(Points[point][CapperName], Points[point][PlayerNameCapping], 0, 32, 32);
format(string, sizeof(string), "%s has successfully taken control of the %s for %s.", Points[point][CapperName], Points[point][Name], Points[point][Owner]);
SendClientMessageToAll(COLOR_YELLOW, string);
UpdatePoints();
KillTimer(Points[point][CaptureTimerEx2]);
Points[point][CaptureTimerEx2] = -1;
}
}
}
public ProgressTimer(point)
{
if(Points[point][ClaimerId] != INVALID_PLAYER_ID && Points[point][TimeToClaim])
{
Points[point][TimeLeft]--;
SetProgressBarValue(Points[point][PointBarID], GetProgressBarValue(Points[point][PointBarID])-10.0);
UpdateProgressBar(Points[point][PointBarID], Points[point][ClaimerId]);
if(GetProgressBarValue(Points[point][PointBarID]) >= 10) SetTimerEx("ProgressTimer", 1000, 0, "d", point);
new string[128];
if(Points[point][TimeLeft] == 9) Points[point][CaptureProgress] = CreateDynamic3DTextLabel(string, COLOR_RED, Points[point][Pointx], Points[point][Pointy], Points[point][Pointz]+1.0, 10.0);
else if(Points[point][TimeLeft] < 9 && Points[point][TimeLeft] >= 0) UpdateDynamic3DTextLabelText(Points[point][CaptureProgress], COLOR_RED, string);
if(GetProgressBarValue(Points[point][PointBarID]) == 50.0)
{
SetProgressBarColor(Points[point][PointBarID], COLOR_YELLOW);
UpdateProgressBar(Points[point][PointBarID], Points[point][ClaimerId]);
}
else if(GetProgressBarValue(Points[point][PointBarID]) == 20.0)
{
SetProgressBarColor(Points[point][PointBarID], COLOR_RED);
UpdateProgressBar(Points[point][PointBarID], Points[point][ClaimerId]);
}
else if(GetProgressBarValue(Points[point][PointBarID]) <= 0.0 && Points[point][TimeLeft] <= 0)
{
CaptureTimer(point);
Points[point][TimeLeft] = 0;
DestroyProgressBar(Points[point][PointBarID]);
DestroyDynamic3DTextLabel(Points[point][CaptureProgress]);
}
}
else
{
DestroyProgressBar(Points[point][PointBarID]);
DestroyDynamic3DTextLabel(Points[point][CaptureProgress]);
Points[point][ClaimerId] = INVALID_PLAYER_ID;
Points[point][TimeToClaim] = 0;
}
return 1;
}
pawn Код:
public UpdatePoints()
{
new idx;
new File: file2;
while (idx < sizeof(Points))
{
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%f|%f|%f|%d|%d|%s|%s|%s|%d\n",
Points[idx][Pointx],
Points[idx][Pointy],
Points[idx][Pointz],
Points[idx][Type],
Points[idx][Vulnerable],
Points[idx][Owner],
Points[idx][CapperName],
Points[idx][Name],
Points[idx][MatPoint]);
if(idx == 0)
{
file2 = fopen("points.cfg", io_write);
}
else
{
file2 = fopen("points.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}
public LoadPoints()
{
new arrCoords[9][64];
new strFromFile2[256];
new File: file = fopen("points.cfg", io_read);
if (file)
{
new idx;
while (idx < sizeof(Points))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, '|');
Points[idx][Pointx] = floatstr(arrCoords[0]);
Points[idx][Pointy] = floatstr(arrCoords[1]);
Points[idx][Pointz] = floatstr(arrCoords[2]);
Points[idx][Type] = strval(arrCoords[3]);
Points[idx][Vulnerable] = strval(arrCoords[4]);
strmid(Points[idx][Owner], arrCoords[5], 0, strlen(arrCoords[5]), 255);
strmid(Points[idx][CapperName], arrCoords[6], 0, strlen(arrCoords[6]), 255);
strmid(Points[idx][Name], arrCoords[7], 0, strlen(arrCoords[7]), 255);
Points[idx][MatPoint] = strval(arrCoords[8]);
//printf("%s Type:%d Owner:%s",Points[idx][Name],Points[idx][Type],Points[idx][Owner]);
Points[idx][CaptureTimerEx2] = -1;
Points[idx][ClaimerId] = INVALID_PLAYER_ID;
Points[idx][PointPickupID] = CreateDynamicPickup( 1239, 23, Points[idx][Pointx], Points[idx][Pointy], Points[idx][Pointz]);
idx++;
}
fclose(file);
}
return 1;
}
pawn Код:
if(strcmp(cmd,"/claim",true)==0)
{
new mypoint = -1;
if (PlayerInfo[playerid][pFMember] == 255 || PlayerInfo[playerid][pRank] < 5)
{
SendClientMessage(playerid, COLOR_GRAD1, " You are not high rank enough to capture!");
return 1;
}
for (new i=0; i<MAX_POINTS; i++)
{
if (IsPlayerInRangeOfPoint(playerid, 1.0, Points[i][Pointx], Points[i][Pointy], Points[i][Pointz])) mypoint = i;
}
if (mypoint == -1)
{
SendClientMessage(playerid, COLOR_GRAD1, " You are not at the capture place!");
return 1;
}
if (Points[mypoint][Vulnerable] > 0)
{
SendClientMessage(playerid, COLOR_GRAD1, " This point is not ready for takeover.");
return 1;
}
if (Points[mypoint][TimeToClaim])
{
SendClientMessage(playerid, COLOR_GRAD1, " This point is already being captured!");
return 1;
}
if(GetPlayerPing(playerid) > pointpinglimit)
{
format(string,sizeof(string), " You can not capture with %d+ ping!", pointpinglimit);
SendClientMessage(playerid, COLOR_WHITE, string);
return 1;
}
Points[mypoint][PointBarID] = CreateProgressBar(258.00, 137.00, 131.50, 3.19, COLOR_GREEN, 100.0);
SetProgressBarValue(Points[mypoint][PointBarID], 100.0);
ShowProgressBarForPlayer(playerid, Points[mypoint][PointBarID]);
GetPlayerPos(playerid, Points[mypoint][Capturex], Points[mypoint][Capturey], Points[mypoint][Capturez]);
Points[mypoint][ClaimerId] = playerid;
Points[mypoint][TimeToClaim] = 1;
Points[mypoint][TimeLeft] = 10;
SetTimerEx("ProgressTimer", 1000, 0, "d", mypoint);
return 1;
}
pawn Код:
if(strcmp(cmd,"/points",true)==0)
{
for(new i; i < MAX_POINTS; i++)
{
if (Points[i][Type] >= 0)
{
format(string, sizeof(string), "Name: %s | Owner: %s | Captured By: %s | Hours: %d",
Points[i][Name],Points[i][Owner],Points[i][CapperName],Points[i][Vulnerable]);
SendClientMessage(playerid, COLOR_WHITE, string);
}
}
return 1;
}
and it not wrong,i mean the points.cfg,but when i do /points ig it shows:

and i cant claim at the entrance in points.cfg