script not updating DATABASE

Started by Nihongo^, Dec 05, 2017, 09:31 AM

Previous topic - Next topic

Nihongo^

Hello iam trying to add gems on my script

ok to save gems stats my friend use savestats function which mean if the player left the server, script store his info ( gems ) into database
Quotefunction SaveStatus( player )
{
   QuerySQL(db, "UPDATE Accounts SET Gems = '"+status[ player.ID ].Gems+"', GemsRange = '"+status[ player.ID ].GemsRange+ "' WHERE Name = '"+ player.Name +"'");
   print( "saved status of player: "+player.Name+"." );
}

but i remove the savestats function and add this

Quotefunction IncGems( player )
{
   
        local Calc = PlayerGems( player ) + 1;
        local query1 = format( "UPDATE Account SET Gems=%i WHERE Name='" + player.Name +"'", Calc );
        QuerySQL( db, query1 );
   
}
function PlayerGems( player )
{
    local name = player.Name;
    local Answer = QuerySQL( db, "SELECT Kills, Deaths, Joins, Gems FROM Account WHERE Name='" + player.Name +"' COLLATE NOCASE" );
    local Gems = GetSQLColumnData( Answer, 0 );
    if ( !Gems ) return 0;
    else return Gems;
    FreeSQLQuery( Answer );
}

But the script is not updating the gems value in db also what is the use of this value

Quotelocal Gems = GetSQLColumnData( Answer, 0 );

why we put the 0 ?. I saw on my cash function it was 2


Nihongo^

Rip this forum man nobodys helping me

Mohamed Boubekri

What u Man, i Don't Understand Anything.
Man just Use The Fuzzie Account System, Its very Good.
P.S Your English RAPED.
Good Luck.
| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].

Mohamed Boubekri

#3
Try To Add it For function OnPlayerJoin & OnPlayerPart.
SaveStatus( player );GL.
| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].

Nihongo^


Mohamed Boubekri

Fast Go School And Learn how to talk English
Good Luck.
| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].

Xmair

Quote from: Mohamed on Dec 06, 2017, 07:26 AMFast Go School And Learn how to talk English
Good Luck.
I suggest you to do the same.

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

Mohamed Boubekri

Quote from: Xmair on Dec 06, 2017, 09:06 AM
Quote from: Mohamed on Dec 06, 2017, 07:26 AMFast Go School And Learn how to talk English
Good Luck.
I suggest you to do the same.
Nah, i Already Learned
i Suggest You To Do the Same.
| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].

!

#8
Quote from: Mohamed on Dec 06, 2017, 09:35 AM
Quote from: Xmair on Dec 06, 2017, 09:06 AM
Quote from: Mohamed on Dec 06, 2017, 07:26 AMFast Go School And Learn how to talk English
Good Luck.
I suggest you to do the same.
Nah, i Already Learned
i Suggest You To Do the Same.
Lol and what was the reason of suggesting him Fuzzie Account System if you don't even know what he needs.

Quote from: Mohamed on Dec 05, 2017, 06:30 PMWhat u Man, i Don't Understand Anything.
Man just Use The Fuzzie Account System, Its very Good.
P.S Your English RAPED.
Good Luck.
Now we all know who needs to go to school.



@Nihongo^ try this
function IncGems( player )
{
   local Calc = PlayerGems( player ) + 1;
   QuerySQL( db, "UPDATE Account SET Gems='"+Calc+"' WHERE Name='"+player.Name+"'" );
}
function PlayerGems( player )
{
   local query = QuerySQL( db, "SELECT Gems FROM Account WHERE Name='"+player.Name+"'" );

   if ( !query ) return 0;

   local Gems = GetSQLColumnData( query, 0 );
   FreeSQLQuery( query );

   return Gems.tointeger();
}

Discord: zeus#5155