[HELP]Error - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP]Error (
/showthread.php?tid=106664)
[HELP]Error -
mr.b - 04.11.2009
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
Re: [HELP]Error -
Devine - 05.11.2009
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.
Re: [HELP]Error -
Kyosaur - 05.11.2009
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
))
Re: [HELP]Error -
Blacklite - 05.11.2009
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.
Re: [HELP]Error -
Kyosaur - 05.11.2009
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;
}