AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Array Must Be Indexed. :/ (https://forums.alliedmods.net/showthread.php?t=19411)

Stormsys 10-16-2005 06:52

Array Must Be Indexed. :/
 
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?

Freecode 10-16-2005 07:26

what line?
try "%s", wmsg

Stormsys 10-16-2005 07:39

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)

Brad 10-16-2005 08:24

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.

Stormsys 10-16-2005 08:41

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

teame06 10-16-2005 09:21

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


you can do this

if(get_cvar_num("sshp_welcomemsg")){

or

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

Hawk552 10-16-2005 10:07

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;     }


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

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