AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Arrays (https://forums.alliedmods.net/showthread.php?t=22401)

DarlD 12-25-2005 21:37

Arrays
 
I've been experimenting with arrays with hud messages.

i've created the hud messages:
Code:
#define MAXMESSAGES 4 new Messages[MAXMESSAGES] = {     "Hello",     "Welcome",     "Test1",     "Test2"; }

and i created a code for the text msgs:

Code:
public e_r_hud(id) { // e_r_hud is a ResetHUD event     new m_id = 1; 0 > m_id; m_id++ // this is supposed to change the message     set_hudmessage(200,100,0,-1.0,0.35,0,6.0,12.0)     show_hudmessage(id,"%s",Messages[m_id]) }

i get these errors when i compile:
Code:

error 001: expected token: "}", but found ";"
warning 215: expression has no effect

here is the hole script:

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #define PLUGIN "New Plugin" #define VERSION "0.1" #define AUTHOR "Meta" #define MAXMESSAGES 4 new Messages[MAXMESSAGES] = {     "Hello",     "Welcome",     "Test1",     "Test2"; } public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_event("ResetHUD","e_r_hud","b") } public e_r_hud(id) {     new m_id = 1; 0 > m_id; m_id++     set_hudmessage(200,100,0,-1.0,0.35,0,6.0,12.0)     show_hudmessage(id,"%s",Messages[m_id]) }

Xanimos 12-25-2005 21:43

Your confusing a for loop with regular code.
If you made it a for loop it will show everysingle text message.

maybe try
Code:
public e_r_hud(id) { // e_r_hud is a ResetHUD event     new m_id = random_num( 0 , MAXMESSAGES )     set_hudmessage(200,100,0,-1.0,0.35,0,6.0,12.0)     show_hudmessage(id,"%s",Messages[m_id]) }

Freecode 12-26-2005 00:04

i think he wanted a for loop

VEN 12-26-2005 08:01

Code:
new Messages[MAXMESSAGES]
should be
Code:
new Messages[MAXMESSAGES][]

Xanimos 12-26-2005 11:34

Good catch. Don't know how I missed that.

DarlD 12-26-2005 17:03

whats the differance between Messages[MAXMESSAGES] & Messages[MAXMESSAGES][]???

Brad 12-26-2005 19:47

http://www.compuphase.com/pawn/pawn-lang.pdf

Xanimos 12-26-2005 23:21

One is set as a string with a set length the other is an array of strings with an unset length.


All times are GMT -4. The time now is 16:04.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.