SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 28/06/2016, 07:53 PM   #1
MayaEU
Huge Clucker
 
Join Date: Nov 2015
Posts: 384
Reputation: 2
Default [warning] client exceeded 'ackslimit' IP (4323) limit: 3000/sec

Why is this command making my game freeze?

pawn Code:
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;
    }
MayaEU is offline   Reply With Quote
Old 28/06/2016, 08:00 PM   #2
AaronJ
Little Clucker
 
Join Date: May 2016
Posts: 26
Reputation: 0
Default Re: [warning] client exceeded 'ackslimit' IP (4323) limit: 3000/sec

Quote:
Originally Posted by MayaEU View Post
Why is this command making my game freeze?

pawn Code:
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 Code:
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...
AaronJ is offline   Reply With Quote
Old 28/06/2016, 08:03 PM   #3
MayaEU
Huge Clucker
 
Join Date: Nov 2015
Posts: 384
Reputation: 2
Default Re: [warning] client exceeded 'ackslimit' IP (4323) limit: 3000/sec

the second one checks if the return user is connected, but i dont really understand what you mean.
MayaEU is offline   Reply With Quote
Old 28/06/2016, 08:07 PM   #4
AaronJ
Little Clucker
 
Join Date: May 2016
Posts: 26
Reputation: 0
Default Re: [warning] client exceeded 'ackslimit' IP (4323) limit: 3000/sec

_Updated the post

Ok, understood what you do with the player check but i think you can skip the check to know if who is using the command is connected..
AaronJ is offline   Reply With Quote
Old 28/06/2016, 08:10 PM   #5
MayaEU
Huge Clucker
 
Join Date: Nov 2015
Posts: 384
Reputation: 2
Default Re: [warning] client exceeded 'ackslimit' IP (4323) limit: 3000/sec

I fixed it already
MayaEU is offline   Reply With Quote
Old 28/06/2016, 08:12 PM   #6
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,079
Reputation: 2655
Default Re: [warning] client exceeded 'ackslimit' IP (4323) limit: 3000/sec

This entire piece of code is so confusing and repetitive.
  1. The player that executes the command is always connected (duh) so that check is completely redundant to begin with.
  2. If giveplayerid is connected then giveplayerid is obviously not INVALID_PLAYER_ID so that check is also completely redundant.
  3. You start a loop for sizeof(CarInfo) times, but I have no idea why. The iterating variable (i) isn't even being used.
  4. Use an array for pCarkey instead of creating five separate attributes.
__________________
Vince is offline   Reply With Quote
Old 28/06/2016, 08:13 PM   #7
AaronJ
Little Clucker
 
Join Date: May 2016
Posts: 26
Reputation: 0
Default Re: [warning] client exceeded 'ackslimit' IP (4323) limit: 3000/sec

Quote:
Originally Posted by Vince View Post
This entire piece of code is so confusing and repetitive.
  1. The player that executes the command is always connected (duh) so that check is completely redundant to begin with.
  2. If giveplayerid is connected then giveplayerid is obviously not INVALID_PLAYER_ID so that check is also completely redundant.
  3. You start a loop for sizeof(CarInfo) times, but I have no idea why. The iterating variable (i) isn't even being used.
  4. Use an array for pCarkey instead of creating five separate attributes.
But he fixed it..
How we'll never know
AaronJ is offline   Reply With Quote
Old 28/06/2016, 08:17 PM   #8
MayaEU
Huge Clucker
 
Join Date: Nov 2015
Posts: 384
Reputation: 2
Default Re: [warning] client exceeded 'ackslimit' IP (4323) limit: 3000/sec

I just forgot return 1;
MayaEU is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Warning: client exceeded 'ackslimit' 322.0.0.9:5206 (6882) Limit: 3000/sec Supermaxultraswag Scripting Help 18 13/12/2014 04:15 PM
Warning: client exceeded 'ackslimit' 110.174.228.223:50520 (1073) Limit: 1000/sec Mriss Server Support 3 18/04/2014 02:03 PM


All times are GMT. The time now is 04:02 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.