[warning] client exceeded 'ackslimit' IP (4323) limit: 3000/sec
#2

Quote:
Originally Posted by MayaEU
Посмотреть сообщение
Why is this command making my game freeze?

pawn Код:
if (strcmp(cmd, "/checkcars", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if (PlayerInfo[playerid][pAdmin] & ADMIN_LOWLEVEL)
            {
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_GRAD1, ""COL_SZR"Usage:"COL_WHITE" /checkcars [playerid/PartOfName]");
                    return 1;
                }
                //giveplayerid = strval(tmp);
                giveplayerid = ReturnUser(tmp);
                if(IsPlayerConnected(giveplayerid))
                {
                    if(giveplayerid != INVALID_PLAYER_ID)
                    {
                        for (new i = 0; i < sizeof(CarInfo); i++) {
                            if (PlayerInfo[giveplayerid][pCarkey] == SCRIPT_CARS)
                            if (PlayerInfo[giveplayerid][pCarkey2] == SCRIPT_CARS)
                            if (PlayerInfo[giveplayerid][pCarkey3] == SCRIPT_CARS)
                            if (PlayerInfo[giveplayerid][pCarkey4] == SCRIPT_CARS)
                            if (PlayerInfo[giveplayerid][pCarkey5] == SCRIPT_CARS) {
                                SendClientMessage(playerid, COLOR_GREY, "No vehicles found.");
                                return 1;
                            }

                            new carkey = PlayerInfo[giveplayerid][pCarkey],
                                carkey2 = PlayerInfo[giveplayerid][pCarkey2],
                                carkey3 = PlayerInfo[giveplayerid][pCarkey3],
                                carkey4 = PlayerInfo[giveplayerid][pCarkey4],
                                carkey5 = PlayerInfo[giveplayerid][pCarkey5];

                            if (PlayerInfo[giveplayerid][pCarkey] != SCRIPT_CARS) {
                                format(string, sizeof(string), ""COL_GREY"1. {FF6347}%s"COL_GREY"  Value[%d]  Dest[%d]  Insure[%d]  Plate[%s]  Impounded[%d]  Impound Price[%d]", CarInfo[carkey][cDescription], CarInfo[carkey][cValue], CarInfo[carkey][cDestroys], CarInfo[carkey][cInsure], CarInfo[carkey][cPlate], CarInfo[carkey][cImpounded], CarInfo[carkey][cImpoundedPrice]);
                                SendClientMessage(playerid, COLOR_GREY, string);
                            }
                            if (PlayerInfo[giveplayerid][pCarkey2] != SCRIPT_CARS) {
                                format(string, sizeof(string), ""COL_GREY"2. {FF6347}%s"COL_GREY"  Value[%d]  Dest[%d]  Insure[%d]  Plate[%s]  Impounded[%d]  Impound Price[%d]", CarInfo[carkey2][cDescription], CarInfo[carkey2][cValue], CarInfo[carkey2][cDestroys], CarInfo[carkey2][cInsure], CarInfo[carkey2][cPlate], CarInfo[carkey2][cImpounded], CarInfo[carkey2][cImpoundedPrice]);
                                SendClientMessage(playerid, COLOR_GREY, string);
                            }
                            if (PlayerInfo[giveplayerid][pCarkey3] != SCRIPT_CARS) {
                                format(string, sizeof(string), ""COL_GREY"3. {FF6347}%s"COL_GREY"  Value[%d]  Dest[%d]  Insure[%d]  Plate[%s]  Impounded[%d]  Impound Price[%d]", CarInfo[carkey3][cDescription], CarInfo[carkey3][cValue], CarInfo[carkey3][cDestroys], CarInfo[carkey3][cInsure], CarInfo[carkey3][cPlate], CarInfo[carkey3][cImpounded], CarInfo[carkey3][cImpoundedPrice]);
                                SendClientMessage(playerid, COLOR_GREY, string);
                            }
                            if (PlayerInfo[giveplayerid][pCarkey4] != SCRIPT_CARS) {
                                format(string, sizeof(string), ""COL_GREY"4. {FF6347}%s"COL_GREY"  Value[%d]  Dest[%d]  Insure[%d]  Plate[%s]  Impounded[%d]  Impound Price[%d]", CarInfo[carkey4][cDescription], CarInfo[carkey4][cValue], CarInfo[carkey4][cDestroys], CarInfo[carkey4][cInsure], CarInfo[carkey4][cPlate], CarInfo[carkey4][cImpounded], CarInfo[carkey4][cImpoundedPrice]);
                                SendClientMessage(playerid, COLOR_GREY, string);
                            }
                            if (PlayerInfo[giveplayerid][pCarkey5] != SCRIPT_CARS) {
                                format(string, sizeof(string), ""COL_GREY"5. {FF6347}%s"COL_GREY"  Value[%d]  Dest[%d]  Insure[%d]  Plate[%s]  Impounded[%d]  Impound Price[%d]", CarInfo[carkey5][cDescription], CarInfo[carkey5][cValue], CarInfo[carkey5][cDestroys], CarInfo[carkey5][cInsure], CarInfo[carkey5][cPlate], CarInfo[carkey5][cImpounded], CarInfo[carkey5][cImpoundedPrice]);
                                SendClientMessage(playerid, COLOR_GREY, string);
                            }
                        }
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GRAD1, "   No Such Player");
                }
            }
            else
            {
                SendClientMessage(playerid, GREY, AdminOnly);
            }
        }
        return 1;
    }
First of all why do you check twice "if(IsPlayerConnected(playerid))"?

PHP код:
if (PlayerInfo[giveplayerid][pCarkey] == SCRIPT_CARS)
if (
PlayerInfo[giveplayerid][pCarkey2] == SCRIPT_CARS)
if (
PlayerInfo[giveplayerid][pCarkey3] == SCRIPT_CARS)
if (
PlayerInfo[giveplayerid][pCarkey4] == SCRIPT_CARS)
if (
PlayerInfo[giveplayerid][pCarkey5] == SCRIPT_CARS) {
    
SendClientMessage(playeridCOLOR_GREY"No vehicles found.");
    return 
1;

this will return the message only with the last if!
You need to declare the Message and the return for each if condition or use the && to write only one if condition.

And after that you create always 5 new vars and check again each car.
Why don't you make an else after each if to send the information?

P.S.
Why don't you create a field to store how many cars the player has? if is 0 skip everything, if is >0 you can use a while statement to send the data without checking things that are not needed...
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)