Mysql - read value from Table WHERE id=x
#1

I have table name "factions" and i want to extract the value of a row "groupSlots" WHERE id=1 (for faction id=1)

i've tried this
Код:
stock GetFactionSlots( FactionID )
{
	new szString[ 128 ], Cache: Result, Get[ 2 ], szFacSlots[ MAX_PLAYER_NAME ];
	format( szString, sizeof( szString ), "SELECT `groupSlots` FROM `factions` WHERE `ID` = %d ;", FactionID );
    Result = mysql_query( SQL, szString );
    cache_get_data( Get[ 0 ], Get[ 1 ], SQL );
    if( !Get[ 0 ] ) szFacSlots = "No-One";
   	 else cache_get_field_content( 0, "groupSlots", szFacSlots, SQL, sizeof( szFacSlots ) );
    cache_delete( Result );
	return ( szFacSlots );
}
and in cmd:factions
Код:
new szString[ 1200 ];			
	format( szString, sizeof( szString ), "{0059FF}Police Departament 		{ffffff}-	Lider: %s (%s) - Membri: %d/%d\n", GetFactionLeader( 1 ), IsOnline( GetFactionLeader( 1 ) ), GetFactionMembers( 1 ) , GetFactionSlots( 1 ) );
groupSlots for faction id 1 value is 6
but on server when running "/factions" returns me something else...
Reply
#2

First of all, this is has nothing to do with 0.3.7 version. It's a scripting issue; thus it should've been posted in "Scripting Help" section.

Also GetFactionSlots returns the result as a string and you used in the command /factions %d specifier which is for integers. So change it to %s specifier.
Reply
#3

Thank you very much and sorry for this wrong section in wich i've posted my thread.

Hace a good day .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)