Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] mysql server problem

 
  • 0 Vote(s) - 0 Average
Pawn mysql server problem
Trox
Offline

Burgershot Member
Posts: 4
Threads: 4
Joined: May 2019
Reputation: 0
#1
2019-05-06, 09:10 PM
yo guys . ive tried to make a lottery system in the past few hours but the problem is that i save the variable in mysql all ok. The thing is that i have to relog to see my money . Anyone knows how can i save it and at the same time have it *instantly* on the server?

CODE :

Code:
 for(new i, j = cache_get_row_count (); i < j; i++) {
       cache_get_field_content(i, "name", szResult); format(name, 256, szResult);
       cache_get_field_content(i, "Money", moneyss);
       new money = strval(moneyss)+50000;
       x++;
       new szQuery2[256];
       mysql_format(SQL, szQuery2, sizeof(szQuery2), "UPDATE `users` SET `Money`='%d' WHERE `name`='%s'", money, name);
       mysql_tquery(SQL,szQuery2, "", "");
     
       format(string, sizeof(string), "{FFFFFF}The winner is: {FF0000}%s", name);
       MsjL(COLOR_WHITE, string);
   }

*i dont receive any error the only problem is that i have to relog to have my money
JustMichael
Offline

Forum Manager

Posts: 189
Threads: 3
Joined: Feb 2019
Reputation: 17
Location: England
#2
2019-05-06, 11:47 PM
That would be because you need to call `GivePlayerMoney` with the variable `money` so the player see's the amount.

Normally you would store the amount of money a player as in a variable and so something like this

Code:
new money = 5000;
GivePlayerMoney(playerid, PlayerData[playerid][pMoney] + money);

of course no sane person would do it like that, and would instead have a function that does this correctly.
Remember to always refer to J0sh as `J0sh...`

@ Networks/Servers
San Andreas Gaming Network (Owner/Founder)
San Andreas Gaming (Owner/Founder)
Grand Theft Cop's n Robber's (Owner)
Britannia Roleplay (Owner/Founder)
Alpine RP (Owner/Founder)
Aluminium Network (Maintainer)
AlphaDM (Tech Support)

# Services
Burgershot.gg (Forum Manager)
open.mp (Member)

~ Languages/Frameworks
Pawn, C, C++, C#, Javascript, Typescript, Lua, Python, Go, Rust, PHP, SQL,
Angular, React, Vue, Svelte, Laravel, Rocket
unix
Offline

Burgershot Member
Posts: 20
Threads: 5
Joined: Apr 2019
Reputation: 1
Location: Kosovo
#3
2019-05-08, 08:50 PM
^ Use that as above when a player respawns or dies or whatsoever, else you can just function a loop every 5 minutes (or if u have any loop that goes through connected players)

example:
Code:
for(new i = 0; i != MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
ResetPlayerMoney(i);
GivePlayerMoney(playerid, PlayerData[playerid][pMoney] );
}
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode