Raised This Month: $ Target: $400
 0% 

Array Must Be Indexed. :/


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Stormsys
Member
Join Date: Oct 2005
Old 10-16-2005 , 06:52   Array Must Be Indexed. :/
Reply With Quote #1

Code:
#include <amxmodx>
#include <amxmisc>
#include <amxconst>

	new data[2]
        new wmsg[225]
	new adminmsg[255]
public plugin_init......
........
....
......

....
public client_putinserver(id)
{
if(get_cvar_num("sshp_welcomemsg")==""){
		
		
	}else{

		if (!(get_user_flags(id)&ADMIN_LEVEL_F)) {
			format(wmsg, 224, "[Stormsys] %s", get_cvar_num("sshp_welcomemsg"))
			client_print(id, print_chat, wmsg)	
		}else{

   			new playername[32]
   			get_user_name(id, playername, 31)
			format(wmsg, 224, "[Stormsys] %s(Server Admin), Has Just Entered The Game", playername)
			client_print(id, print_chat, "Welcome Admin Enjoy Your Stay")	
			client_print(0, print_chat, wmsg)	
			
		}
	}

	return PLUGIN_CONTINUE
}
}

and it gives em erros in the vairialbe (array mst be indexed) how do i fix this?
Stormsys is offline
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 10-16-2005 , 07:26  
Reply With Quote #2

what line?
try "%s", wmsg
Freecode is offline
Stormsys
Member
Join Date: Oct 2005
Old 10-16-2005 , 07:39  
Reply With Quote #3

Quote:
Originally Posted by Freecode
what line?
try "%s", wmsg
every time i want to use a variable eg.

format(wmsg, 224, "[Stormsys] %s(Server Admin), Has Just Entered The Game", playername)
client_print(id, print_chat, "Welcome Admin Enjoy Your Stay")
client_print(0, print_chat, wmsg) <-------------(wmsg)
Stormsys is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 10-16-2005 , 08:24  
Reply With Quote #4

Perhaps unrelated to your question, but a problem all the same...
Code:
format(wmsg, 224, "[Stormsys] %s", get_cvar_num("sshp_welcomemsg"))
You should either change %s to %i (or %d) or you should change get_cvar_num(...) to get_cvar_str(...).

Actually, I see you are consistently using get_cvar_num where it appears you should be using get_cvar_str. In the code you've shown us, change all occurences of get_cvar_num to get_cvar_str. Be sure to look the function up though, because the arguments you pass are slightly different.
Brad is offline
Stormsys
Member
Join Date: Oct 2005
Old 10-16-2005 , 08:41  
Reply With Quote #5

hey thanks both of you,

got the main problem fixed. skill left with 3 errors

if(!get_cvar_str("sshp_welcomemsg")==""){

or

if(get_cvar_num("somming")== 1)

i get another array error there
Stormsys is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 10-16-2005 , 09:21  
Reply With Quote #6

if(get_cvar_num("sshp_welcomemsg")==""){


you can do this

if(get_cvar_num("sshp_welcomemsg")){

or

if(get_cvar_num("sshp_welcomemsg") == "1"){
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 10-16-2005 , 10:07  
Reply With Quote #7

Brad just said you cannot use get_cvar_str the same way.

Don't use it like this
Code:
if(!get_cvar_str("sshp_welcomemsg")=="") {         // }

Use this
Code:
    new str[64];     get_cvar_string("sshp_welcomemsg",str,63);         if(!str || !get_cvar_num("WHATEVER YOUR ON / OFF CVAR IS")     {         return 0;     }
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
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:39.


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