saving score Help Plz Plz
#1

All Other Things are saving except player score Help Me with that plx
Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",Player[playerid][pPass]);
    INI_Int("Cash",Player[playerid][pCash]);
    INI_Int("Admin",Player[playerid][pAdmin]);
    INI_Int("Kills",Player[playerid][pKills]);
    INI_Int("Deaths",Player[playerid][pDeaths]);
    INI_Int("Score",Player[playerid][pScore]);
    INI_Int("Skin",Player[playerid][Skin]);
    INI_Int("Color",Player[playerid][pcolor]);
    INI_Int("Ban",Player[playerid][pBan]);
    INI_Int("Team",gTeam[playerid]);
    INI_Int("Ninja",Player[playerid][pninja]);		
	INI_Int("clothes",Player[playerid][pclothes]);
	INI_Int("ninjaskin",Player[playerid][pskin]);
	return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
	SendDeathMessage(killerid, playerid, reason);
	if(killerid != INVALID_PLAYER_ID)
	{
	 SetPlayerScore (killerid, GetPlayerScore (killerid) + 1);
	}
        Player[killerid][pScore]++;
	Player[killerid][pKills]++;
   	Player[playerid][pDeaths]++;
	GivePlayerMoney(killerid,2);
	return 1;
}


stock SavePlayerData(playerid)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",Player[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",Player[playerid][pKills]);
    INI_WriteInt(File,"Deaths",Player[playerid][pDeaths]);
    INI_WriteInt(File,"Score",GetPlayerScore(playerid));
    INI_WriteInt(File,"Skin",Player[playerid][Skin]);
    INI_WriteInt(File,"Ban",Player[playerid][pBan]);
    INI_WriteInt(File,"Color",GetPlayerColor(playerid));
	INI_WriteInt(File,"Team",gTeam[playerid]);
	INI_WriteInt(File,"Ninja",Player[playerid][pninja]);
	INI_WriteInt(File,"clothes",Player[playerid][pclothes]);
	INI_WriteInt(File,"ninjaskin",Player[playerid][pskin]);
	INI_Close(File);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
   SendDeathMessage(INVALID_PLAYER_ID,playerid,201);
    SavePlayerData(playerid);
    return 1;
}
Reply
#2

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	SendDeathMessage(killerid, playerid, reason);
	SetPlayerScore (killerid, GetPlayerScore (killerid) + 1);
        Player[killerid][pScore]++;
	Player[killerid][pKills]++;
   	Player[playerid][pDeaths]++;
	GivePlayerMoney(killerid,2);
	return 1;
}
----------------

This's useless:
Код:
if(killerid != INVALID_PLAYER_ID)
- *Just saying* I think there's no need for [pScore], You can use SetPlayerScore instead
Reply
#3

Ok let me try i HOpe it Work
Reply
#4

Quote:
Originally Posted by RowdyrideR
Посмотреть сообщение
This's useless:
Код:
if(killerid != INVALID_PLAYER_ID)
No, this is isn't.

What about this:

pawn Код:
new pKills[MAX_PLAYERS]; // By default, it is pKills[500];

public OnPlayerDeath(playerid,killerid,reason)
{
    // killerid may be INVALID_PLAYER_ID, it means killerid = 65535
    pKills[killerid] ++;
    // There is a big mistake here, pKills doesn't have 65536 cells, so we don't have a 65535 cell id.
   return 1;
}
Accessing invalid cell id's will give you big problems.
Reply
#5

No it still not saving Player Score Plz Help
Reply
#6

public OnPlayerConnect add
pawn Код:
SetPlayerScore(playerid,Player[playerid][pScore]);
Reply
#7

Where i can put On Player Connect?
Код:
public OnPlayerConnect(playerid)
{
	SendDeathMessage(INVALID_PLAYER_ID,playerid,200);
    ClassChosen[playerid] = 0;
   	PlayerPlaySound(playerid, 1185, -1753.6743,885.2703,295.8750);
	if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
		TogglePlayerSpectating(playerid, true);
		PAccount[playerid]=1;
	
	}
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
        PAccount[playerid]=0;
	}
	return 1;
}
Reply
#8

Quote:
Originally Posted by MBilal
Посмотреть сообщение
Where i can put On Player Connect?
pawn Код:
public OnPlayerConnect(playerid)
{
    SendDeathMessage(INVALID_PLAYER_ID,playerid,200);
    ClassChosen[playerid] = 0;
    PlayerPlaySound(playerid, 1185, -1753.6743,885.2703,295.8750);
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);//that are the loading of the player data , so we are going to use it there
        SetPlayerScore(playerid,Player[playerid][pScore]);
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
        TogglePlayerSpectating(playerid, true);
        PAccount[playerid]=1;
   
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
        PAccount[playerid]=0;
    }
    return 1;
}
Reply
#9

Thanks its Work Dude !!!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)