how to store player's damage
#1

how to store it, and there my questions regarding that: (no need to saveit , just to view the CURRENT damage amount)

How to show the player's damage.
How to show top 3 player's damage (with a list on text, 1) name 230 damage, 2) name 130 damage, 3) name 90 damage).
Reply
#2

https://sampwiki.blast.hk/wiki/OnPlayerGiveDamage
https://sampwiki.blast.hk/wiki/OnPlayerTakeDamage

- it will be useful
Reply
#3

Thanks yeah xD

edit: what about last question?
Reply
#4

Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
    new string[156], victim[MAX_PLAYER_NAME], attacker[MAX_PLAYER_NAME];
    new weaponname[24];
    GetPlayerName(playerid, attacker, sizeof (attacker));
    GetPlayerName(damagedid, victim, sizeof (victim));
    GetWeaponName(weaponid, weaponname, sizeof (weaponname));
    format(string, sizeof(string), "%s has made %.0f damage to %s, weapon: %s, bodypart: %d", attacker, amount, victim, weaponname, bodypart);
   
	new
	 File:lFile = fopen("Damages.txt", io_append);
	fwrite(lFile, string);
	fclose(lFile);
	SendClientMessageToAll(0xFFFFFFFF, string);
	return 1;
}
Go scriptfiles and create Damages.txt
via; https://sampforum.blast.hk/showthread.php?tid=264770
Reply
#5

Why are you even making a file, he just wants the top 3, so he can show it... It doesn't need to log the damage, simply store it to an array.
Reply
#6

Exactly, no need to store it, ok i'll try.

EDIT: so thats what i did for now

after doing the damage enum, inside OnPlayerDamage callback.
PHP код:
SetTimerEx("damagedone"200000true"i"playerid); 
PHP код:
forward damagedone(playerid, &Float:amount);
public 
damagedone(playerid, &Float:amount)
{
      new 
stringg[128];
      new 
Damage[playerid] = amount// stating that the Damage enum will show the amount of damage.
    
format(stringgsizeof(stringg), "You did: %.0f damage in 30 minutes."Damage[playerid]);
    
SendClientMessage(playerid, -1stringg);
    
Damage[playerid] = 0// setting it to 0 so on next 30 minutes it wont simply add the current amount on the existing one
    
return 1;

Код:
C:\Users\Wallen\Desktop\LS DM\gamemodes\DBv1.pwn(4770) : warning 219: local variable "Damage" shadows a variable at a preceding level
C:\Users\Wallen\Desktop\LS DM\gamemodes\DBv1.pwn(4770) : error 008: must be a constant expression; assumed zero
C:\Users\Wallen\Desktop\LS DM\gamemodes\DBv1.pwn(4770) : error 008: must be a constant expression; assumed zero
C:\Users\Wallen\Desktop\LS DM\gamemodes\DBv1.pwn(4770) : error 036: empty statement
C:\Users\Wallen\Desktop\LS DM\gamemodes\DBv1.pwn(4770) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#7

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Why are you even making a file, he just wants the top 3, so he can show it... It doesn't need to log the damage, simply store it to an array.
i thought he mean recording
Reply
#8

PHP код:
public damagedone(playerid, &Float:amount

      new 
stringg[128]; 
      new 
Damage[playerid] = amount// You need to NOT define it here, as it's a global var, not a local variable.
    //
    //What happens with this, is that you create it in here, and it will only be visible in here, yet it needs tracking for more than just the one instance which is here.
   //You have this defined in the main gamemode, and redefining it here is causing the error. Remove this, and you should have more progress.
    
format(stringgsizeof(stringg), "You did: %.0f damage in 30 minutes."Damage[playerid]); 
    
SendClientMessage(playerid, -1stringg); 
    
Damage[playerid] = 0// setting it to 0 so on next 30 minutes it wont simply add the current amount on the existing one 
    
return 1

That's not an enum in there, that's an array. You also need to remove it as it's conflicting with the Damage variable that you made prior. Along with it not being a global variable anyway, which it actually needs to be Global.
Reply
#9

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
PHP код:
public damagedone(playerid, &Float:amount

      new 
stringg[128]; 
      new 
Damage[playerid] = amount// You need to NOT define it here, as it's a global var, not a local variable.
    //
    //What happens with this, is that you create it in here, and it will only be visible in here, yet it needs tracking for more than just the one instance which is here.
   //You have this defined in the main gamemode, and redefining it here is causing the error. Remove this, and you should have more progress.
    
format(stringgsizeof(stringg), "You did: %.0f damage in 30 minutes."Damage[playerid]); 
    
SendClientMessage(playerid, -1stringg); 
    
Damage[playerid] = 0// setting it to 0 so on next 30 minutes it wont simply add the current amount on the existing one 
    
return 1

That's not an enum in there, that's an array. You also need to remove it as it's conflicting with the Damage variable that you made prior. Along with it not being a global variable anyway, which it actually needs to be Global.
So after all that, where do i make it? you telling me "not, not, not" but no facts on where , for example where do i define this part?

PHP код:
      new Damage[playerid] = amount// You need to NOT define it here, as it's a global var, not a local variable.
    // 
Top gamemode?

So basically i just need to delete the timer, and make it on the callback where damage is called, if i make it separately like i did there it will have trouble on showing it? But doing that the timer is not there, and therefore it will not be shown again in some amount of time. Which i actually want it to happen.
But the last thing that i wanted to tell you
PHP код:
   //You have this defined in the main gamemode, and redefining it here is causing the error. Remove this, and you should have more progress. 
    
format(stringgsizeof(stringg), "You did: %.0f damage in 30 minutes."Damage[playerid]); 
Why should i delete the format ? lol
Reply
#10

Read your errors...

Damage is already defined, meaning that where you're defining it in your callback, it's already defined at the top of the script.

The comments ALL relate to the Damage variable, nothing to do with the segment below.

If it were to do with the format it would be
PHP код:
format()//Remove this. 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)