problem with fexist
#1

Hi guys

I have a problem, I started making my new filterscript, race system, now, in my /buildrace command I made a check if file of choose race already exist but it doesn't works, take a look on code

command:
pawn Код:
YCMD:buildrace(playerid, params[], help)
{
    #pragma unused help
    new name[50], rFile[128];
    if(PlayerStartedBuildingRace[playerid] == true) return SendClientMessage(playerid, -1, "{F81414}> {FFFFFF}You allready started building race!");
    if(sscanf(params, "s[128]", name)) return SendClientMessage(playerid, -1, "{F81414}< {FFFFFF}Usage: /buildrace [Name] {F81414}>");
    format(string, sizeof(string), "S32_Race/%s.ini", name);
    if(fexist(string)) return SendClientMessage(playerid, -1, "{F81414}> {FFFFFF}Race with that name already exist!");
    format(rFile, sizeof(rFile), "S32_Race/%s.ini", name);
    new INI: RaceFile = INI_Open(rFile);
    INI_WriteString(RaceFile, "Name", name);
    INI_WriteInt(RaceFile, "Type", 0);
    INI_WriteInt(RaceFile, "Laps", 1);
    INI_WriteFloat(RaceFile, "CP Size", 1.0);
    INI_WriteInt(RaceFile, "Vehicle Model", 0);
    INI_Close(RaceFile);
   
    SendClientMessage(playerid, -1, "{B7FF00}> {FFFFFF}You started building race! {B7FF00}<");
   
    PlayerStartedBuildingRace[playerid] = true;
    return 1;
}
check:
pawn Код:
format(string, sizeof(string), "S32_Race/%s.ini", name);
    if(fexist(string)) return SendClientMessage(playerid, -1, "{F81414}> {FFFFFF}Race with that name already exist!");
Reply
#2

pawn Код:
YCMD:buildrace(playerid, params[], help)
{
    #pragma unused help
    new name[50], rFile[128];
    if(PlayerStartedBuildingRace[playerid] == true) return SendClientMessage(playerid, -1, "{F81414}> {FFFFFF}You allready started building race!");
    if(sscanf(params, "s[128]", name)) return SendClientMessage(playerid, -1, "{F81414}< {FFFFFF}Usage: /buildrace [Name] {F81414}>");
    format(string, sizeof(string), "S32_Race/%s.ini", name);
    if(fexist(string)) return SendClientMessage(playerid, -1, "{F81414}> {FFFFFF}Race with that name already exist!");
    else
    {
         format(rFile, sizeof(rFile), "S32_Race/%s.ini", name);
         new INI: RaceFile = INI_Open(rFile);
         INI_WriteString(RaceFile, "Name", name);
         INI_WriteInt(RaceFile, "Type", 0);
         INI_WriteInt(RaceFile, "Laps", 1);
         INI_WriteFloat(RaceFile, "CP Size", 1.0);
         INI_WriteInt(RaceFile, "Vehicle Model", 0);
         INI_Close(RaceFile);
    }
   
    SendClientMessage(playerid, -1, "{B7FF00}> {FFFFFF}You started building race! {B7FF00}<");
   
    PlayerStartedBuildingRace[playerid] = true;
    return 1;
}
Untested
Reply
#3

thanks for help but fuck ini, MySQL ftw!!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)