AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   save data (https://forums.alliedmods.net/showthread.php?t=338160)

XSlayer 06-11-2022 19:54

save data
 
Hi, i wanted to know how to store a data globaly, in one varible, like first the character, and second the models

i thought something like this:

PHP Code:

         // Global
                                       // 12 for the max characters, and 2 for the max lvls ( in models )
new __int_CLASSLVL[12][2] =

              
// 0 = Goku
                                 // "goku.mdl"
                                // "ssjgoku.mdl"
             // 1 = Freezer
                                 // "freezer.mdl"
                                      // how to write something like that correctly?, and if its possible of course




Then for use it:
PHP Code:

                                                          // *= how can i check the max of lvls, thinking that goku will have 2 and freezer 1
if(__int_LVL[Client] < __int_CLASSLVL[__int_PJ[Client][*]) 


Supremache 06-11-2022 21:31

Re: save data
 
PHP Code:

enum ClassLvlData
{
    
Goku32 ],
    
Freezer32 ]//,
    
    // MaxData // You can add more variables to store the maximum enum
}

new 
__int_CLASSLVL[ ][ClassLvlData] = 
{
    { 
"freezer.mdl""goku.mdl" },
    { 
"freezer.mdl""ssjgoku.mdl" },
    { 
"freezer.mdl""goku.mdl" },
    { 
"freezer.mdl""ssjgoku.mdl" },
    { 
"freezer.mdl""goku.mdl" },
    { 
"freezer.mdl""ssjgoku.mdl" },
    { 
"freezer.mdl""goku.mdl" },
    { 
"freezer.mdl""ssjgoku.mdl" },
    { 
"freezer.mdl""goku.mdl" },
    { 
"freezer.mdl""ssjgoku.mdl" },
    { 
"freezer.mdl""goku.mdl" }
}

public 
plugin_precache()
{
    for( new 
iArrayiArray sizeof__int_CLASSLVL ); iArray++) // Create a loop to make the code work for all the data on the array
    
{
        for( new 
iClass GokuiClass <= FreezeriClass++ ) // Create a loop to make the code work for all the enum data on the array
        
{
            
precache_player_model__int_CLASSLVLiArray ][ iClass ] )
        }
    }
}


public Function( 
Client )
{
    for( new 
iArrayDataiArraySize sizeof__int_CLASSLVL ); iArrayData iArraySizeiArrayData++)
    {
        if( 
iArrayData <= __int_LVLClient ] < iArraySize // If the player has levels less than the maximum of array size and equal to or greater than the array data, then he gets the model
        
{
            
cs_set_user_modelid__int_CLASSLVLiArrayData ][ Goku ] )
            break;
        }
    }



Bugsy 06-11-2022 21:44

Re: save data
 
Supremache, you need to make Goku and Freezer arrays

XSlayer 06-11-2022 21:58

Re: save data
 
Quote:

Originally Posted by Supremache (Post 2781511)
PHP Code:

enum ClassLvlData
{
    
Goku,
    
Freezer//,
    
    // MaxData // You can add more variables to store the maximum enum
}

new 
__int_CLASSLVL[ ][ClassLvlData] = 
{
    { 
"freezer.mdl""goku.mdl" },
    { 
"freezer.mdl""ssjgoku.mdl" },
    { 
"freezer.mdl""goku.mdl" },
    { 
"freezer.mdl""ssjgoku.mdl" },
    { 
"freezer.mdl""goku.mdl" },
    { 
"freezer.mdl""ssjgoku.mdl" },
    { 
"freezer.mdl""goku.mdl" },
    { 
"freezer.mdl""ssjgoku.mdl" },
    { 
"freezer.mdl""goku.mdl" },
    { 
"freezer.mdl""ssjgoku.mdl" },
    { 
"freezer.mdl""goku.mdl" }
}

public 
plugin_precache()
{
    for( new 
iArrayiArray sizeof__int_CLASSLVL ); iArray++) // Create a loop to make the code work for all the data on the array
    
{
        for( new 
iClass GokuiClass <= FreezeriClass++ ) // Create a loop to make the code work for all the enum data on the array
        
{
            
precache_player_model__int_CLASSLVLiArray ][ iClass ] )
        }
    }
}


public Function( 
Client )
{
    for( new 
iArrayDataiArraySize sizeof__int_CLASSLVL ); iArrayData iArraySizeiArrayData++)
    {
        if( 
iArrayData <= __int_LVLClient ] < iArraySize // If the player has levels less than the maximum of array size and equal to or greater than the array data, then he gets the model
        
{
            
cs_set_user_modelid__int_CLASSLVLiArrayData ][ Goku ] )
            break;
        }
    }



doesnt work

Supremache 06-11-2022 21:59

Re: save data
 
Quote:

Originally Posted by Bugsy (Post 2781513)
Supremache, you need to make Goku and Freezer arrays

Why!

Quote:

Originally Posted by XSlayer (Post 2781514)
doesnt work

Show me what you did, I gave you an example.

XSlayer 06-11-2022 22:04

Re: save data
 
Quote:

Originally Posted by Supremache (Post 2781515)
Why!



Show me what you did, I gave you an example.

its just a bit diffente because im comparing in other way i think.


PHP Code:

new __int_CLASSLVL[12][2] =

              
// 0 = Goku
                                 // "goku.mdl"
                                // "ssjgoku.mdl"
             // 1 = Freezer
                                 // "freezer.mdl"
                                      // how to write something like that correctly?, and if its possible of course




// i have the character with __int_PJ[Client] ( number ), i just wanted to see the max of lvls for this, compare the actual LVL( __int_LVL ) with the max lvl for the character

PHP Code:

if(__int_LVL[Client] < __int_CLASSLVL[__int_PJ[Client][*]) 

PHP Code:

new __int_CLASSLVL[][] = 
{
  
// Goku
    
"goku.mdl""ssjgoku.mdl" }, // 0 base // 1 ssj

  
// Freezer
    
"freezer.mdl" }, // 0 base



// is this possible?

Bugsy 06-11-2022 22:06

Re: save data
 
Quote:

Originally Posted by Supremache (Post 2781515)
Why!



Show me what you did, I gave you an example.

Because you're using the enum to size a 2-dimension array of strings. What you did would allow this format only

{ 1 , 2 },
{ 3 , 4 }

etc

Supremache 06-11-2022 22:13

Re: save data
 
@XSlayer, if you want to compare the levels with the max size of the array try this:
if(__int_LVL[Client] < sizeof( __int_CLASSLVL ) )

[/PHP]
@Bugsy, Oops, I thought something else, it fixed.

XSlayer 06-11-2022 22:15

Re: save data
 
Quote:

Originally Posted by Supremache (Post 2781518)
@XSlayer, if you want to compare the levels with the max size of the array try this:
if(__int_LVL[Client] < sizeof( __int_CLASSLVL ) )
Replace this:
PHP Code:

new __int_CLASSLVL[][] = 
{
  
// Goku
    
"goku.mdl""ssjgoku.mdl" }, // 0 base // 1 ssj

  
// Freezer
    
"freezer.mdl" }, // 0 base



with this
PHP Code:

new __int_CLASSLVL[][] = 
{
  
// Goku
    
"goku.mdl""ssjgoku.mdl" }, // 0 base // 1 ssj

  
// Freezer
    
"freezer.mdl""" }, // 0 base



@Bugsy, Oops, I thought something else, it fixed.

PHP Code:

new __int_CLASSLVL[][] = 
{
  
// Goku
    
"goku.mdl""ssjgoku.mdl" }, // 0 base // 1 ssj

  
// Freezer
    
"freezer.mdl""" }, // 0 base




this is just an idea, the compiler throw an error, cause i didnt separate the clases ( 0 = goku )

Supremache 06-11-2022 22:18

Re: save data
 
Check it again


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

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