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 , 05:25   Re: How to save arrays to mysql
Reply With Quote #1

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 #2

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