AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [ Array ] (https://forums.alliedmods.net/showthread.php?t=254751)

Xablau 01-05-2015 21:23

[ Array ]
 
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... 


YamiKaitou 01-05-2015 21:27

Re: [ Array ]
 
Not possible with Pawn

Xablau 01-05-2015 21:32

Re: [ Array ]
 
Quote:

Originally Posted by YamiKaitou (Post 2245343)
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.

YamiKaitou 01-05-2015 21:46

Re: [ Array ]
 
Enums or https://forums.alliedmods.net/showthread.php?t=26634

Xablau 01-05-2015 22:22

Re: [ Array ]
 
Quote:

Originally Posted by YamiKaitou (Post 2245348)

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)



NiHiLaNTh 01-06-2015 01:10

Re: [ Array ]
 
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.

Xablau 01-06-2015 05:00

Re: [ Array ]
 
Quote:

Originally Posted by NiHiLaNTh (Post 2245367)
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 01-06-2015 09:11

Re: [ Array ]
 
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 }



Xablau 01-06-2015 13:29

Re: [ Array ]
 
With orm is playing unrealistic values.
Still does not work with enum, why?


All times are GMT -4. The time now is 18:48.

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