Raised This Month: $51 Target: $400
 12% 

save data


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
XSlayer
Member
Join Date: Dec 2021
Old 06-11-2022 , 19:54   save data
Reply With Quote #1

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][*]) 

Last edited by XSlayer; 06-11-2022 at 19:57.
XSlayer is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 06-11-2022 , 21:31   Re: save data
Reply With Quote #2

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;
        }
    }

__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 06-11-2022 at 22:10.
Supremache is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-11-2022 , 21:44   Re: save data
Reply With Quote #3

Supremache, you need to make Goku and Freezer arrays
__________________
Bugsy is offline
XSlayer
Member
Join Date: Dec 2021
Old 06-11-2022 , 21:58   Re: save data
Reply With Quote #4

Quote:
Originally Posted by Supremache View Post
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
XSlayer is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 06-11-2022 , 21:59   Re: save data
Reply With Quote #5

Quote:
Originally Posted by Bugsy View Post
Supremache, you need to make Goku and Freezer arrays
Why!

Quote:
Originally Posted by XSlayer View Post
doesnt work
Show me what you did, I gave you an example.
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 06-11-2022 at 22:01.
Supremache is offline
XSlayer
Member
Join Date: Dec 2021
Old 06-11-2022 , 22:04   Re: save data
Reply With Quote #6

Quote:
Originally Posted by Supremache View Post
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?

Last edited by XSlayer; 06-11-2022 at 22:07.
XSlayer is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-11-2022 , 22:06   Re: save data
Reply With Quote #7

Quote:
Originally Posted by Supremache View Post
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
__________________
Bugsy is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 06-11-2022 , 22:13   Re: save data
Reply With Quote #8

@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.
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 06-11-2022 at 22:28.
Supremache is offline
XSlayer
Member
Join Date: Dec 2021
Old 06-11-2022 , 22:15   Re: save data
Reply With Quote #9

Quote:
Originally Posted by Supremache View Post
@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 )
XSlayer is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 06-11-2022 , 22:18   Re: save data
Reply With Quote #10

Check it again
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache 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 09:43.


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