Commit Transaction error

Started by Cool, Feb 21, 2017, 04:35 PM

Previous topic - Next topic

Cool

Yep Its really hard to type from phone And Thanks its solved it Btw this small mistake waste my 6 hours before posting here i tried many times to solve it :P
I am not locking this topic if i got some problem i will post here because i dont want to create more threads

Cool

No error and nothing its returning
else if ( cmd == "clanrank" )
        {
        if ( RegisteredClans() > 5 ) Message( "** Sorry, the server need min. 5 clans registed from a table of rankings" );
            else
            {
                local Limit = 6, a = 1;
                local q = ::mysql_query( sDB, "SELECT Clan, Kills, Deaths FROM ClanStats ORDER BY Kills DESC LIMIT " + Limit );
               
                if( ::mysql_num_rows( q ) == 1 ){
                local result = ::mysql_fetch_assoc( q );
                local Clan;
                while ( a < Limit )
                {
local Clan = Name = result[ "Name" ].tostring(), Kills = Kills = result[ "Kills" ].tofloat(), Deaths = Deaths = result[ "Deaths" ].tofloat(), Ratio;
                    if ( ( Kills > 0 ) && ( Deaths > 0 ) ) Ratio = Kills / Deaths;
                    else Ratio = 0;
                    Ratio = format ( "%.2f", Ratio );
 
                    if ( a == 1 ) Message( "** 5 Clan's with top kills:" );
                    if ( a == 1 ) (Clan) ? Message( ">> 1. " + Clan + " with " + Kills + " kills - Ratio: " + Ratio ) : Message( "** 1. Position Empty" );
                    else if ( a == 2 ) (Clan) ? Message( ">> 2. " + Clan + " with " + Kills + " kills - Ratio: " + Ratio ) : Message( "** 2. Position Empty" );
                    else if ( a == 3 ) (Clan) ? Message( ">> 3. " + Clan + " with " + Kills + " kills - Ratio: " + Ratio ) : Message( "** 3. Position Empty" );
                    else if ( a == 4 ) (Clan) ? Message( ">> 4. " + Clan + " with " + Kills + " kills - Ratio: " + Ratio ) : Message( "** 4. Position Empty" );
                    else if ( a == 5 ) (Clan) ? Message( ">> 5. " + Clan + " with " + Kills + " kills - Ratio: " + Ratio ) : Message( "** 5. Position Empty" );
                    a ++;
                }
        mysql_free_result( q );
            }             
        }
        }

Thijn

If you're going to limit by 6, you're not going to always get 1 result. You'd get max 6.

So go over your code and fix it yourself.

KAKAN

if ( a == 1 ) Message( "** 5 Clan's with top kills:" );
                    if ( a == 1 ) (Clan) ? Message( ">> 1. " + Clan + " with " + Kills + " kills - Ratio: " + Ratio ) : Message( "** 1. Position Empty" );
                    else if ( a == 2 ) (Clan) ? Message( ">> 2. " + Clan + " with " + Kills + " kills - Ratio: " + Ratio ) : Message( "** 2. Position Empty" );
                    else if ( a == 3 ) (Clan) ? Message( ">> 3. " + Clan + " with " + Kills + " kills - Ratio: " + Ratio ) : Message( "** 3. Position Empty" );
                    else if ( a == 4 ) (Clan) ? Message( ">> 4. " + Clan + " with " + Kills + " kills - Ratio: " + Ratio ) : Message( "** 4. Position Empty" );
                    else if ( a == 5 ) (Clan) ? Message( ">> 5. " + Clan + " with " + Kills + " kills - Ratio: " + Ratio ) : Message( "** 5. Position Empty" );
dafuq did I just see?
if( a >= 1 )
Message( Clan ? format( ">> %i . %s with %i Kills. Ratio: %.2f", a, Clan, Ratio ) : "**" + a + ". Position Empty." );
oh no

Cool


KAKAN

#20
the first if statement, it should check for < 5 and not > 5.
:edit: Test this one, bugs might come, was in a kind of hurry:-
else if( cmd == "clanrank" ){
    local top_ranks_limit = 5;
    if( RegisteredClans() < top_ranks_limit ) return PrivMessage( player, "The server needs atleast 5 registered clans to show a toprank." );
    local q = mysql_query( sDB, "SELECT Clan, Kills, Deaths FROM ClanStats ORDER BY Kills DESC LIMIT " + top_ranks_limit );
    if( mysql_num_rows( q ) == 0 ) return PrivMessage( player, "Something wrong happened and we couldn't complete the action." );
    local result, i = 1;
    Message("** 5 clans with top kills.");
    while( result = mysql_fetch_assoc( q ) ){
        local Clan = result["Clan"],
            Kills = result["Kills"],
            Deaths = result["Deaths"],
            Ratio = format( "%.2f", ( Kills > 0 && Deaths > 0 ) ? Kills/Deaths : 0.00 ),
            szMsg = Clan ? format( ">> %i . %s with %i Kills. Ratio: %.2f", i, Clan, Kills, Ratio ) : "**" + i + ". Position Empty.";
        Message( szMsg );
        i++;
    }

}
oh no

Cool

Error: Float expected for the specified format

KAKAN

Quote from: happymint2 on Feb 23, 2017, 04:14 PMError: Float expected for the specified format
which line? I can't just go and find out the error like that, you need to give us details :) And why not try solving it yourself?
oh no

Cool

Quote from: KAKAN on Feb 23, 2017, 04:31 PM
Quote from: happymint2 on Feb 23, 2017, 04:14 PMError: Float expected for the specified format
which line? I can't just go and find out the error like that, you need to give us details :) And why not try solving it yourself?
Tried but cant solved it :P i never post error without trying to solve :P
error line local Clan = result["Clan"],Between i tried to solve it with :P
local Clan = result["Clan"].tostring(),
            Kills = result["Kills"].tofloat(),
            Deaths = result["Deaths"].tofloat(),

KAKAN

Quote from: happymint2 on Feb 23, 2017, 04:33 PMBetween i tried to solve it with :P
local Clan = result["Clan"].tostring(),
            Kills = result["Kills"].tofloat(),
            Deaths = result["Deaths"].tofloat(),
Still the same error?
If so, I can't do anything. Its been a long time since I last touched Squirrel. Lets wait for someone else.
oh no

Cool

Quote from: KAKAN on Feb 23, 2017, 04:35 PM
Quote from: happymint2 on Feb 23, 2017, 04:33 PMBetween i tried to solve it with :P
local Clan = result["Clan"].tostring(),
            Kills = result["Kills"].tofloat(),
            Deaths = result["Deaths"].tofloat(),
Still the same error?
If so, I can't do anything. Its been a long time since I last touched Squirrel. Lets wait for someone else.
Error is still same :P  i will wait for someone else reply :D

DizzasTeR

local Clan = result["Clan"]
print( type( Clan ) );

Post the result

Cool

Quote from: Doom_Kill3R on Feb 24, 2017, 03:44 AMlocal Clan = result["Clan"]
print( type( Clan ) );

Post the result
string

DizzasTeR

Try
else if( cmd == "clanrank" ){
    local top_ranks_limit = 5;
    if( RegisteredClans() < top_ranks_limit ) return PrivMessage( player, "The server needs atleast 5 registered clans to show a toprank." );
    local q = mysql_query( sDB, "SELECT Clan, Kills, Deaths FROM ClanStats ORDER BY Kills DESC LIMIT " + top_ranks_limit );
    if( mysql_num_rows( q ) == 0 ) return PrivMessage( player, "Something wrong happened and we couldn't complete the action." );
    local result, nrows = mysql_num_rows( q ), i = 0;
    Message("** 5 clans with top kills.");
    while( i < nrows ){
result = mysql_fetch_assoc( q )
        local Clan = result["Clan"],
            Kills = result["Kills"],
            Deaths = result["Deaths"],
            Ratio = format( "%.2f", ( Kills > 0 && Deaths > 0 ) ? Kills/Deaths : 0.00 ),
            szMsg = Clan ? format( ">> %i . %s with %i Kills. Ratio: %.2f", i, Clan, Kills, Ratio ) : "**" + i + ". Position Empty.";
        Message( szMsg );
        i++;
    }

}

Cool