Money Saving Issue. REP+
#1

Helpme with my money sytem when a player dissconects his money save but when he connects to server again they are not given to him I dont know why? Is there something I can do to fix it here is my code.
pawn Код:
public OnPlayerConnect(playerid)
{
   
    new string[128];
    new plname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, plname, sizeof(plname));
    PlayerInfo[playerid][pLevel] = 0;
    PlayerInfo[playerid][pCash] = 0;
    PlayerInfo[playerid][pDriveLic] = 0;
    PlayerInfo[playerid][pVip] = 0;
    PlayerInfo[playerid][pAdmin] = 0;
    PlayerInfo[playerid][pTester] = 0;
    PlayerInfo[playerid][pGuard] = 0;
    PlayerInfo[playerid][pVampire] = 0;
    PlayerInfo[playerid][pSpawn] = 0;
    PlayerInfo[playerid][pSex] = 0;
    RefuelTime[playerid] = 0;
    TrackCar[playerid] = 0;
    PlayerInfo[playerid][pAge] = 0;
    PlayerInfo[playerid][pOrigin] = 0;
    PlayerInfo[playerid][pModel] = 23;
    PlayerInfo[playerid][pLocked] = 0;
    PlayerInfo[playerid][pExp] = 0;
    PlayerInfo[playerid][pWarns] = 0;
    PlayerNeedsHelp[playerid] = 0;
    Mobile[playerid] = 255;
    PlayerInfo[playerid][pMuted] = 0;
    PlayerInfo[playerid][pMuteTime] = 0;
    gPlayerTutorialing[playerid] = 0;
    format(string, sizeof(string), "/Users/%s.ini", plname);
    new DialogString[1024];
    format(DialogString, sizeof DialogString, "%s%s%s%s%s%s%s%s", reg1, reg2, reg3, reg4, reg5, reg6, reg7, reg8);
    ShowPlayerDialog(playerid,1234, DIALOG_STYLE_MSGBOX,"Introduction", DialogString,"Accept","Decline");

    Textdraw98[playerid] = TextDrawCreate(146.000000, 203.000000, " "); // Tutorial
    TextDrawBackgroundColor(Textdraw98[playerid], 255);
    TextDrawUseBox(Textdraw98[playerid] , 1);
    TextDrawFont(Textdraw98[playerid], 1);
    TextDrawBoxColor(Textdraw98[playerid] ,0x00000066);
    TextDrawLetterSize(Textdraw98[playerid], 0.289899, 1.099900);
    TextDrawColor(Textdraw98[playerid], 13107455);
    TextDrawSetOutline(Textdraw98[playerid], 1);
    TextDrawSetProportional(Textdraw98[playerid], 1);
    TextDrawAlignment(Textdraw98[playerid],2);
    GivePlayerCash(playerid, PlayerInfo[playerid][pCash]);
    SetPlayerSkin(playerid, PlayerInfo[playerid][pModel]);
    SetOriginalColor(playerid);
    return 1;
}
On Player Connect
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File, "Level",PlayerInfo[playerid][pLevel]);
    INI_WriteInt(File, "Money",GetPlayerMoney(playerid));
    INI_WriteInt(File, "Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File, "Tester",PlayerInfo[playerid][pTester]);
    INI_WriteInt(File, "Guard",PlayerInfo[playerid][pGuard]);
    INI_WriteInt(File, "Vampire",PlayerInfo[playerid][pVampire]);
    INI_WriteInt(File, "Vip",PlayerInfo[playerid][pVip]);
    INI_WriteInt(File, "Spawn",PlayerInfo[playerid][pSpawn]);
    INI_WriteInt(File, "Model",PlayerInfo[playerid][pModel]);
    INI_WriteInt(File, "Locked",PlayerInfo[playerid][pLocked]);
    INI_WriteInt(File, "FirstJoined", PlayerInfo[playerid][pFirstJoined]);
    INI_WriteInt(File, "Sex", PlayerInfo[playerid][pSex]);
    INI_WriteInt(File, "Age", PlayerInfo[playerid][pAge]);
    INI_WriteInt(File, "Origin", PlayerInfo[playerid][pOrigin]);
    INI_WriteInt(File, "Respect", PlayerInfo[playerid][pExp]);
    INI_WriteInt(File, "Warns", PlayerInfo[playerid][pWarns]);
    INI_WriteInt(File, "Selected", PlayerInfo[playerid][pSelected]);
    INI_WriteInt(File, "Continent", PlayerInfo[playerid][pPlace]);
    INI_WriteInt(File, "Muted", PlayerInfo[playerid][pMuted]);
    INI_WriteInt(File, "MuteTime", PlayerInfo[playerid][pMuteTime]);
    INI_WriteInt(File, "Ph", PlayerInfo[playerid][pNumber]);
    INI_WriteInt(File, "DriveLic", PlayerInfo[playerid][pDriveLic]);
    INI_Close(File);
    return 1;
}
OnPlayerDissconnect

pawn Код:
public OnPlayerSpawn(playerid)
{
    if(PlayerInfo[playerid][pSelected] == 0)
    {
        new sexthings[] = "1\tMale \n2\tFemale";
        ShowPlayerDialog(playerid,155,DIALOG_STYLE_LIST,"[IC INFORMATION]Select Your Sex",sexthings,"Select","Quit");
        SetPlayerPos(playerid, -2824.3604,-461.9743,7.1875);
        gPlayerRegStep[playerid] = 1;
        new randphone = 100000 + random(899999);
        PlayerInfo[playerid][pNumber] = randphone;
        return 1;
    }
    if(PlayerInfo[playerid][pFirstJoined] == 0)
    {

        gPlayerTutorialing[playerid] = 1;
        SetPlayerHealth(playerid,100);
        SetPlayerPos(playerid,-2824.3604,-461.9743,7.1875);
        SetPlayerCameraPos(playerid,-2824.3604,-461.9743,7.1875);
        SetPlayerCameraLookAt(playerid,-2824.3604,-461.9743,7.1875);
        SendClientMessage(playerid,COLOR_LIGHTRED,"Spawned into the college you, Use /help and helpme for further assistance");
        SendClientMessage(playerid,COLOR_YELLOW,"Use Space Bar to proceed");
        SetPlayerSkin(playerid, PlayerInfo[playerid][pModel]);
        return 1;
    }
    if(gPlayerLogged[playerid] == 0)
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "[SERVER] This server requires a Login before spawn [Kicked]");
        Kick(playerid);
    }
    SetPlayerPos(playerid, -2824.3604,-461.9743,7.1875);
    SetPlayerInterior(playerid,0);
    SetPlayerVirtualWorld(playerid, 0);
    SetOriginalColor(playerid);
    SetPlayerSkin(playerid, PlayerInfo[playerid][pModel]);
    ResetPlayerMoney(playerid);
    GivePlayerCash(playerid, PlayerInfo[playerid][pCash]);

    return 1;
}
OnPlayer Spawn

Here please help me withit I am asking help from many days but no one seems to help me REP + For that if you help me.
Reply
#2

ResetPlayerMoney(playerid);

That might be why
Reply
#3

I added it dosent affect.
Reply
#4

Anyone?
Reply
#5

He Meant you should remove it.
Reply
#6

remove

pawn Код:
INI_WriteInt(File, "Money",GetPlayerMoney(playerid));
and add
pawn Код:
INI_WriteInt(File, "Money",PlayerInfo[playerid][pCash]);
then

pawn Код:
public OnPlayerSpawn(playerid)
{
    if(PlayerInfo[playerid][pSelected] == 0)
    {
        new sexthings[] = "1\tMale \n2\tFemale";
        ShowPlayerDialog(playerid,155,DIALOG_STYLE_LIST,"[IC INFORMATION]Select Your Sex",sexthings,"Select","Quit");
        SetPlayerPos(playerid, -2824.3604,-461.9743,7.1875);
        gPlayerRegStep[playerid] = 1;
        new randphone = 100000 + random(899999);
        PlayerInfo[playerid][pNumber] = randphone;
        return 1;
    }
    if(PlayerInfo[playerid][pFirstJoined] == 0)
    {

        gPlayerTutorialing[playerid] = 1;
        SetPlayerHealth(playerid,100);
        SetPlayerPos(playerid,-2824.3604,-461.9743,7.1875);
        SetPlayerCameraPos(playerid,-2824.3604,-461.9743,7.1875);
        SetPlayerCameraLookAt(playerid,-2824.3604,-461.9743,7.1875);
        SendClientMessage(playerid,COLOR_LIGHTRED,"Spawned into the college you, Use /help and helpme for further assistance");
        SendClientMessage(playerid,COLOR_YELLOW,"Use Space Bar to proceed");
        SetPlayerSkin(playerid, PlayerInfo[playerid][pModel]);
        return 1;
    }
    if(gPlayerLogged[playerid] == 0)
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "[SERVER] This server requires a Login before spawn [Kicked]");
        Kick(playerid);
    }
    SetPlayerPos(playerid, -2824.3604,-461.9743,7.1875);
    SetPlayerInterior(playerid,0);
    SetPlayerVirtualWorld(playerid, 0);
    SetOriginalColor(playerid);
    SetPlayerSkin(playerid, PlayerInfo[playerid][pModel]);
    ResetPlayerMoney(playerid);
    SetPlayerMoney(playerid, PlayerInfo[playerid][pCash]);

    return 1;
}
Reply
#7

Quote:
Originally Posted by mahdi499
Посмотреть сообщение
He Meant you should remove it.
Adding or removing is not causing any change is there something else I can do?
Reply
#8

pawn Код:
stock GivePlayerCash(playerid, money)
{
    PlayerInfo[playerid][pCash] += money;
    ResetMoneyBar(playerid);//Resets the money in the original moneybar, Do not remove!
    UpdateMoneyBar(playerid,PlayerInfo[playerid][pCash]);//Sets the money in the moneybar to the serverside cash, Do not remove!
    return PlayerInfo[playerid][pCash];
}
stock SetPlayerCash(playerid, money)
{
    PlayerInfo[playerid][pCash] = money;
    ResetMoneyBar(playerid);//Resets the money in the original moneybar, Do not remove!
    UpdateMoneyBar(playerid,PlayerInfo[playerid][pCash]);//Sets the money in the moneybar to the serverside cash, Do not remove!
    return PlayerInfo[playerid][pCash];
}
stock ResetPlayerCash(playerid)
{
    PlayerInfo[playerid][pCash] = 0;
    ResetMoneyBar(playerid);//Resets the money in the original moneybar, Do not remove!
    UpdateMoneyBar(playerid,PlayerInfo[playerid][pCash]);//Sets the money in the moneybar to the serverside cash, Do not remove!
    return PlayerInfo[playerid][pCash];
}
stock GetPlayerCash(playerid)
{
    return PlayerInfo[playerid][pCash];
}
This server side function is also there.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)