Raised This Month: $219 Target: $400
 54% 

[ Array ]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Xablau
Member
Join Date: Dec 2014
Old 01-05-2015 , 21:23   [ Array ]
Reply With Quote #1

How do I mount an array like this:

myArray[0]["value1"] = 0
myArray[0]["value2"] = 33
myArray[1]["value1"] = 1

PHP Code:
new p_Data[33][33]
copy(p_Data[playerID]["test"], 32"1")
copy(p_Data[playerID]["haha"], 32"test")
not work... 
Xablau is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 01-05-2015 , 21:27   Re: [ Array ]
Reply With Quote #2

Not possible with Pawn
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (intervening in a thread, asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Xablau
Member
Join Date: Dec 2014
Old 01-05-2015 , 21:32   Re: [ Array ]
Reply With Quote #3

Quote:
Originally Posted by YamiKaitou View Post
Not possible with Pawn
What is the best way to store players data to use in various functions?
I am using socket for receiving player data and need to use this data in the rounds.
Xablau is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 01-05-2015 , 21:46   Re: [ Array ]
Reply With Quote #4

Enums or https://forums.alliedmods.net/showthread.php?t=26634
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (intervening in a thread, asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Xablau
Member
Join Date: Dec 2014
Old 01-05-2015 , 22:22   Re: [ Array ]
Reply With Quote #5

Quote:
Originally Posted by YamiKaitou View Post
I have problem :/

PHP Code:
enum _:PlayerInfo
{
    
max_health
}
new 
p_Data33 ][ PlayerInfo ]

public 
plugin_init() 

    
RegisterHam(Ham_Spawn"player""Player_Spawn"1); 
}
public 
Player_Spawn(id
{
    if(
is_user_alive(id))  
        
set_user_health(idp_Data[id][max_health]) // p_Data[id][max_health] Is returning 0
}
public 
client_putinserver(id)
{
    
p_Data[id][max_health] = str_to_num(200)


Last edited by Xablau; 01-05-2015 at 22:23. Reason: Adapted the original code.
Xablau is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 01-06-2015 , 01:10   Re: [ Array ]
Reply With Quote #6

p_Data[id][max_health] = str_to_num(200) ; str_to_num requires a string as a param. Anyway, that conversion is useless, just write directly 200.
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
Xablau
Member
Join Date: Dec 2014
Old 01-06-2015 , 05:00   Re: [ Array ]
Reply With Quote #7

Quote:
Originally Posted by NiHiLaNTh View Post
p_Data[id][max_health] = str_to_num(200) ; str_to_num requires a string as a param. Anyway, that conversion is useless, just write directly 200.
Even without direct str_to_num the value is not being passed ...
Xablau is offline
Xablau
Member
Join Date: Dec 2014
Old 01-06-2015 , 09:11   Re: [ Array ]
Reply With Quote #8

Work with database_orm:

PHP Code:
enum _:p_DataColumns
{
    
id,
    
max_health,
    
max_armor
}
new 
p_Datap_DataColumns ][ ClassColumnStruct ] = 
{
    { 
"id"Column_Int11 },
    { 
"max_health"Column_Int11 },
    { 
"max_armor"Column_Int11 }


Last edited by Xablau; 01-06-2015 at 09:12.
Xablau is offline
Xablau
Member
Join Date: Dec 2014
Old 01-06-2015 , 13:29   Re: [ Array ]
Reply With Quote #9

With orm is playing unrealistic values.
Still does not work with enum, why?
Xablau is offline
Reply


Thread Tools
Display Modes

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 10:28.


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