Will This Make An Infinite Loop?
#1

Will These Codes From PPC_House Make Infinite Loop?

pawn Код:
HouseFile_Load(HouseID)
{
    // Setup local variables
    new file[100], File:HFile, LineFromFile[100], ParameterName[50], ParameterValue[50];

    // Construct the complete filename for this house-file
    format(file, sizeof(file), HouseFile, HouseID);

    // Check if the HouseFile exists
    if (fexist(file))
    {
        // Open the housefile for reading
        HFile = fopen(file, io_read);
        // Read the first line of the file
        fread(HFile, LineFromFile);

        // Keep reading until the end of the file is found (no more data)
        // An empty line between data-segments still has the NewLine characters (\r\n) so it's not completely empty
        // Reading past the last line will read a completely empty line, therefore indicating the end of the file
        while (strlen(LineFromFile) > 0)
        {
            StripNewLine(LineFromFile); // Strip any newline characters from the LineFromFile
            sscanf(LineFromFile, "s[50]s[50]", ParameterName, ParameterValue); // Extract parametername and parametervalue

            // Check if there is anything in the LineFromFile (skipping empty lines)
            if (strlen(LineFromFile) > 0)
            {
                // Store the proper value in the proper place
                if (strcmp(ParameterName, "Owned", false) == 0) // If the parametername is correct ("Owned")
                {
                    if (strcmp(ParameterValue, "Yes", false) == 0) // If the value "Yes" was read
                        AHouseData[HouseID][Owned] = true; // House is owned
                    else
                        AHouseData[HouseID][Owned] = false; // House is not owned
                }
                if (strcmp(ParameterName, "Owner", false) == 0) // If the parametername is correct ("Owner")
                    // Store the Owner (Owner will hold "1" if there is no owner (empty string), done by "sscanf" I guess)
                    // But this doesn't matter, as the owner will never be displayed when the house is not owned by someone
                    format(AHouseData[HouseID][Owner], 24, ParameterValue);

                if (strcmp(ParameterName, "HouseName", false) == 0) // If the parametername is correct ("HouseName")
                    format(AHouseData[HouseID][HouseName], 24, ParameterValue); // Store the HouseName
                if (strcmp(ParameterName, "HouseX", false) == 0) // If the parametername is correct ("HouseX")
                    AHouseData[HouseID][HouseX] = floatstr(ParameterValue); // Store the HouseX
                if (strcmp(ParameterName, "HouseY", false) == 0) // If the parametername is correct ("HouseY")
                    AHouseData[HouseID][HouseY] = floatstr(ParameterValue); // Store the HouseY
                if (strcmp(ParameterName, "HouseZ", false) == 0) // If the parametername is correct ("HouseZ")
                    AHouseData[HouseID][HouseZ] = floatstr(ParameterValue); // Store the HouseZ
                if (strcmp(ParameterName, "HouseLevel", false) == 0) // If the parametername is correct ("HouseLevel")
                    AHouseData[HouseID][HouseLevel] = strval(ParameterValue); // Store the HouseLevel
                if (strcmp(ParameterName, "HouseMaxLevel", false) == 0) // If the parametername is correct ("HouseMaxLevel")
                    AHouseData[HouseID][HouseMaxLevel] = strval(ParameterValue); // Store the HouseMaxLevel
                if (strcmp(ParameterName, "HousePrice", false) == 0) // If the parametername is correct ("HousePrice")
                    AHouseData[HouseID][HousePrice] = strval(ParameterValue); // Store the HousePrice
                if (strcmp(ParameterName, "HouseOpened", false) == 0) // If the parametername is correct ("HouseOpened")
                {
                    if (strcmp(ParameterValue, "Yes", false) == 0) // If the value "Yes" was read
                        AHouseData[HouseID][HouseOpened] = true; // House is open to the public (anyone can enter)
                    else
                        AHouseData[HouseID][HouseOpened] = false; // House is closed to the public, only house-owner can enter
                }
                if (strcmp(ParameterName, "Insurance", false) == 0) // If the parametername is correct ("Insurance")
                {
                    if (strcmp(ParameterValue, "Yes", false) == 0) // If the value "Yes" was read
                        AHouseData[HouseID][Insurance] = true; // House has insurance for it's vehicles
                    else
                        AHouseData[HouseID][Insurance] = false; // House doesn't have insurance
                }

                if (strcmp(ParameterName, "StaticHouse", false) == 0) // If the parametername is correct ("StaticHouse")
                {
                    if (strcmp(ParameterValue, "Yes", false) == 0) // If the value "Yes" was read
                        AHouseData[HouseID][StaticHouse] = true; // House is static (not upgradable, fixed interior and carslots)
                    else
                        AHouseData[HouseID][StaticHouse] = false; // House isn't static (upgradable, interior and carslots based on HouseLevel)
                }
                if (strcmp(ParameterName, "CarSlots", false) == 0) // If the parametername is correct ("CarSlots")
                    AHouseData[HouseID][CarSlots] = strval(ParameterValue); // Store the CarSlots
            }

            // Read the next line of the file
            fread(HFile, LineFromFile);
        }

        // Close the file
        fclose(HFile);

        // Add a pickup and 3DText for this house
        House_UpdateEntrance(HouseID);
        // Count the amount of houses that are loaded
        TotalHouses++;

        // Return if the file was read correctly
        return 1;
    }
    else
        return 0; // Return 0 if the file couldn't be read (doesn't exist)
}
Reply
#2

If you want a infinite loop. See this.
Код:
for(;;)
{
your code here
}
Reply
#3

i am just checking my server why its freezing when player connects,and i found that infinite loop is the problem,so i am trying to delete it.
Reply
#4

What is the exact error when you log in ?
Reply
#5

often,when someone joins the server,server gets freezed,and no one can perform and command or text or anything,so these the codes while connecting in my server:

From My GM:

pawn Код:
#define DIALOG_RULES2 12
#define savefolder "/Accounts/%s.ini" // This defines the file name and folder
public OnPlayerConnect(playerid)
{
    new string[64], pName2[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName2,MAX_PLAYER_NAME);
    format(string,sizeof string,"%s (%d) Has Joined The Server.",pName2,playerid);
    GameTextForPlayer(playerid, "Welcome To The Los Santos Gang War Server", 5000, 4);
    ShowPlayerDialog(playerid, DIALOG_RULES2, DIALOG_STYLE_MSGBOX, "Server Rules", "1- No Cheating\n2- No Spamming\n3- Slide Bug Is Not Allowed But C Bug Is Allowed\n4- No Rule Breaking\n5- No G Abuse\n6- No Advertising\n7- Teleport Abuse Is Not Allowed\n8- Weapon Mods Are Allowed Only\n9- Respect Player Especially Admins\n10- Scamming Is Not Allowed\n11- Aimbot Is Not Allowed\n12- Don't Try To Climb Up Over The Freeroam Walls If You Are(not) In Freeroam Mod\n\nDo You Agree The Server Rules?", "Yes", "No");
    SendClientMessageToAll(0xAFAFAFAA,string);
    SendClientMessage(playerid,-1,"Welcome To The {FFEA00}LOS SANTOS GANG WARS{FFFFFF} Version 2.2! Please Enjoy Your Stay.");
    SendClientMessage(playerid,-1,"You Can Listen,Save,Stop,Check Your Favourite Song Or Unsave Your Song By Some Commands For It In /cmds");
    SendClientMessage(playerid, 0x00EEFFFF, "Please Visit Our Forums: lsgangwars.createaforum.com");
    SendClientMessage(playerid, 0x00FF22FF, "When You Spawn A Skin Type /help To See The Help Menu.");
    new pname[128];  // This get's the length of the player name
    new file[128];        // This get's the lenght of the file
    GetPlayerName(playerid, pname, sizeof(pname)); // This get's the player name with the lenght of the player name
    format(file, sizeof(file), savefolder,pname); // This describe's where to save and how to save it
    if(dini_Exists(file)) { // If the file exist
        SetPlayerScore(playerid, dini_Int(file, "Score"));
        SetPlayerMoney(playerid, dini_Int(file, "Money"));
        LPinfo[playerid][Drugs] = dini_Int(file,"Drugs");
        LPinfo[playerid][Adre] = dini_Int(file,"Adrenaline Pills");
        BankMoney[playerid] = dini_Int(file,"BankMoney");
        Favouritesong[playerid] = dini_Int(file,"SongID");
    }
    else {
        dini_Create(file); // Create the file
        dini_IntSet(file, "Score", 0); // Set's "Score"
        dini_IntSet(file, "Money", 0); // Set's "Money"
        dini_IntSet(file, "Drugs", LPinfo[playerid][Drugs]); // Set's "Kills"
        dini_IntSet(file, "Adrenaline Pills", LPinfo[playerid][Adre]); // Set's "Kills"
        dini_IntSet(file, "BankMoney", BankMoney[playerid]); // Set's "Kills"
        dini_IntSet(file, "SongID", Favouritesong[playerid]); // Set's "Kills"
        SetPlayerScore(playerid, dini_Int(file, "Score")); // This describes where to load the score
        SetPlayerMoney(playerid, dini_Int(file, "Money")); // This describes where to load the money
        // the same thing
    } // This get's the length of the player name
    pInfo[playerid][Last] = -1;
    pInfo[playerid][NoPM] = 0;
    PlayerCar[playerid] = -1;
    AntiKillRowSpam[playerid] = 0;
    PlayAudioStreamForPlayer(playerid, "http://s3.argim.net/files/r/gta_san_andreas_theme_song_wmm.mp3");
    return 1;
}
Codes From PPC_House:
pawn Код:
public OnPlayerConnect(playerid)
{
    // Setup local variables
    new HouseID, HouseSlot, Name[24];

    // Get the player's name
    GetPlayerName(playerid, Name, sizeof(Name));

    // Loop through all houses to find the ones which belong to this player
    for (HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
    {
        // Check if the house exists
        if (IsValidDynamicPickup(AHouseData[HouseID][PickupID]))
        {
            // Check if the house is owned
            if (AHouseData[HouseID][Owned] == true)
            {
                // Check if the player is the owner of the house
                if (strcmp(AHouseData[HouseID][Owner], Name, false) == 0)
                {
                    // Add the HouseID to the player's account for faster reference later on
                    APlayerData[playerid][Houses][HouseSlot] = HouseID;

                    // Load housecars if they weren't loaded at FilterscriptInit
                    if (LoadCarsDuringFSInit == false)
                        HouseFile_LoadCars(HouseID);

                    // Select the next HouseSlot
                    HouseSlot++;
                }
            }
        }
    }

    return 1;
}
Codes From LuxAdmin:
pawn Код:
public OnPlayerConnect(playerid)
{
    AccInfo[playerid][Deaths]       = 0;
    AccInfo[playerid][Kills]        = 0;
    AccInfo[playerid][Jailed]       = 0;
    AccInfo[playerid][Frozen]       = 0;
    AccInfo[playerid][Level]        = 0;
    AccInfo[playerid][pVip]         = 0;
    AccInfo[playerid][LoggedIn]     = 0;
    AccInfo[playerid][Registered]   = 0;
    AccInfo[playerid][God]          = 0;
    AccInfo[playerid][GodCar]       = 0;
    AccInfo[playerid][TimesSpawned] = 0;
    AccInfo[playerid][Muted]        = 0;
    AccInfo[playerid][MuteWarnings] = 0;
    AccInfo[playerid][Warnings]     = 0;
    AccInfo[playerid][Caps]         = 0;
    AccInfo[playerid][DoorsLocked]  = 0;
    AccInfo[playerid][pCar]         = -1;
    AccInfo[playerid][SpamCount]    = 0;
    AccInfo[playerid][MaxAdv]       = 0;
    AccInfo[playerid][SpamTime]     = 0;
    AccInfo[playerid][PingCount]    = 0;
    AccInfo[playerid][PingTime]     = 0;
    AccInfo[playerid][FailLogin]    = 0;
    AccInfo[playerid][Hide]         = 0;
    AccInfo[playerid][pInvis]       = 0;
    AccInfo[playerid][pGps]         = -1;

    #if EnableTwoRcon == true
    AccInfo[playerid][MaxRcon] = 0;
    #endif

    AccInfo[playerid][ConnectTime] = gettime();
    for(new i; i<PING_MAX_EXCEEDS; i++)
    AccInfo[playerid][pPing][i] = 0;
    //------------------------------------------------------
    new string[128];
    new str[128];
    new file[256];
    new PlayerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
    new tmp3[50]; GetPlayerIp(playerid,tmp3,50);

    ResetForbiddenWeaponsForPlayer(playerid);
    TempBanCheck(playerid);
//==============================================================================
// Connect Messages
//==============================================================================
    if(ServerInfo[ConnectMessages] == 1)
    {
        new pAKA[256];
        pAKA = dini_Get("LuxAdmin/Config/aka.txt",tmp3);
        if (strlen(pAKA) < 3)
        format(str,sizeof(str),"* Player %s (Id:%d) has joined the server", PlayerName,playerid);
        else if (!strcmp(pAKA,PlayerName,true))
        format(str,sizeof(str),"* Player %s (Id:%d) has joined the server", PlayerName,playerid);
        else format(str,sizeof(str),"Player %s (Id:%d) has joined the server (Aka: %s)",PlayerName,playerid,pAKA);

        for(new i = 0; i < MAX_PLAYERS; i++)
        if(IsPlayerConnected(i) && playerid != i)
        {
        if(AccInfo[i][Level] > 2)
        SendClientMessage(i,grey,str);
        else
        {
        format(string,sizeof(string),"* Player %s (Id:%d) has joined the server", PlayerName, playerid);
        SendClientMessage(i,grey,string);
        }
        }
    }
//==============================================================================
// If PlayerName is Banned
//==============================================================================
    if (dUserINT(PlayerName2(playerid)).("Banned") == 1)
    {
        SendClientMessage(playerid, red, "ATTENTION: This name is banned from this server!");
        format(string,sizeof(string),"|- Player %s (Id:%d) has been Automatically  Kicked. | Reason: Name Banned! -|",PlayerName,playerid);
        SendClientMessageToAll(red, string);  print(string);
        SaveIn("KickLog",string);  Kick(playerid);
    }
//==============================================================================
// Kick Forbidden Name
//==============================================================================
    if(ServerInfo[NameKick] == 1)
    {
        for(new s = 0; s < BlockedNamesCount; s++)
        {
            if(!strcmp(BlockedNames[s],PlayerName,true))
            {
            SendClientMessage(playerid,red, "ATTENTION: Your name is on our Black List, you have been Kicked.");
            format(string,sizeof(string),"|- Player %s (Id:%d) has been Automatically Kicked. | Reason: Forbidden Name -|",PlayerName,playerid);
            SendClientMessageToAll(red, string);
            print(string);
            SaveIn("KickLog",string);
            Kick(playerid);
            return 1;
            }
        }
    }
//==============================================================================
// Kick Forbidden Part of Name
//==============================================================================
    if(ServerInfo[PartNameKick] == 1)
    {
        for(new s = 0; s < BlockedPartNameCount; s++)
        {
            new pos;
            while((pos = strfind(PlayerName,BlockedPartName[s],true)) != -1)
            for(new i = pos, j = pos + strlen(BlockedPartName[s]); i < j; i++)
            {
            SendClientMessage(playerid,red, "ATTENTION: Your name is not Allowed on this server, you have been Kicked!.");
            format(string,sizeof(string),"|- Player %s (Id:%d) has been Automatically Kicked. | Reason: Forbidden Name -|",PlayerName,playerid);
            SendClientMessageToAll(red, string);  print(string);
            SaveIn("KickLog",string);  Kick(playerid);
            return 1;
            }
        }
    }
//==============================================================================
// Server Locked
//==============================================================================
    if(ServerInfo[Locked] == 1)
    {
        AccInfo[playerid][AllowedIn] = false;
        SendClientMessage(playerid,red,"|- Server is Locked! -|");
        SendClientMessage(playerid,red,"|- You have 40 seconds to enter the server Password! -|");
        LockKickTimer[playerid] = SetTimerEx("AutoKick", 40000, 0, "i", playerid);
    }
    if (ServerInfo[Locked] == 1 && AccInfo[playerid][AllowedIn] == false)
    {
        ShowPlayerDialog(playerid, DIALOG_TYPE_SERVPASS, DIALOG_STYLE_INPUT,
        "Server Locked!.", "Enter the password to Access it:", "Access", "Exit");
    }
//==============================================================================
// Register & Login
//==============================================================================
    if(strlen(dini_Get("LuxAdmin/Config/aka.txt", tmp3)) == 0)
    dini_Set("LuxAdmin/Config/aka.txt", tmp3, PlayerName);
    else
    {
        if( strfind( dini_Get("LuxAdmin/Config/aka.txt", tmp3), PlayerName, true) == -1 )
        {
        format(string,sizeof(string),"%s,%s", dini_Get("LuxAdmin/Config/aka.txt",tmp3), PlayerName);
        dini_Set("LuxAdmin/Config/aka.txt", tmp3, string);
        }
    }
    if(!udb_Exists(PlayerName2(playerid)))
    SendClientMessage(playerid,orange, "SERVER: Your account isn't registered. Please register (/"#RegisterCommand" [Password])");
    else
    {
    AccInfo[playerid][Registered] = 1;
    format(file,sizeof(file),"/LuxAdmin/Accounts/%s.sav",udb_encode(PlayerName));
    new tmp2[256]; tmp2 = dini_Get(file,"Ip");

    if( (!strcmp(tmp3,tmp2,true)) && (ServerInfo[AutoLogin] == 1))
    {
        LoginPlayer(playerid);
        if(AccInfo[playerid][Level] > 0)
        {
            switch(AccInfo[playerid][Level])
            {
                case 1: AdmRank = "Basic Moderator";
                case 2: AdmRank = "Moderator";
                case 3: AdmRank = "Master Moderator";
                case 4: AdmRank = "Administrator";
                case 5: AdmRank = "Master Administrator";
                case 6: AdmRank = "Professional Admin";
                case 7: AdmRank = "Trusted Admin";
                case 8: AdmRank = "Perfect Admin";
                case 9: AdmRank = "Co-Owner";
                case 10: AdmRank = "Owner";
            }

//==============================================================================
// VIP System
//==============================================================================
            if(AccInfo[playerid][pVip] > 0)
            {
                switch(AccInfo[playerid][pVip])
                {
                    case 1: AccType = "Silver";
                    case 2: AccType = "Gold";
                    case 3: AccType = "Premium";
                }
                format(string,sizeof(string),"|- You have been Automatically Logged in | Account: %s | Level %d - %s -|", AccType, AccInfo[playerid][Level],AdmRank);
                SendClientMessage(playerid,0x00C378AA,string);
            }
            else
            {
                format(string,sizeof(string),"|- You have been Automatically Logged in | Level %d - %s -|", AccInfo[playerid][Level],AdmRank);
                SendClientMessage(playerid,green,string);
            }
//==============================================================================
        }
        else
        {
            if(AccInfo[playerid][pVip] > 0)
            {
                switch(AccInfo[playerid][pVip])
                {
                    case 1: AccType = "Silver";
                    case 2: AccType = "Gold";
                    case 3: AccType = "Premium";
                }
                format(string,sizeof(string),"|- You have been Automatically Logged in - Account Type: %s", AccType);
                SendClientMessage(playerid,0x00C896AA,string);
            }
            else
            {
                format(string,sizeof(string),"|- You have been Automatically Logged in");
                SendClientMessage(playerid,green,string);
            }
        }
    }
    else SendClientMessage(playerid, white, "That account is registered!") &&
    SendClientMessage(playerid, orange, "Please login to access your Account (/"#LoginCommand" [Password])");
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)