Raised This Month: $ Target: $400
 0% 

Array Problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 06-12-2010 , 07:49   Array Problem
Reply With Quote #1

Hello.

I did a array:

PHP Code:
new class[32
When you choose the first item in my menu, 1 item in the array shout be 1.

PHP Code:
    switch(keyid)
    {
        case 
1:
        {
               
set_user_gravity(id0.5)
               class[
id] = 1
               client_print
(idprint_chat"[FM] You are a Sonic now!");
               
menu_destroy(menu_class);
               return 
PLUGIN_HANDLED;
        }
    } 
so, i registerd a event, that is called when a new round beginns. In this event i wrote:
PHP Code:
 public event_new_round(id)
 
    {
        
client_print(idprint_chat"%i <- Shout be 1 cause i set it to 1", class[id])
        return 
PLUGIN_CONTINUE

BUT I GOT ALWAYS 0 instead 1

can you tell me why?
mottzi is offline
Send a message via MSN to mottzi
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 06-12-2010 , 07:52   Re: Array Problem
Reply With Quote #2

Maybe it is case 0: instead of case 1: , no ?
__________________
You can do anything you set your mind to, man.

Devil259 is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 06-12-2010 , 07:56   Re: Array Problem
Reply With Quote #3

No, that cant be.

Something has to be wrong with:

%i, class[id]
mottzi is offline
Send a message via MSN to mottzi
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 06-12-2010 , 08:02   Re: Array Problem
Reply With Quote #4

new class[33]
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 06-12-2010 , 08:09   Re: Array Problem
Reply With Quote #5

dont work


here is my full code:
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>


#define PLUGIN "FutureMod"
#define VERSION "1.1"
#define AUTHOR "Mottzi"

      
new class[33]

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /class""change_class")
    
register_clcmd("say_team /class""change_class")
    
register_event("HLTV""event_new_round""a""1=0""2=0")  

}

 public 
change_class(id)
 {
    if (!
is_user_alive(id) == 1)
    {
        new 
menu_class menu_create("\r: Choose a class!""change_class_menu");
       
        
menu_additem(menu_class"\wSonic""1"0);
        
        
menu_setprop(menu_classMPROP_EXITMEXIT_ALL);
        
        
menu_display(idmenu_class0);
    }
    else
    {
        
client_print(idprint_chat"Only dead peaple can change their class!")
    }
   

   
 }

 public 
change_class_menu(idmenu_classitem)
 {

    
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu_class);
        return 
PLUGIN_HANDLED;
    }

    
    new 
data[6], iName[64];
    new 
accesscallback;

    
menu_item_getinfo(menu_classitemaccessdata,5iName63callback);

    
    new 
key str_to_num(data);
   
    switch(
keyid)
    {
        case 
1:
        {
               
set_user_gravity(id0.5)
       class[
id] = 0
            client_print
(idprint_chat"[FM] You are a Sonic now!");
            
menu_destroy(menu_class);
       

            return 
PLUGIN_HANDLED;
        }
    }

    
menu_destroy(menu_class);
    return 
PLUGIN_HANDLED;
 }

 public 
event_new_round(id)
 
    {
        
client_print(idprint_chat"%i lool", class[id])
        new 
players[32], inum
        get_players
(playersinum)
        for(new 
0inumi++;) 
        {
        
client_print(idprint_chat"%i lool", class[id])
        if(class[
id] == )
        {
            
set_user_health(id150)
            
set_user_gravity(id0.5)
        }
        }
        return 
PLUGIN_CONTINUE

mottzi is offline
Send a message via MSN to mottzi
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 06-12-2010 , 08:11   Re: Array Problem
Reply With Quote #6

you can't use id in event_new_round, you have to loop through all the players

Edit: try this:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>


#define PLUGIN "FutureMod"
#define VERSION "1.1"
#define AUTHOR "Mottzi"

new class[33]

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /class""change_class")
    
register_clcmd("say_team /class""change_class")
    
register_event("HLTV""event_new_round""a""1=0""2=0")  
}

public 
change_class(id)
{
    if (!
is_user_alive(id))
    {
        new 
menu_class menu_create("\r: Choose a class!""change_class_menu");
       
        
menu_additem(menu_class"\wSonic""1"0);
        
        
menu_setprop(menu_classMPROP_EXITMEXIT_ALL);
        
        
menu_display(idmenu_class0);
    }
    
    else
    {
        
client_print(idprint_chat"Only dead peaple can change their class!")
    }
   

   
 }

 public 
change_class_menu(idmenu_classitem)
 {

    
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu_class);
        return 
PLUGIN_HANDLED;
    }

    
    new 
data[6], iName[64];
    new 
accesscallback;

    
menu_item_getinfo(menu_classitemaccessdata,5iName63callback);

    
    new 
key str_to_num(data);
   
    switch(
keyid)
    {
        case 
1:
        {
            
set_user_gravity(id0.5)
            class[
id] = 0
            client_print
(idprint_chat"[FM] You are a Sonic now!");
            
menu_destroy(menu_class);
       

            return 
PLUGIN_HANDLED;
        }
    }

    
menu_destroy(menu_class);
    return 
PLUGIN_HANDLED;
 }

public 
event_new_round()
{
    new 
players[32], inumid
    get_players
(playersinum)
    
    for(new 
0inumi++) 
    {
        
id players[i]
        
        if(class[
id] == 1)
        {
            
set_user_health(id150)
            
set_user_gravity(id0.5)
        }
        
        
client_print(idprint_chat"%i lool", class[id])
    }
    return 
PLUGIN_CONTINUE

__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.

Last edited by drekes; 06-12-2010 at 08:19.
drekes is offline
Send a message via MSN to drekes
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 06-12-2010 , 08:20   Re: Array Problem
Reply With Quote #7

can you tell me how?
mottzi is offline
Send a message via MSN to mottzi
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 06-12-2010 , 08:21   Re: Array Problem
Reply With Quote #8

Quote:
Originally Posted by mottzi View Post
can you tell me how?
Look post above
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 06-12-2010 , 08:33   Re: Array Problem
Reply With Quote #9

Thank u very much.

class[id] returns 1 now.

But why i dont get gravity and 150 hp???


if(class[id] == 1)
{
set_user_health(id, 150)
set_user_gravity(id, 0.5)
}
mottzi is offline
Send a message via MSN to mottzi
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 06-12-2010 , 08:37   Re: Array Problem
Reply With Quote #10

my guess would be that you have error logs in event round start because the player in not alive or something, check the logs and enable debug.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
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 14:43.


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