Raised This Month: $ Target: $400
 0% 

[SOLVED]Saving data in array


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 06-06-2007 , 15:21   [SOLVED]Saving data in array
Reply With Quote #1

Hi.Is there a way to store player team in an array and weapon in another array?

Thanks
__________________
Still...lovin' . Connor noob! Hello

Last edited by Alka; 06-08-2007 at 07:17.
Alka is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 06-06-2007 , 16:11   Re: Array help
Reply With Quote #2

heh, it doesn't seem to be difficult

PHP Code:
new g_player_team[33]

for(new 
i=1i<=32i++)
    if(
is_user_connected(i))
        
g_player_team[i] = get_user_team(i)
        
new 
g_player_weapons[33][32]
new 
g_player_weapons_num[33]

for(new 
i=1i<=32i++)
    if(
is_user_alive(i))
        
get_user_weapons(ig_player_weapons[i], g_player_weapons_num[i]) 
You can use other functions, just search funcwiki for "weapon" and "team".
__________________
Impossible is Nothing
Sylwester is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 06-06-2007 , 16:19   Re: Array help
Reply With Quote #3

Heh ...Thanks mate ,but i want to make somehting like this:
*When type a command get user weapons and when type again give that weapons stored in array! is this possible?:-s
__________________
Still...lovin' . Connor noob! Hello

Last edited by Alka; 06-06-2007 at 16:54.
Alka is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 06-06-2007 , 17:33   Re: Saving data in array
Reply With Quote #4

Everything is possible
PHP Code:
new g_player_weapons[33][32]
new 
g_player_weapons_num[33] = 0



public store_weapons(id){
   if(
is_user_alive(id))
        
get_user_weapons(ig_player_weapons[id], g_player_weapons_num[id])
}

public 
give_weapons(id){
    if(
is_user_alive(id) && g_player_weapons_num[id]){
        new 
weapon_name[20]

        for(new 
i=0i<g_player_weapons_num[id]; i++){
            if(
g_player_weapons[id] == CSW_AK47//g_player_weapons array contains weapons ids
                
weapon_name "weapon_ak47"  //depending on weapon id, you must insert correct weapon name
            
else                            //weapon names depends on mod
            
if(g_player_weapons[id] == CSW_M4A1)
                
weapon_name "weapon_m4a1"
            
else
            .
            .
            .
            
give_item(idweapon_name//http://www.amxmodx.org/funcwiki.php?go=func&id=120
        
}
    }

__________________
Impossible is Nothing

Last edited by Sylwester; 06-06-2007 at 17:38.
Sylwester is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 06-06-2007 , 17:48   Re: Saving data in array
Reply With Quote #5

Thanks...anyway +k
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 06-08-2007 , 04:57   Re: Saving data in array
Reply With Quote #6

PHP Code:
new iweapons[32][32], wpname[32][32], inum[32]

public 
get_weapons(id){
    new 
idx id 1maxweapons
    
    
if(!is_user_alive(id)) return
    
    
get_user_weapons(idiweapons[idx], maxweapons)
    for(new 
0maxweaponsa++) get_weaponname(iweapons[idx][a], wpname[idx], 31)
    
inum[idx] = maxweapons
}

public 
give_weapons(id){
    new 
idx id 1maxweapons inum[idx]
    
    if(!
is_user_alive(id) || !maxweapons) return
    
    for(new 
0maxweaponsa++) give_item(idwpname[idx])

_Master_ 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 10:37.


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