AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED]Saving data in array (https://forums.alliedmods.net/showthread.php?t=56099)

Alka 06-06-2007 15:21

[SOLVED]Saving data in array
 
Hi.Is there a way to store player team in an array and weapon in another array?

Thanks:up:

Sylwester 06-06-2007 16:11

Re: Array help
 
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".

Alka 06-06-2007 16:19

Re: Array help
 
Heh ...Thanks mate :wink: :P,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

Sylwester 06-06-2007 17:33

Re: Saving data in array
 
Everything is possible :P
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
        
}
    }



Alka 06-06-2007 17:48

Re: Saving data in array
 
Thanks...anyway :wink: +k

_Master_ 06-08-2007 04:57

Re: Saving data in array
 
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])




All times are GMT -4. The time now is 10:37.

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