SA-MP Forums Archive
V.I.P with SQL help... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: V.I.P with SQL help... (/showthread.php?tid=268370)



V.I.P with SQL help... - Edvin - 12.07.2011

Hi, all!

i make this command:
pawn Код:
CMD:setvip( playerid, params[ ] )
{
    new giveplayerid, level;
    new string[ 128 ], Query[ 256 ], DBResult:Resultat;
   
    if ( !IsPlayerAdmin( playerid ) ) return SendClientMessage( playerid, RED, "Only RCON Administrator can use this command!" );
    if ( sscanf( params, "ud", giveplayerid, level ) ) return SendClientMessage( playerid, RED, "USAGE: /setvip [ playerid ] [ level ]" );
    if ( giveplayerid == INVALID_PLAYER_ID ) return SendClientMessage( playerid, RED, "Player Is Not Connected!" );
    if ( level > 3 ) return SendClientMessage( playerid, RED, "Maximum V.I.P level is 3!" );
   
    format( Query, sizeof( Query ), "SELECT * FROM `Vips` WHERE `Nume` = '%s'", PlayerName2( playerid ) );
    Resultat = db_query( Database, Query );
    if ( db_num_rows( Resultat ) )
    {
        P_DATA[ giveplayerid ][ Vip ] = level;
        format( string, sizeof( string ), "Administrator %s has set your V.I.P level to %d!", PlayerName2( playerid ), level );
        SendClientMessage( playerid, ABLUE, string );
        format( Query, sizeof( Query ), "INSERT INTO `Vips` ( `Nume`,`VipLevel` ) VALUES('%s','%d')", PlayerName2( playerid ), level );
        db_free_result( db_query( Database, Query ) );
    }
    else
    {
        format( Query, sizeof( Query ), "UPDATE `Vips` SET ( `VipLevel` = '%d' ) WHERE `Nume` = '%s'", level, PlayerName2( giveplayerid ) );
        db_free_result( db_query( Database, Query ) );
        format( string, sizeof( string ), "Administrator %s has update your V.I.P level to %d", PlayerName2( playerid ), level );
        SendClientMessage( playerid, ABLUE, string );
    }
    return 1;
}
if i have name in the db it not to update my V.I.P level why? it only insert new row with my name and new V.I.P level wat's the problem?


Re: V.I.P with SQL help... - Edvin - 12.07.2011

BUMP...anyone?


Re: V.I.P with SQL help... - Jefff - 12.07.2011

Remove ( )