Raised This Month: $ Target: $400
 0% 

Arrays


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DarlD
Senior Member
Join Date: Aug 2004
Old 12-25-2005 , 21:37   Arrays
Reply With Quote #1

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]) }
__________________
DarlD is offline
Send a message via MSN to DarlD
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 12-25-2005 , 21:43  
Reply With Quote #2

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]) }
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 12-26-2005 , 00:04  
Reply With Quote #3

i think he wanted a for loop
Freecode is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 12-26-2005 , 08:01  
Reply With Quote #4

Code:
new Messages[MAXMESSAGES]
should be
Code:
new Messages[MAXMESSAGES][]
VEN is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 12-26-2005 , 11:34  
Reply With Quote #5

Good catch. Don't know how I missed that.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
DarlD
Senior Member
Join Date: Aug 2004
Old 12-26-2005 , 17:03  
Reply With Quote #6

whats the differance between Messages[MAXMESSAGES] & Messages[MAXMESSAGES][]???
__________________
DarlD is offline
Send a message via MSN to DarlD
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 12-26-2005 , 19:47  
Reply With Quote #7

http://www.compuphase.com/pawn/pawn-lang.pdf
Brad is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 12-26-2005 , 23:21  
Reply With Quote #8

One is set as a string with a set length the other is an array of strings with an unset length.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
Reply



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

Forum Jump


All times are GMT -4. The time now is 23:42.


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