[Tutorial] [BUD]Blazing User Database | Complete documentation
#5

Part 3:
In this part we will learn how to extract anytime, anywhere data from the columns and set them when we want and where we want.

I will beggin with strings:
GetStringEntry - Get a string from the database
pawn Код:
BUD::GetStringEntry( uid, entry[ ], &value[ ][, size ] )
Will do the work for us.
Parameters:
uid - Unique ID of player
entry[ ] - Name of the column from where we want to extract string
value[ ][, size ] - String to store extracted data

Use:
pawn Код:
new
   rTest[ 30 ],
   iUID = BUD::GetNameUID( GetName( playerid ) )
;
BUD::GetStringEntry( iUID, "Rank", rTest );
printf( "%s", rTest );
-----------------------------------------------------------------------------------
SetStringEntry - Set string directly into the database
pawn Код:
BUD::SetStringEntry( uid, entry[ ], value[ ][, size ] )
Parameters are exactly the same as GetStringEntry.

Use:
pawn Код:
BUD::SetStringEntry( iUID, "Rank", "Newbie" ); // "Newbie" - string which will be stored in the column "Rank"
-----------------------------------------------------------------------------------

GetIntEntry - Extract integrer value
pawn Код:
BUD::GetIntEntry( uid, entry[ ] )
It's easier than string, simply do:
pawn Код:
new
   rTest[ 20 ],
   iUID = BUD::GetNameUID( GetName( playerid ) )
;
format( rTest, 20, "Val: %i", BUD::GetIntEntry( iUID, "Money" ) );
printf( "%i", rTest );
-----------------------------------------------------------------------------------
SetIntEntry - Set integrer value
pawn Код:
BUD::SetIntEntry( uid, entry[ ], value )
Use:
pawn Код:
BUD::SetIntEntry( iUID, "Money", 50 ); // 50 - value we will add
-----------------------------------------------------------------------------------

GetFloatEntry - Extract floats
pawn Код:
BUD::GetFloatEntry( uid, entry[ ] )
Simple and useful:
pawn Код:
new
   rTest[ 50 ],
   iUID = BUD::GetNameUID( GetName( playerid ) )
;
format( rTest, 50, "Val: %f", BUD::GetFloatEntry( iUID, "Health" );
printf( "%f", rTest );
-----------------------------------------------------------------------------------

SetFloatEntry - Set float value
pawn Код:
BUD::SetFloatEntry( uid, entry[ ], Float:value )
Same as integrer:
pawn Код:
BUD::SetFloatEntry( iUID, "Health", 100.00 ) // 100.00 - value which will be set to column "Health"
Done.
ATTENTION: All values set with SetStringEntry, SetIntEntry and SetFloatEntry will replace old values in the database.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)