SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 09/05/2020, 01:10 PM   #1
Vy
Little Clucker
 
Join Date: Aug 2016
Posts: 40
Reputation: 0
Default 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!
Vy is offline   Reply With Quote
Old 09/05/2020, 01:15 PM   #2
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,227
Reputation: 205
Default Re: save amount

`TotalDMG` should have Float: tag
pawn Code:
PlayerInfo[playerid][TotalDMG] += amount;
// is equivalent to
PlayerInfo[playerid][TotalDMG] = PlayerInfo[playerid][TotalDMG] + amount;
__________________
Calisthenics is offline   Reply With Quote
Old 09/05/2020, 01:22 PM   #3
Vy
Little Clucker
 
Join Date: Aug 2016
Posts: 40
Reputation: 0
Default Re: save amount

Quote:
Originally Posted by Calisthenics View Post
`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?
Vy is offline   Reply With Quote
Old 09/05/2020, 01:39 PM   #4
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,227
Reputation: 205
Default Re: save amount

Quote:
Originally Posted by Vy View Post
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?
__________________
Calisthenics is offline   Reply With Quote
Old 09/05/2020, 01:53 PM   #5
Vy
Little Clucker
 
Join Date: Aug 2016
Posts: 40
Reputation: 0
Default Re: save amount

Quote:
Originally Posted by Calisthenics View Post
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
Vy is offline   Reply With Quote
Old 09/05/2020, 02:08 PM   #6
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,227
Reputation: 205
Default 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.
__________________
Calisthenics is offline   Reply With Quote
Old 09/05/2020, 02:22 PM   #7
Vy
Little Clucker
 
Join Date: Aug 2016
Posts: 40
Reputation: 0
Default Re: save amount

Quote:
Originally Posted by Calisthenics View Post
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 is offline   Reply With Quote
Old 09/05/2020, 02:33 PM   #8
Vy
Little Clucker
 
Join Date: Aug 2016
Posts: 40
Reputation: 0
Default 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
Vy is offline   Reply With Quote
Old 09/05/2020, 02:54 PM   #9
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,227
Reputation: 205
Default Re: save amount

Do you sort `top_kills` array? Can you post the code?
__________________
Calisthenics is offline   Reply With Quote
Old 09/05/2020, 06:20 PM   #10
Vy
Little Clucker
 
Join Date: Aug 2016
Posts: 40
Reputation: 0
Default Re: save amount

Quote:
Originally Posted by Calisthenics View Post
Do you sort `top_kills` array? Can you post the code?
i fixed that, thanks anyway
Vy is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Same amount! Man43 Scripting Help 4 25/07/2018 12:21 PM
dmg amount, save in-array FinStar Scripting Help 0 22/09/2016 02:03 PM
How Do I Do This? On Screen Amount Of Kills And amount Of Deaths HayZatic Help Archive 1 01/07/2011 02:26 PM
Custom bank script doesn't save properly/load amount Biesmen Help Archive 0 14/10/2010 02:42 PM
Save amount in string Mike Garber Help Archive 4 19/02/2010 08:45 AM


All times are GMT. The time now is 06:55 PM.


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