SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Scripting Help (https://forum.sa-mp.com/forumdisplay.php?f=12)
-   -   save amount (https://forum.sa-mp.com/showthread.php?t=675317)

Vy 09/05/2020 01:10 PM

save amount
 
Hello! Is there any way to save the amount of damage to a player variable?

I've tried this form but it doesn't work:

PHP Code:

public OnPlayerTakeDamage(playeridissuerid,Floatamountweaponid)
{
if (
issuerid != INVALID_PLAYER_ID)
{
    
PlayerInfo[playerid][TotalDMG] = ++amount;
}
return 
1;


I need save all the damage one does to another player for a top, but this shows the error:

PHP Code:

C:\Users\thef\Escritorio\SERVER\gamemodes\game.pwn(849) : warning 213tag mismatchexpected tag none ("_"), but found "Float" 

Thanks!

Calisthenics 09/05/2020 01:15 PM

Re: save amount
 
`TotalDMG` should have Float: tag
pawn Code:
PlayerInfo[playerid][TotalDMG] += amount;
// is equivalent to
PlayerInfo[playerid][TotalDMG] = PlayerInfo[playerid][TotalDMG] + amount;

Vy 09/05/2020 01:22 PM

Re: save amount
 
Quote:

Originally Posted by Calisthenics (Post 4145014)
`TotalDMG` should have Float: tag
pawn Code:
PlayerInfo[playerid][TotalDMG] += amount;
// is equivalent to
PlayerInfo[playerid][TotalDMG] = PlayerInfo[playerid][TotalDMG] + amount;

Thank you very much! I also have another problem. I have a PlayerText that indicates the fps, ping and packetloss for each player. The problem is that if I connect and then someone connects, that someone doesn't show up but I do. Even if the other one is id 0 and I'm 1.

PHP Code:

new PlayerText:Textdraw0[MAX_PLAYERS]; 

stock in OnPlayerConnect:

PHP Code:

stock PlayerTextdrawing(playerid)
{
    
Textdraw0[playerid] = CreatePlayerTextDraw(playerid540.0000000.000000"FPS:000 Ping:000 PL:0.00");
    
PlayerTextDrawBackgroundColor(playeridTextdraw0[playerid], 255);
    
PlayerTextDrawFont(playeridTextdraw0[playerid], 1);
    
PlayerTextDrawLetterSize(playeridTextdraw0[playerid], 0.2199991.100000);
    
PlayerTextDrawColor(playeridTextdraw0[playerid], -1);
    
PlayerTextDrawSetOutline(playeridTextdraw0[playerid], 0);
    
PlayerTextDrawSetProportional(playeridTextdraw0[playerid], 1);
    
PlayerTextDrawSetShadow(playeridTextdraw0[playerid], 0);


And the showtextdraw in the teams:

PHP Code:

PlayerTextDrawShow(playeridTextdraw0[playerid]); 

OnPlayerUpdate:

PHP Code:

    new str[25];
    
format(strsizeof(str), "FPS:%d Ping:%d PL:%.2f"GetPlayerFPS(playerid), GetPlayerPing(playerid), NetStats_PacketLossPercent(playerid));
    
PlayerTextDrawSetString(playeridTextdraw0[playerid], str); 

Why?

Calisthenics 09/05/2020 01:39 PM

Re: save amount
 
Quote:

Originally Posted by Vy (Post 4145017)
The problem is that if I connect and then someone connects, that someone doesn't show up but I do. Even if the other one is id 0 and I'm 1.

What do you mean it does not show up? The player-textdraw? Are you sure `PlayerTextDrawShow` is executed correctly when choosing a team?

Vy 09/05/2020 01:53 PM

Re: save amount
 
Quote:

Originally Posted by Calisthenics (Post 4145028)
What do you mean it does not show up? The player-textdraw? Are you sure `PlayerTextDrawShow` is executed correctly when choosing a team?

Yes. I think the problem is the format of the textdraw. I have put the PlayerTextDrawshow in the OnPlayerConnect and work perfect for me but for the other no. I have 2 playertextdraws, the dmg and the fps. The dmg shows perfectly and the mates too but the textdraw fps no. Idk why

Calisthenics 09/05/2020 02:08 PM

Re: save amount
 
If it is not shown at all, the formatting should not be the problem. You can try set textdraw string and re-show it.

Vy 09/05/2020 02:22 PM

Re: save amount
 
Quote:

Originally Posted by Calisthenics (Post 4145034)
If it is not shown at all, the formatting should not be the problem. You can try set textdraw string and re-show it.

Fixed. It was the position of the textdraw. In Y:0 it didn't work but yes when I put in 5

Thanks.

Vy 09/05/2020 02:33 PM

Re: save amount
 
Sorry for repost! I have other problem.

In the top, the damage is reversed. If I have 150 damage and Carl 40, he gets my 150 damages and I get his 40.

PHP Code:

format(messagesizeof (message), "#%d %s(%d) with %d Kills and %.0f total dmg"1player_nametop_kills[i][1], top_kills[i][0], PlayerInfo[i][TotalDMG]); 

In the OnPlayerTakeDamage i save only the issuerid

Calisthenics 09/05/2020 02:54 PM

Re: save amount
 
Do you sort `top_kills` array? Can you post the code?

Vy 09/05/2020 06:20 PM

Re: save amount
 
Quote:

Originally Posted by Calisthenics (Post 4145054)
Do you sort `top_kills` array? Can you post the code?

i fixed that, thanks anyway


All times are GMT. The time now is 10:01 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.