04.06.2012, 16:07
I appreciate the help 3ventric, but I don't think I need any includes, as the source of the script is https://sampwiki.blast.hk/wiki/File_Functions, and it doesn't state I need any includes.
Despite adding in that code, making the script:
It still returns a few errors
Despite adding in that code, making the script:
Код:
#include <a_samp>
#include <
new PKills[MAX_PLAYERS]; // Kill Tracker
new PDeaths[MAX_PLAYERS]; // Death tracker
#define FILE_NAME "stats.txt" // The name of the file
new File:gstats; // The file
new string[256];
new pname[24];
new str[256];
forward fcreate(filename[]);
forward equal(var1, var2, match);
public fcreate(filename[])
{
if (fexist(filename)){return false;}
new File:fhandle = fopen(filename,io_write);
fclose(fhandle);
return true;
}
fdeleteline(filename[], line[]){
if(fexist(filename)){
new temp[256];
new File:fhandle = fopen(filename,io_read);
fread(fhandle,temp,sizeof(temp),false);
if(strfind(temp,line,true)==-1){return 0;}
else{
fclose(fhandle);
fremove(filename);
for(new i=0;i<strlen(temp);i++){
new templine[256];
strmid(templine,temp,i,i+strlen(line));
if(equal(templine,line,true)){
strdel(temp,i,i+strlen(line));
fcreate(filename);
fhandle = fopen(filename,io_write);
fwrite(fhandle,temp);
fclose(fhandle);
return 1;
}
}
}
}
return 0;
}
public equal(var1, var2, match)
{
if((var1 == var2 && match) || (var1 != var2 && !match)){
return true;
}else {
return false;
}
}
public OnPlayerConnect(playerid)
{
if(!gstats)// Our check
{
fcreate(FILE_NAME);
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
SaveStats(playerid, d, k)
{
gstats=fopen(FILE_NAME, io_append);
GetPlayerName(playerid, pname, 24); // The name of the player
format(str, sizeof(str), "%s %d %d\n\r",pname, k, d); // format
while(fread(gstats, string))
{
if(strcmp(string, pname, false, strlen(pname))==0)
{ // To check if the players name is in the file
fdeleteline(FILE_NAME, string); // delete the line
fwrite(gstats, str); // write the string
}
}
fclose(gstats);
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/stats", cmdtext, true, 10) == 0)
{
ReadStats(playerid) {
gstats=fopen(FILE_NAME, io_read);
GetPlayerName(playerid, pname, 24);
while(fread(gstats, string)) {
if(strcmp(str, pname, false, strlen(pname))==0) {
PKills[playerid]=GetVal(1, str);
PDeaths[playerid]=GetVal(2, str);
}
}
fclose(gstats);
}
new Float:ratio=floatdiv(PKills[playerid], PDeaths[playerid]);
format(str, 256, "%d %d %.2f", PKills[playerid], PDeaths[playerid], ratio);
return 1;
}
return 0;
}
Код:
SAMP S3RV\filterscripts\stats.pwn(33) : error 035: argument type mismatch (argument 1) SAMP S3RV\filterscripts\stats.pwn(67) : error 017: undefined symbol "SaveStats" SAMP S3RV\filterscripts\stats.pwn(68) : warning 217: loose indentation SAMP S3RV\filterscripts\stats.pwn(71) : error 017: undefined symbol "k" SAMP S3RV\filterscripts\stats.pwn(83) : warning 217: loose indentation SAMP S3RV\filterscripts\stats.pwn(90) : error 017: undefined symbol "ReadStats" SAMP S3RV\filterscripts\stats.pwn(95) : error 017: undefined symbol "GetVal" SAMP S3RV\filterscripts\stats.pwn(96) : error 017: undefined symbol "GetVal" SAMP S3RV\filterscripts\stats.pwn(99) : warning 217: loose indentation Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 6 Errors.

