Raised This Month: $ Target: $400
 0% 

[ Enums Problem ]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Xablau
Member
Join Date: Dec 2014
Old 01-06-2015 , 16:42   [ Enums Problem ]
Reply With Quote #1

I have problem on enums :/

See my code:

PHP Code:
enum _:p_DataColumns
{
    
max_health
}
new 
p_Datap_DataColumns ][ ClassColumnStruct ] = 
{
    { 
"max_health"Column_Int11 }
}
public 
plugin_init() 
{
    
RegisterHam(Ham_Spawn"player""Player_Spawn"1); 
}
public 
Player_Spawn(id
{
    
client_print(idprint_chat"New HP: %d"p_Data[id][max_health])
}
public 
client_putinserver(id)
{
    
p_Data[id][max_health] = 200

Player_Spawn is not returning the correct value. Why?
Xablau is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-06-2015 , 17:04   Re: [ Enums Problem ]
Reply With Quote #2

If you do that: p_Data[id][max_health] = 200

It means p_Data should be declared like: new p_Data[MAX_PLAYERS][p_DataColumns];

But you declare it with something else.
__________________
Arkshine is offline
Xablau
Member
Join Date: Dec 2014
Old 01-06-2015 , 17:08   Re: [ Enums Problem ]
Reply With Quote #3

Quote:
Originally Posted by Arkshine View Post
If you do that: p_Data[id][max_health] = 200

It means p_Data should be declared like: new p_Data[MAX_PLAYERS][p_DataColumns];

But you declare it with something else.
How do I create a data dictionary and access it in other functions?
Could provide me an example?

Last edited by Xablau; 01-06-2015 at 17:18.
Xablau is offline
Xablau
Member
Join Date: Dec 2014
Old 01-06-2015 , 17:20   Re: [ Enums Problem ]
Reply With Quote #4

PHP Code:
enum _:p_DataColumns

    
max_health 

new 
p_Data[33][p_DataColumns]

public 
plugin_init()  

    
RegisterHam(Ham_Spawn"player""Player_Spawn"1);  

public 
Player_Spawn(id)  

    
client_print(idprint_chat"New HP: %d"p_Data[id][max_health]) 

public 
client_putinserver(id

    
p_Data[id][max_health] = 200 

Still not work.
client_print(id, print_chat, "New HP: %d", p_Data[id][max_health]) // Return New HP: 0

Last edited by Xablau; 01-06-2015 at 17:21.
Xablau is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-06-2015 , 18:49   Re: [ Enums Problem ]
Reply With Quote #5

Add is_user_alive() in Player_Spawn. Ham_Spawn is called twice, just before you are put in server (you spawn the first time as a player entity, and later alive, after choosing team/class.
__________________
Arkshine is offline
Xablau
Member
Join Date: Dec 2014
Old 01-06-2015 , 19:25   Re: [ Enums Problem ]
Reply With Quote #6

Quote:
Originally Posted by Arkshine View Post
Add is_user_alive() in Player_Spawn. Ham_Spawn is called twice, just before you are put in server (you spawn the first time as a player entity, and later alive, after choosing team/class.
PHP Code:
public Player_Spawn(id)  

    if(
is_user_alive(id)) client_print(idprint_chat"New HP: %d"p_Data[id][max_health]) 

Still not work...
p_Data[id][max_health] is not returning 200
Xablau is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-06-2015 , 19:36   Re: [ Enums Problem ]
Reply With Quote #7

Attach your whole running .sma file so we can check it.
__________________
fysiks is offline
Old 01-06-2015, 19:43
Xablau
This message has been deleted by Xablau.
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-06-2015 , 20:04   Re: [ Enums Problem ]
Reply With Quote #8

The enums works just fine, see this modified version of your plugin (that was changed to test the enum only). Therefore, issue is unrelated to the enum.

Your issue is the sockets. You cannot read from the socket in the same function as you send the socket packet out. The internet is not that fast. Look at the sockets tutorial for how to do it (I actually recently learned how to use sockets from that same tutorial also).
Attached Files
File Type: sma Get Plugin or Get Source (temp.sma - 323 views - 769 Bytes)
__________________

Last edited by fysiks; 01-06-2015 at 20:04.
fysiks is offline
Xablau
Member
Join Date: Dec 2014
Old 01-06-2015 , 20:10   Re: [ Enums Problem ]
Reply With Quote #9

i change public client_putinserver(id) to public client_putinserver(pid) and it worked.
How strange. Why?
Xablau is offline
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 15:17.


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