15.08.2015, 12:59
Quote:
Код:
stock textdraw(playerid) { if(IsPlayerConnected(playerid)) { new pscore[127]; format(pscore, sizeof(pscore), "Score : ~y~%d" ,GetPlayerScore(playerid)); PlayerTextDrawSetString(playerid, Textdraw1[playerid], pscore); //new pname[128]; new names[MAX_PLAYER_NAME]; GetPlayerName(playerid, names, sizeof(names)); format(names, sizeof(names),"Name : ~y~%s" ,names); PlayerTextDrawSetString(playerid, Textdraw2[playerid], names); new prank[129]; format(prank, sizeof(prank), "Rank : ~y~%s" ,GetRankName(playerid)); PlayerTextDrawSetString(playerid, Textdraw3[playerid], prank); new pclass[130]; format(pclass, sizeof(pclass), "Class : ~y~%s" ,GetClass(playerid)); PlayerTextDrawSetString(playerid, Textdraw4[playerid], pclass); new pkill[131]; format(pkill, sizeof(pkill), "Kills : ~y~%d" ,PlayerInfo[playerid][Kills]); PlayerTextDrawSetString(playerid, Textdraw5[playerid], pkill); new pdeath[132]; format(pdeath, sizeof(pdeath), "Deaths : ~y~%d" ,PlayerInfo[playerid][Deaths]); PlayerTextDrawSetString(playerid, Textdraw6[playerid], pdeath); new pdkill; new pdkills[100]; if(PlayerInfo[playerid][Deaths] == 0) pdkill = 1; else pdkill = PlayerInfo[playerid][Deaths]; format(pdkills, sizeof(pdkills), "K/D Ratio : ~y~%0.2f" ,Float:PlayerInfo[playerid][Kills]/Float:pdkill); PlayerTextDrawSetString(playerid, Textdraw7[playerid], pdkills); new pip[136]; new tmp33[50]; GetPlayerIp(playerid,tmp33,50); format(pip,sizeof(pip),"IP : ~y~%s", tmp33); PlayerTextDrawSetString(playerid, Textdraw8[playerid], pip); new phealthw[137]; new Float:armour; GetPlayerArmour(playerid, armour); format(phealthw, sizeof(phealthw),"%0.0f", armour); PlayerTextDrawSetString(playerid, healthcount[playerid], phealthw); new phealthr[137]; new Float:health; GetPlayerHealth(playerid,health); format(phealthr, sizeof(phealthr),"%0.0f", health); PlayerTextDrawSetString(playerid, healthcount1[playerid], phealthr); new ping[138]; format(ping,sizeof(ping),"Ping : ~r~%i",GetPlayerPing(playerid)); PlayerTextDrawSetString(playerid, TextPing[playerid], ping); } } public OnPlayerConnect(playerid) { Textdraw1[playerid] = CreatePlayerTextDraw(playerid, 9.375000, 160.416641, "Score :"); PlayerTextDrawLetterSize(playerid, Textdraw1[playerid], 0.240624, 1.016666); PlayerTextDrawAlignment(playerid, Textdraw1[playerid], 1); PlayerTextDrawColor(playerid, Textdraw1[playerid], -5963521); PlayerTextDrawSetShadow(playerid, Textdraw1[playerid], 0); PlayerTextDrawSetOutline(playerid, Textdraw1[playerid], 1); PlayerTextDrawBackgroundColor(playerid, Textdraw1[playerid], 51); PlayerTextDrawFont(playerid, Textdraw1[playerid], 1); PlayerTextDrawSetProportional(playerid, Textdraw1[playerid], 1); return 1; } public OnPlayerSpawn(playerid) { PlayerTextDrawShow(playerid,Textdraw1[playerid]); return 1; } public OnPlayerDeath(playerid) { PlayerTextDrawHide(playerid,Textdraw1[playerid]); return 1; } Like this if(IsPlayerConnected(killerid) && killerid != INVALID_PLAYER_ID) { textdraw(killerid); // this will update player stats who kill other player. } and also textdraw(playerid); that will update stats of player who die. And now you asking how to set and show stats when player connect when he login do that textdraw(playerid); his stats updated to his recent stats on the server which you saved. |
PHP код:
public OnPlayerUpdate
{
if(IsPlayerConnected(playerid))
{
new pscore[127];
format(pscore, sizeof(pscore), "Score : ~y~%d" ,GetPlayerScore(playerid));
PlayerTextDrawSetString(playerid, Textdraw1[playerid], pscore);
//new pname[128];
new names[MAX_PLAYER_NAME];
GetPlayerName(playerid, names, sizeof(names));
format(names, sizeof(names),"Name : ~y~%s" ,names);
PlayerTextDrawSetString(playerid, Textdraw2[playerid], names);
new prank[129];
format(prank, sizeof(prank), "Rank : ~y~%s" ,GetRankName(playerid));
PlayerTextDrawSetString(playerid, Textdraw3[playerid], prank);
new pclass[130];
format(pclass, sizeof(pclass), "Class : ~y~%s" ,GetClass(playerid));
PlayerTextDrawSetString(playerid, Textdraw4[playerid], pclass);
new pkill[131];
format(pkill, sizeof(pkill), "Kills : ~y~%d" ,PlayerInfo[playerid][Kills]);
PlayerTextDrawSetString(playerid, Textdraw5[playerid], pkill);
new pdeath[132];
format(pdeath, sizeof(pdeath), "Deaths : ~y~%d" ,PlayerInfo[playerid][Deaths]);
PlayerTextDrawSetString(playerid, Textdraw6[playerid], pdeath);
new pdkill;
new pdkills[100];
if(PlayerInfo[playerid][Deaths] == 0) pdkill = 1; else pdkill = PlayerInfo[playerid][Deaths];
format(pdkills, sizeof(pdkills), "K/D Ratio : ~y~%0.2f" ,Float:PlayerInfo[playerid][Kills]/Float:pdkill);
PlayerTextDrawSetString(playerid, Textdraw7[playerid], pdkills);
new pip[136];
new tmp33[50];
GetPlayerIp(playerid,tmp33,50);
format(pip,sizeof(pip),"IP : ~y~%s", tmp33);
PlayerTextDrawSetString(playerid, Textdraw8[playerid], pip);
new phealthw[137];
new Float:armour;
GetPlayerArmour(playerid, armour);
format(phealthw, sizeof(phealthw),"%0.0f", armour);
PlayerTextDrawSetString(playerid, healthcount[playerid], phealthw);
new phealthr[137];
new Float:health;
GetPlayerHealth(playerid,health);
format(phealthr, sizeof(phealthr),"%0.0f", health);
PlayerTextDrawSetString(playerid, healthcount1[playerid], phealthr);
new ping[138];
format(ping,sizeof(ping),"Ping : ~r~%i",GetPlayerPing(playerid));
PlayerTextDrawSetString(playerid, TextPing[playerid], ping);
}
return 1;
}