Player money need help
#1

Hello community i have one big problem in my GM . Money of players didn't save before they disconnect .
second:
I wanna set money for players when they register to 50k in cash and 50k in bank

Quote:

my code
public OnPlayerDisconnect(playerid, reason)
{
new str[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
PlayerInfo[ playerid ][ pStatus ] = 0;
mysql_format(mysql_db, str, sizeof(str),"UPDATE `users` SET `Status` = '0' WHERE `Name` = '%e'", name);
mysql_tquery(mysql_db, str);
OnPlayerSave(playerid);
switch(reason)
{
case 0:
{
format(str,sizeof(str), "Jucatorul %s [id: %d] a parasit serverul. (Lost Connection | Crash)", name,playerid);
ProxDetector(30.0, playerid, str, COLOR_MESS, COLOR_MESS, COLOR_MESS, COLOR_MESS, COLOR_MESS);
}
case 1:
{
format(str,sizeof(str), "Jucatorul %s [id: %d] a parasit serverul. (Quit)", name,playerid);
ProxDetector(30.0, playerid, str, COLOR_MESS, COLOR_MESS, COLOR_MESS, COLOR_MESS, COLOR_MESS);
}
case 2:
{
format(str,sizeof(str), "Jucatorul %s [id: %d] a parasit serverul. (Kick | Ban)", name,playerid);
ProxDetector(30.0, playerid, str, COLOR_MESS, COLOR_MESS, COLOR_MESS, COLOR_MESS, COLOR_MESS);
}
}
if(player_family [ playerid ])family_info [ player_family [ playerid ]] [ f_online ]--;

Reply
#2

Hey,
Show us "OnPlayerSave" function
Reply
#3

add this on public OnPlayerDisconnect

Quote:

SavePlayer(playerid);

Reply
#4

@Bomber07 "SavePlayer" is custom function just like "OnPlayerSave" in his/her case.
Reply
#5

define OnPlayerSave? or
Quote:

public SaveAccounts()
{
foreach(Player, i)
{
OnPlayerSave(i);
if(PlayerInfo[i][pJob] > 0)
{
if(PlayerInfo[i][pContractTime] < 25)
{
PlayerInfo[i][pContractTime] ++;
}
}
}

Reply
#6

show where OnPlayerSave giving her action
Reply
#7

Show us the public or the stock "OnPlayerSave"
Reply
#8

that is all about OnPlayerSave

Quote:

forward OnPlayerSave(playerid);

public OnPlayerDisconnect(playerid, reason)
{
new str[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
PlayerInfo[ playerid ][ pStatus ] = 0;
mysql_format(mysql_db, str, sizeof(str),"UPDATE `users` SET `Status` = '0' WHERE `Name` = '%e'", name);
mysql_tquery(mysql_db, str);
OnPlayerSave(playerid);
switch(reason)
{
case 0:
{
format(str,sizeof(str), "Jucatorul %s [id: %d] a parasit serverul. (Lost Connection | Crash)", name,playerid);
ProxDetector(30.0, playerid, str, COLOR_MESS, COLOR_MESS, COLOR_MESS, COLOR_MESS, COLOR_MESS);
}
case 1:
{
format(str,sizeof(str), "Jucatorul %s [id: %d] a parasit serverul. (Quit)", name,playerid);
ProxDetector(30.0, playerid, str, COLOR_MESS, COLOR_MESS, COLOR_MESS, COLOR_MESS, COLOR_MESS);
}
case 2:
{
format(str,sizeof(str), "Jucatorul %s [id: %d] a parasit serverul. (Kick | Ban)", name,playerid);
ProxDetector(30.0, playerid, str, COLOR_MESS, COLOR_MESS, COLOR_MESS, COLOR_MESS, COLOR_MESS);
}
}
if(player_family [ playerid ])family_info [ player_family [ playerid ]] [ f_online ]--;



public GameModeInitExitFunc()
{
new string[128];
format(string, sizeof(string), "SERVER RESTART");
foreach(Player, i)
{
DisablePlayerCheckpoint(i);
gPlayerCheckpointStatus[i] = CHECKPOINT_NONE;
GameTextForPlayer(i, string, 4000, 5);
SetPlayerCameraPos(i,1460.0, -1324.0, 287.2);
SetPlayerCameraLookAt(i,1374.5, -1291.1, 239.0);
OnPlayerSave(i);
gPlayerLogged[i] = 0;
}
db_close ( db_tbans );
mysql_close ( mysql_db );
print ( "-> Dealership unloaded" );
SetTimer("GameModeExitFunc", 4000, 0);
return 1;

public OnPlayerSave(playerid)
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid])
{
new pName[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, pName, MAX_PLAYER_NAME );
szQuery[ 0 ] = EOS;

MYSQL
Quote:

mysql_format( mysql_db, szQuery, sizeof( szQuery ), "UPDATE `users` SET Money=%d WHERE `Name` = '%e'",PlayerInfo[playerid][pCash], pName);mysql_tquery( mysql_db, szQuery );
mysql_format( mysql_db, szQuery, sizeof( szQuery ), "UPDATE `users` SET Bank=%d WHERE `Name` = '%e'",PlayerInfo[playerid][pAccount], pName);mysql_tquery( mysql_db, szQuery );

Reply
#9

wtf this ?
Reply
#10

Quote:

PlayerInfo[playerid][pCash]

You use server side for anti-money cheat ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)