03.07.2017, 04:39
Opa por que q meu sistema de RECORD de jogadores nгo esta lendo o arquivo dos RECORDS ele diz la no jogo EX:
RECORD:30 ai ele seta na pasta 30 certinho soq quando renincia o servidor ele zera , e nгo le o TXT
#include <a_samp>
#include <foreach>
#define TDSFP TextDrawShowForPlayer
//================================New's============= ============================
new onlinepl, postojecirekord, Text:OnlineRecord;
//================================================== ============================
public OnFilterScriptInit()
{
DosadasnjiRekord();
onlinepl=Konektovano();
OnlineRecord = TextDrawCreate(495.000000,101.000000,"~y~Online agora:~w~ ~n~~y~Recorde:~w~ ");
TextDrawAlignment(OnlineRecord,0);
TextDrawBackgroundColor(OnlineRecord,0);
TextDrawFont(OnlineRecord,2);
TextDrawLetterSize(OnlineRecord,0.299999,1.000000) ;
TextDrawColor(OnlineRecord,0xffffffff);
TextDrawSetProportional(OnlineRecord,1);
TextDrawSetShadow(OnlineRecord,0);
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
SacuvajRekord();
SetTimerEx("RekordTimer", 3000, false, "d", playerid);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
onlinepl--;
return 1;
}
public OnPlayerSpawn(playerid)
{
new string1[512];
format(string1, 512, "~y~Online agora:~w~ %d~n~~y~Recorde:~w~ %d", Konektovano(), postojecirekord);
TextDrawSetString(OnlineRecord, string1);
TDSFP(playerid, OnlineRecord);
return 1;
}
///////////////////////////////////////////////////////////////////////////
forward DosadasnjiRekord();
public DosadasnjiRekord()
{
new strFromFile[24], arrCoords[6][5], File: file = fopen("rekord.txt", io_read);
if (file)
{
fread(file, strFromFile);
razdvoji(strFromFile, arrCoords, ',');
postojecirekord = strval(arrCoords[0]);
fclose(file);
}
return 1;
}
forward SacuvajRekord();
public SacuvajRekord()
{
new coordsstring[24];
format(coordsstring, sizeof(coordsstring), "%d", postojecirekord);
new File: file = fopen("rekord.txt", io_write);
fwrite(file, coordsstring);
fclose(file);
return 1;
}
forward RekordTimer(playerid);
public RekordTimer(playerid)
{
if(postojecirekord)
{
new string1[512];
format(string1, 512, "~y~Online agora:~w~ %d~n~~y~Recorde:~w~ %d", Konektovano(), postojecirekord);
TextDrawSetString(OnlineRecord, string1);
}
onlinepl++;
if(postojecirekord < onlinepl)
{
postojecirekord=onlinepl;
new string[128], string1[512];
format(string, sizeof(string), "Novi rekord igraca je: %d", postojecirekord);
SendClientMessageToAll(0xFCB833FF, string);
SacuvajRekord();
format(string1, 512, "~y~Online agora:~w~ %d~n~~y~Recorde:~w~ %d", Konektovano(), postojecirekord);
TextDrawSetString(OnlineRecord, string1);
}
return 1;
}
stock razdvoji(const strsrc[], strdest[][], delimiter)
{
new i, li;
new aNum;
new len;
while(i <= strlen(strsrc))
{
if(strsrc[i] == delimiter || i == strlen(strsrc))
{
len = strmid(strdest[aNum], strsrc, li, i, 12;
strdest[aNum][len] = 0;
li = i+1;
aNum++;
}
i++;
}
return 1;
}
forward Konektovano();
public Konektovano()
{
new Connected;
for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && !IsPlayerNPC(i)) Connected++;
return Connected;
}
RECORD:30 ai ele seta na pasta 30 certinho soq quando renincia o servidor ele zera , e nгo le o TXT
#include <a_samp>
#include <foreach>
#define TDSFP TextDrawShowForPlayer
//================================New's============= ============================
new onlinepl, postojecirekord, Text:OnlineRecord;
//================================================== ============================
public OnFilterScriptInit()
{
DosadasnjiRekord();
onlinepl=Konektovano();
OnlineRecord = TextDrawCreate(495.000000,101.000000,"~y~Online agora:~w~ ~n~~y~Recorde:~w~ ");
TextDrawAlignment(OnlineRecord,0);
TextDrawBackgroundColor(OnlineRecord,0);
TextDrawFont(OnlineRecord,2);
TextDrawLetterSize(OnlineRecord,0.299999,1.000000) ;
TextDrawColor(OnlineRecord,0xffffffff);
TextDrawSetProportional(OnlineRecord,1);
TextDrawSetShadow(OnlineRecord,0);
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
SacuvajRekord();
SetTimerEx("RekordTimer", 3000, false, "d", playerid);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
onlinepl--;
return 1;
}
public OnPlayerSpawn(playerid)
{
new string1[512];
format(string1, 512, "~y~Online agora:~w~ %d~n~~y~Recorde:~w~ %d", Konektovano(), postojecirekord);
TextDrawSetString(OnlineRecord, string1);
TDSFP(playerid, OnlineRecord);
return 1;
}
///////////////////////////////////////////////////////////////////////////
forward DosadasnjiRekord();
public DosadasnjiRekord()
{
new strFromFile[24], arrCoords[6][5], File: file = fopen("rekord.txt", io_read);
if (file)
{
fread(file, strFromFile);
razdvoji(strFromFile, arrCoords, ',');
postojecirekord = strval(arrCoords[0]);
fclose(file);
}
return 1;
}
forward SacuvajRekord();
public SacuvajRekord()
{
new coordsstring[24];
format(coordsstring, sizeof(coordsstring), "%d", postojecirekord);
new File: file = fopen("rekord.txt", io_write);
fwrite(file, coordsstring);
fclose(file);
return 1;
}
forward RekordTimer(playerid);
public RekordTimer(playerid)
{
if(postojecirekord)
{
new string1[512];
format(string1, 512, "~y~Online agora:~w~ %d~n~~y~Recorde:~w~ %d", Konektovano(), postojecirekord);
TextDrawSetString(OnlineRecord, string1);
}
onlinepl++;
if(postojecirekord < onlinepl)
{
postojecirekord=onlinepl;
new string[128], string1[512];
format(string, sizeof(string), "Novi rekord igraca je: %d", postojecirekord);
SendClientMessageToAll(0xFCB833FF, string);
SacuvajRekord();
format(string1, 512, "~y~Online agora:~w~ %d~n~~y~Recorde:~w~ %d", Konektovano(), postojecirekord);
TextDrawSetString(OnlineRecord, string1);
}
return 1;
}
stock razdvoji(const strsrc[], strdest[][], delimiter)
{
new i, li;
new aNum;
new len;
while(i <= strlen(strsrc))
{
if(strsrc[i] == delimiter || i == strlen(strsrc))
{
len = strmid(strdest[aNum], strsrc, li, i, 12;
strdest[aNum][len] = 0;
li = i+1;
aNum++;
}
i++;
}
return 1;
}
forward Konektovano();
public Konektovano()
{
new Connected;
for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && !IsPlayerNPC(i)) Connected++;
return Connected;
}