Skocz do zawartości

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.
  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Zdjęcie

Ilość elementów zmiennej/tablicy


  • Zamknięty Temat jest zamknięty
6 odpowiedzi w tym temacie

#1 L0rdS^P0l4K

    Profesjonalista

  • Użytkownik

Reputacja: 117
Zaawansowany

  • Postów:197
  • GG:
  • Steam:steam
  • Imię:Denis
  • Lokalizacja:Tarnowskie Góry
Offline

Napisano 11.11.2009 17:20

Witam.
Posiadam serwer 32 sloty... wcześniej było mniej jednak teraz pytanie...
Przy 32 slotach adminlisten wywala debuga że

Run time error 4: index out of bounds

Zmienne czy raczej tablice kij go wie są inicjowane w ten sposób.

new players[32]

Czy wszystko jest ok? Wydaje mi się, przynajmniej tak widziałem w wielu pluginach że daje się tablicę do 33.

W czym jest problem ?[/code]
  • +
  • -
  • 0

#2 Miczu

    Godlike

  • Przyjaciel

Reputacja: 657
Wszechmogący

  • Postów:2 862
Offline

Napisano 11.11.2009 17:43

Nie pamietam jaka jest oficjalne wyjasnienie tego, ale z tego co pamietam, to ostatni znak tablicy to musi byc informacja, ze to to jest wlasnie ostatni element i sie go nie uzywa. Czyli jak potrzebujesz 32 miejsc dla 32 graczy, to albo uzywasz tablicy od elementu 0 (id graczy sie zaczyna od 1, wiec trzeba by [id-1]) lub po prostu zwiekszyc rozmiar tablicy do 33. Oczywiscie jak serwer jest 31 slotowy to nie bedzie id wieksze niz 31, ale skoro masz 32 no to to zapewne jest winne.

:up: ignore

Tak, zwieksz do 33
new players[33]
  • +
  • -
  • 0

#3 L0rdS^P0l4K

    Profesjonalista

  • Autor tematu
  • Użytkownik

Reputacja: 117
Zaawansowany

  • Postów:197
  • GG:
  • Steam:steam
  • Imię:Denis
  • Lokalizacja:Tarnowskie Góry
Offline

Napisano 13.11.2009 14:18

Witam ponownie.
Oczywiście musiałem gdzieś zrobić błąd albo przeoczyć coś bo gdy zwiększyłem wartość do 33 z kompilator wyrzucił mi błąd:
error 047: array size do not match, or destination array is too small

Jeżeli mogę to proszę o przerobienie tego kodu :-)
Pozdrawiam

#include <amxmodx>
#include <amxmisc>
#include <engine>

// Counter for the SayText event.
new count[32][32]     
new g_voice_status[2]

public catch_say(id)
{
	new reciever = read_data(0) //Reads the ID of the message recipient
	new sender = read_data(1)   //Reads the ID of the sender of the message
	new message[151]            //Variable for the message
	new channel[151]
	new sender_name[32]

	if (is_running("czero")||is_running("cstrike"))
	{
   		read_data(2,channel,150)
	   	read_data(4,message,150)
   		get_user_name(sender, sender_name, 31)
	} else {
	        read_data(2,message,150)
	}
   
	// DEBUG. 
	// console_print(0, "DEBUG MESSAGE: %s", message)
	// console_print(0, "DEBUG channel: %s", channel)
	// console_print(0, "DEBUG sender: %s, %i", sender_name, sender)
	// console_print(0, "DEBUG receiver: %i", reciever)
   
   	//With the SayText event, the message is sent to the person who sent it last.
   	//It's sent to everyone else before the sender recieves it.

	// Keeps count of who recieved the message
   	count[sender][reciever] = 1          
	// If current SayText message is the last then...
   	if (sender == reciever)
	{      
      		new player_count = get_playersnum()  //Gets the number of players on the server
      		new players[32] //Player IDs
      		get_players(players, player_count, "c")

      		for (new i = 0; i < player_count; i++) 
		{
			// If the player is an admin...
         		if (get_user_flags(players[i]) & ADMIN_LEVEL_<img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/cool.gif' class='bbc_emoticon' alt='B)' />
			{     
				// If the player did not recieve the message then...
            			if (count[sender][players[i]] != 1)
				{              
               				message_begin(MSG_ONE, get_user_msgid("SayText"),{0,0,0},players[i])
               				// Appends the ID of the sender to the message, so the engine knows what color to make the name.
               				write_byte(sender)
               				// Appends the message to the message (depending on the mod).
					if (is_running("czero")||is_running("cstrike"))
	       				{
   						write_string(channel)
	       					write_string(sender_name)
	       				}
               				write_string(message)
               				message_end()
            			}
         		}
         		count[sender][players[i]] = 0  //Set everyone's counter to 0 so it's ready for the next SayText
      		}
   	}
	
   	return PLUGIN_CONTINUE
}

public plugin_init(){
   register_plugin("AdminListen","2.3x","/dev/ urandom")
   register_srvcmd("amx_adminlisten_voice","voice_status")
   register_event("SayText","catch_say","b")
   return PLUGIN_CONTINUE
}

public plugin_modules(){
   require_module("engine") 
}

// *********************
// VoiceComm Stuff
// *********************

public client_infochanged(id)
{
   if ((get_user_flags(id) & ADMIN_LEVEL_<img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/cool.gif' class='bbc_emoticon' alt='B)' /> && equal(g_voice_status,"1")) set_speak(id, 4)
}

public client_connect(id)
{
   if ((get_user_flags(id) & ADMIN_LEVEL_<img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/cool.gif' class='bbc_emoticon' alt='B)' /> && equal(g_voice_status,"1")) set_speak(id, 4)
}

public voice_status(){
   read_argv(1,g_voice_status,1)
   new player_count = get_playersnum()
   new players[32] //Player IDs
   get_players(players, player_count, "c")
   for (new i = 0; i < player_count; i++) {
      if ((get_user_flags(players[i]) & ADMIN_LEVEL_<img src='https://amxx.pl/public/style_emoticons/<#EMO_DIR#>/cool.gif' class='bbc_emoticon' alt='B)' />){         
         if (equal(g_voice_status,"0")) set_speak(players[i], 0)
         if (equal(g_voice_status,"1")) set_speak(players[i], 4)
      }
   }
}

  • +
  • -
  • 0

#4 Miczu

    Godlike

  • Przyjaciel

Reputacja: 657
Wszechmogący

  • Postów:2 862
Offline

Napisano 13.11.2009 21:22

new count[33][32]

  • +
  • -
  • 0

#5 L0rdS^P0l4K

    Profesjonalista

  • Autor tematu
  • Użytkownik

Reputacja: 117
Zaawansowany

  • Postów:197
  • GG:
  • Steam:steam
  • Imię:Denis
  • Lokalizacja:Tarnowskie Góry
Offline

Napisano 14.11.2009 14:36

L 11/14/2009 - 14:25:05: [AMXX] Run time error 4: index out of bounds 
L 11/14/2009 - 14:25:05: [AMXX]    [0] adminlisten.sma::catch_say (line 65)
L 11/14/2009 - 14:25:57: [AMXX] Displaying debug trace (plugin "adminlisten.amxx")
L 11/14/2009 - 14:25:57: [AMXX] Run time error 4: index out of bounds 
L 11/14/2009 - 14:25:57: [AMXX]    [0] adminlisten.sma::catch_say (line 65)
L 11/14/2009 - 14:26:03: [AMXX] Displaying debug trace (plugin "adminlisten.amxx")
L 11/14/2009 - 14:26:03: [AMXX] Run time error 4: index out of bounds 
L 11/14/2009 - 14:26:03: [AMXX]    [0] adminlisten.sma::catch_say (line 36)
L 11/14/2009 - 14:26:03: [AMXX] Displaying debug trace (plugin "adminlisten.amxx")
L 11/14/2009 - 14:26:03: [AMXX] Run time error 4: index out of bounds 
L 11/14/2009 - 14:26:03: [AMXX]    [0] adminlisten.sma::catch_say (line 65)
L 11/14/2009 - 14:26:05: [AMXX] Displaying debug trace (plugin "adminlisten.amxx")
L 11/14/2009 - 14:26:05: [AMXX] Run time error 4: index out of bounds 
L 11/14/2009 - 14:26:05: [AMXX]    [0] adminlisten.sma::catch_say (line 36)
L 11/14/2009 - 14:26:05: [AMXX] Displaying debug trace (plugin "adminlisten.amxx")

Niestety nadal ten sam problem.
  • +
  • -
  • 0

#6 Miczu

    Godlike

  • Przyjaciel

Reputacja: 657
Wszechmogący

  • Postów:2 862
Offline

Napisano 14.11.2009 14:39

new count[33][33]


Musialem byc zmeczony ;>
  • +
  • -
  • 0

#7 L0rdS^P0l4K

    Profesjonalista

  • Autor tematu
  • Użytkownik

Reputacja: 117
Zaawansowany

  • Postów:197
  • GG:
  • Steam:steam
  • Imię:Denis
  • Lokalizacja:Tarnowskie Góry
Offline

Napisano 15.11.2009 00:38

Dzięki serdeczne... nie wiem jak ja to robiłem, bo też majstrowałem, ale mi wyskakiwały errory :-)
Pozdrawiam
  • +
  • -
  • 0




Użytkownicy przeglądający ten temat: 0

0 użytkowników, 0 gości, 0 anonimowych