damage history -
KeNTos - 26.03.2016
Hello good people
I want to make history Player damage.
To death the player, displays information about the last 5 damage
help me
Привет добрые люди
Хочу сделать историю повреждений игрока.
Чтобы при смерти игрока, выводилась информация о последних 5 повреждений
Код:
#define MAX_DAMAGE 5
enum damageinfo
{
damSource,
damPart[16],
Float: damDamage,
damWeapon,
damTime[6]
};
new damageInfo[MAX_DAMAGE][damageinfo];
new nDamage[MAX_PLAYERS];
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
new str[MAX_DAMAGE][1024];
for(new i = 0; i < MAX_DAMAGE; i++)
{
if(damageInfo[i][damSource] == 1)
{
format(str[i], sizeof(str[i]), "Source: %d\nPart body: %s, damage %.1f\nweapon: %d\ntime: %02d/%02d/%d - %02d:%02d:%02d",
damageInfo[i][damSource], damageInfo[i][damPart], damageInfo[i][damDamage], damageInfo[i][damWeapon], damageInfo[i][damTime][0], damageInfo[i][damTime][1], damageInfo[i][damTime][2], damageInfo[i][damTime][3], damageInfo[i][damTime][4], damageInfo[i][damTime][5]);
}
}
format(str, sizeof(str), "%s\n\n%s\n\n%s\n\n%s\n\n%s", str[0], str[1], str[2], str[3], str[4]);
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "Информация", szOutput, "Закрыть", "");
return 1;
}
Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
nDamage[damagedid] ++;
if(nDamage[damagedid] >= MAX_DAMAGE)
nDamage[damagedid] = 0;
new bodyName[16];
switch(bodypart)
{
case 3: bodyName = "òóëîâèùå";
case 4: bodyName = "ãðóäü";
case 5: bodyName = "ëåâàÿ ðóêà";
case 6: bodyName = "ïðàâà ðóêà";
case 7: bodyName = "ëåâàÿ íîãà";
case 8: bodyName = "ïðàâà íîãà";
case 9: bodyName = "ãîëîâà";
}
damageInfo[nDamage[damagedid]][damSource] = 1;
damageInfo[nDamage[damagedid]][damPart] = bodyName;
damageInfo[nDamage[damagedid]][damDamage] = amount;
damageInfo[nDamage[damagedid]][damWeapon] = weaponid;
getdate(damageInfo[nDamage[damagedid]][damTime][0], damageInfo[nDamage[damagedid]][damTime][1], damageInfo[nDamage[damagedid]][damTime][2]);
gettime(damageInfo[nDamage[damagedid]][damTime][3], damageInfo[nDamage[damagedid]][damTime][4], damageInfo[nDamage[damagedid]][damTime][5]);
return 1;
}
Re: damage history -
KeNTos - 26.03.2016
help me
Re: damage history -
Mencent - 26.03.2016
Hi!
Where do you need help? Where is the problem?
By the way, I would like to change this code:
PHP код:
public OnPlayerDeath(playerid,killerid,reason)
{
new str[1024];
for(new i;i<MAX_DAMAGE;i++)
{
if(damageInfo[i][damSource] == 1)
{
format(str,sizeof str,"%sSource: %d\nPart body: %s, damage %.1f\nweapon: %d\ntime: %02d/%02d/%d - %02d:%02d:%02d\n",
str,damageInfo[i][damSource],damageInfo[i][damPart],damageInfo[i][damDamage],damageInfo[i][damWeapon],damageInfo[i][damTime][0], damageInfo[i][damTime][1], damageInfo[i][damTime][2], damageInfo[i][damTime][3], damageInfo[i][damTime][4], damageInfo[i][damTime][5]);
}
}
ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,"Информация",str,"Закрыть", "");
return 1;
}
It's a very better way. But you have to say where the problem is.
EDIT:
Sorry, here is a little edit. Please change this too:
PHP код:
damageInfo[nDamage[damagedid]][damPart] = bodyName;
to
PHP код:
format(damageInfo[nDamage[damagedid]][damPart],16,"%s",bodyName);
Re: damage history -
KeNTos - 26.03.2016
There is a new problem, I do not work and public onplayergivedamage onplayertakedamage
Re: damage history -
Mencent - 26.03.2016
Can you explain your problem? I don't understand where exactly the problem is.
Re: damage history -
KeNTos - 26.03.2016
Public OnPlayerGiveDamage and OnPlayerTakeDamage not work at all. Just not called .... and tried to grandlarc gamemode....do not work