14.03.2013, 17:51
(
Последний раз редактировалось Rock; 20.12.2013 в 15:46.
)
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
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:
-----------------------------------------------------------------------------------
SetStringEntry - Set string directly into the database
Parameters are exactly the same as GetStringEntry.
Use:
-----------------------------------------------------------------------------------
GetIntEntry - Extract integrer value
It's easier than string, simply do:
-----------------------------------------------------------------------------------
SetIntEntry - Set integrer value
Use:
-----------------------------------------------------------------------------------
GetFloatEntry - Extract floats
Simple and useful:
-----------------------------------------------------------------------------------
SetFloatEntry - Set float value
Same as integrer:
Done.
ATTENTION: All values set with SetStringEntry, SetIntEntry and SetFloatEntry will replace old values in the database.
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 ] )
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 ] )
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[ ] )
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 )
pawn Код:
BUD::SetIntEntry( iUID, "Money", 50 ); // 50 - value we will add
GetFloatEntry - Extract floats
pawn Код:
BUD::GetFloatEntry( uid, entry[ ] )
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 )
pawn Код:
BUD::SetFloatEntry( iUID, "Health", 100.00 ) // 100.00 - value which will be set to column "Health"
ATTENTION: All values set with SetStringEntry, SetIntEntry and SetFloatEntry will replace old values in the database.