Raised This Month: $ Target: $400
 0% 

How to save arrays to mysql


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DoviuX
Senior Member
Join Date: Jun 2009
Location: Lithuania
Old 05-05-2012 , 04:05   How to save arrays to mysql
Reply With Quote #1

How to save these arrays or variables into mysql ?

Is it something like this ?


PHP Code:
p_achieviments33 ][ MAXACHIEVIMENTS ], p_kills33 ][ MAXACHIEVIMENTS ], 
achvi_name33 ][ MAXACHIEVIMENTS ];

    new 
szAuth33 ];
    new 
szKey64 ];

    
get_user_ipidszAuth charsmaxszAuth ), 1);
    
formatexszKey 63 "%s-IP" szAuth );
    static 
szQuery128 ]; 
    
formatexszQuery127"INSERT INTO `achieviment_table` ( `player_id`, `achieviment_name`, `achieviment_id` ) VALUES ( '%s', '%s', '%d' );"szAuth achvi_nameid ][ ], p_achievimentsid ][ ] ); 
DoviuX is offline
Send a message via Skype™ to DoviuX
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 05-05-2012 , 04:56   Re: How to save arrays to mysql
Reply With Quote #2

PHP Code:
// NUMERIC
INSERT INTO MyTable MyFirstRowMySecondRow VALUES 1)
// INSERT INTO Ach ( Kills, Deaths ) VALUES ( %d, %d )

// TEXT
INSERT INTO MyTable MyFirstRowMySecondRow VALUES 'abc''lmn' )
// INSERT INTO Ach ( Name, Steam ) VALUES ( '%s', '%s' )

// FUNCTIONS
INSERT INTO MyTable MyFirstRow VALUES unix_timestampnow( ) ) ) // TIME ELAPSED IN SECONDS SINCE UNIX EPOCH ( JAN 01 1970 ) 
Please make sure your szQuery string has enough characters to handle your whole query. I recommend 256 or 512 cells instead.
__________________

Last edited by claudiuhks; 05-05-2012 at 05:01.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
DoviuX
Senior Member
Join Date: Jun 2009
Location: Lithuania
Old 05-05-2012 , 05:04   Re: How to save arrays to mysql
Reply With Quote #3

Thanks, and will it make achieviments not into one every time but make new or change the existing ones ?
Becouse I have many achieviments and I want that it showed in the website like steams achieviments.
DoviuX is offline
Send a message via Skype™ to DoviuX
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 05-05-2012 , 05:13   Re: How to save arrays to mysql
Reply With Quote #4

Quote:
Originally Posted by DoviuX View Post
Thanks, and will it make achieviments not into one every time but make new or change the existing ones ?
Becouse I have many achieviments and I want that it showed in the website like steams achieviments.
I don't understand. What do you mean with and will it make achieviments not into one every time but make new or change the existing ones?
__________________
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
DoviuX
Senior Member
Join Date: Jun 2009
Location: Lithuania
Old 05-05-2012 , 05:25   Re: How to save arrays to mysql
Reply With Quote #5

I show you an example what i want to do:
Code:
   PlayerIp( or steamid ) - **.**.**.** 
   AchievimentName - Zombie Killer
   AchievimentId - 1

   PlayerIp( or steamid ) - **.**.**.** 
   AchievimentName - Zombie Massacer
   AchievimentId - 2

   PlayerIp( or steamid ) - **.**.**.** 
   AchievimentName - Zombie Destroyer
   AchievimentId - 3
I need that this would be save in mysql, i'am asking by you're gaved code does it make like I showed you now ?
DoviuX is offline
Send a message via Skype™ to DoviuX
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 05-05-2012 , 06:22   Re: How to save arrays to mysql
Reply With Quote #6

PHP Code:
enum Achievements ( <<= )
{
  
ACHIEVEMENT_ZOMBIE_HUNTER 1,
  
ACHIEVEMENT_ZOMBIE_SACRIFICER,
  
ACHIEVEMENT_ZOMBIE_ETC
};

new 
g_iAchievements33 ];

/*
  Player Steam - '%s' - g_cSteam[ 33 ][ 24 ];
  Player IP - '%s' - g_cIP[ 33 ][ 24 ];
  Player Achievements - '%d' - g_iAchievements[ 33 ];
*/

// At plugin attaching
CREATE TABLE IF NOT EXISTS achievements steam TEXTaddress TEXTachievements_list NUMERIC )

// When client joins
SELECT achievements_list FROM achievements WHERE steam '%playersteam%'

// When the function for above query is executed
// If we have a row
g_iAchievementsThisPlayer ] = SQL_ReadResulthQuery);

// Else, if we don't have rows
g_iAchievementsThisPlayer ] = 0;

INSERT INTO achievements VALUES '%playersteam%''%playerip%')

// When a player receive an achievement
if( !( g_iAchivementsThisPlayer ] & ACHIEVEMENT_ZOMBIE_HUNTER ) ) {
  
g_iAchievementsThisPlayer ] |= ACHIEVEMENT_ZOMBIE_HUNTER;

  
UPDATE TABLE achievements SET achievements_list = %playerachievementsWHERE steam '%playersteam%'

__________________

Last edited by claudiuhks; 05-05-2012 at 06:32.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
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 00:32.


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