[HELP]Error
#1

I need help with this code when i'm compiling it i got this error

C:\Users\JAHIR\Desktop\samp03asvr_win32\gamemodes\ lvdm.pwn(462) : error 032: array index out of bounds (variable "H4CKW34P0N5")

Код:
new H4CKW34P0N5[8] = {
17,35,36,37,39,40,44,45
};
Код:
forward W34P0NCH3CK();
public W34P0NCH3CK()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
new H4CK3DW34P0N; H4CK3DW34P0N = GetPlayerWeapon(i);
if(H4CK3DW34P0N == H4CKW34P0N5[8] && !IsPlayerAdminLevel(i,5) //462
{
KickPlayer(i,"Weapon Hack");
}
}
return 1;
}
thanks
Reply
#2

Read your errors more carefully, and look at your code..

new H4CKW34P0N5[8]

H4CKW34P0N5 is more then 8 letters, so why do you have 8? Your string is too small, increase it.
Reply
#3

Quote:
Originally Posted by Devine
Read your errors more carefully, and look at your code..

new H4CKW34P0N5[8]

H4CKW34P0N5 is more then 8 letters, so why do you have 8? Your string is too small, increase it.
Read the script more carefully. "H4CKW34P0N5" is an array that contains illegal weapon id's.

Hmmm you need to loop through "H4CKW34P0N5", cant just put the size of the array / expect it to know what to do. (also, are kickplayer/isadminlevel custom functions ? or did you mean Kick() and IsPlayerAdmin() ?).

Edit: just noticed you missed a brace as well:

if(H4CK3DW34P0N == H4CKW34P0N5[8] && !IsPlayerAdminLevel(i,5))
Reply
#4

Quote:
Originally Posted by Kyosaur!!
Quote:
Originally Posted by Devine
Read your errors more carefully, and look at your code..

new H4CKW34P0N5[8]

H4CKW34P0N5 is more then 8 letters, so why do you have 8? Your string is too small, increase it.
Read the script more carefully. "H4CKW34P0N5" is an array that contains illegal weapon id's.

Hmmm you need to loop through "H4CKW34P0N5", cant just put the size of the array / expect it to know what to do. (also, are kickplayer/isadminlevel custom functions ? or did you mean Kick() and IsPlayerAdmin() ?).

Edit: just noticed you missed a brace as well:

if(H4CK3DW34P0N == H4CKW34P0N5[8] && !IsPlayerAdminLevel(i,5))
Also, note that the size of your array is 8, so the largest you can do is H4CKW34P0N5[7]. H4CKW34P0N5[8] will not work.
Reply
#5

Quote:
Originally Posted by Blacklite
Quote:
Originally Posted by Kyosaur!!
Quote:
Originally Posted by Devine
Read your errors more carefully, and look at your code..

new H4CKW34P0N5[8]

H4CKW34P0N5 is more then 8 letters, so why do you have 8? Your string is too small, increase it.
Read the script more carefully. "H4CKW34P0N5" is an array that contains illegal weapon id's.

Hmmm you need to loop through "H4CKW34P0N5", cant just put the size of the array / expect it to know what to do. (also, are kickplayer/isadminlevel custom functions ? or did you mean Kick() and IsPlayerAdmin() ?).

Edit: just noticed you missed a brace as well:

if(H4CK3DW34P0N == H4CKW34P0N5[8] && !IsPlayerAdminLevel(i,5))
Also, note that the size of your array is 8, so the largest you can do is H4CKW34P0N5[7]. H4CKW34P0N5[8] will not work.
Dont know why you quoted me there lol, i told him to loop through it.


pawn Код:
#include <a_samp>

new HackWeapons[8] =
{
    17,35,36,37,39,40,44,45
};

public OnFilterScriptInit()
{
    SetTimer("WeaponCheck", 500, true); //or under OnGameModeInit...
    return 1;
}

forward WeaponCheck();
public WeaponCheck()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
      if((!IsPlayerConnected(i)) || (IsPlayerAdmin(i))) continue;
     
      for(new a=0; a<sizeof(HackWeapons); a++)
      {
            if((GetPlayerWeapon(i) == HackWeapons[a]) && (GetPlayerAmmo(i) > 0))
            {
              SendClientMessage(i, 0xFF0000FF, "You were kicked for weapon hacking!");
                Kick(i);
            }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)