How to set player money in MYSQL
#1

Hi. How can I set playermoney in MYSQL ?

PHP код:
enum playerinfo
{
money
...
cache_get_field_content(0"Money"tmp), pInfo[playerid][Money] = strval(tmp); 
or how? Because if I do so, the GivePlayerMoney it won't work
Reply
#2

it's get, not set.
you have to use UPDATE function from MySQL

for example: (with MySQL R39)
PHP код:
new sqlquery[512],name[28];
GetPlayerName(playerid,name,28);
mysql_format(handle,sqlquery,512,"UPDATE `account` SET `Money` = '%d' WHERE `Name` = '%s'",GetPlayerMoney(playerid),name);
mysql_query(handle,query); 
Reply
#3

Server Side Money or custom money?
Reply
#4

depends what you want to set. (probably server-sided)
P.S. you must set SQL table name and your decided params in this format. (copying this will not work)
Reply
#5

Quote:
Originally Posted by Mugala
Посмотреть сообщение
depends what you want to set. (probably server-sided)
P.S. you must set SQL table name and your decided params in this format. (copying this will not work)
PHP код:
new Query[1100];
    
strcat(Query,"UPDATE `users` SET  `Money` = '%i' WHERE `Username` = '%s'");
    
format(Query,sizeof(Query),Query,
    
pInfo[playerid][Money],
    
PlayerName(playerid));
    
mysql_tquery(handleQuery"""");
    
printf("%s"Query);
    return 
1;

Reply
#6

exactly! but I don't think that mysql_tquery is needed for this function, you're not using threaded queries here, just mysql_query will be enough.
Reply
#7

Quote:
Originally Posted by Mugala
Посмотреть сообщение
exactly! but I don't think that mysql_tquery is needed for this function, you're not using threaded queries here, just mysql_query will be enough.
And, if I want to do

PHP код:
pInfo[playerid][Money] = -20
it will set - 20. But how can I set to make it to set -20 OF current value?
Reply
#8

pInfo[playerid][Money] -= 20;

or pInfo[playerid][Money] += -20; second one is funny.
Reply
#9

Quote:
Originally Posted by Mugala
Посмотреть сообщение
pInfo[playerid][Money] -= 20;

or pInfo[playerid][Money] += -20; second one is funny.
Thank you, can someone hack mysql (With cheats, in game) and modify their money?
Reply
#10

of course not, it's your data, unless you don't share MySQL params (user,password)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)