SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 25/04/2019, 12:42 AM   #1
Maker52130
Little Clucker
 
Maker52130's Avatar
 
Join Date: Aug 2016
Posts: 28
Reputation: 0
Default Refresh textdraw info (kills/deaths)

Hello I have a problem with my textdraw stats, with each kills / deaths my textdraw updates but it remains the old stats. You will understand by viewing the screens.

sorry for my disgusting english.

http://image.noelshack.com/fichiers/...-sa-mp-155.png
http://image.noelshack.com/fichiers/...-sa-mp-156.png (Textdraw update but the old stats rest)

Do not pay attention to K / D.

Here is my code:

Code:
public OnPlayerUpdate(playerid)
{
	if(IsPlayerConnected(playerid))
	{
	if(IsPlayerNPC(playerid)) return 0;
	new Float:ratio=floatdiv(PlayerInfo[playerid][pKills], PlayerInfo[playerid][pDeaths]);
        new string1[24],string2[24],string3[24];
        format(string1,sizeof(string1),"Kills: %d",PlayerInfo[playerid][pKills]);
        format(string2,sizeof(string2),"Deaths: %d",PlayerInfo[playerid][pDeaths]);
        format(string3,sizeof(string3),"K/D: %.2f",ratio);
        TextDrawSetString(Stats2,string1);
        TextDrawSetString(Stats3,string2);
   	TextDrawSetString(Stats4,string3);
}
Maker52130 is offline   Reply With Quote
Old 25/04/2019, 06:28 AM   #2
Mugala
High-roller
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: Georgia, Tbilisi
Posts: 1,064
Reputation: 50
Default Re: Refresh textdraw info (kills/deaths)

Stats2,Stats3 and Stats4 are global server variables, you should create global player variables.

for example:
PHP Code:
new Stats2[MAX_PLAYERS]; 
than usage:
PHP Code:
TextDrawSetString(Stats2[playerid],string1); 
p.s. could not open the screens, I have a very bad connection.
__________________
Coding in 8 languages including Pawn, C#, C++ and SQL.
Available for hiring.

If you have a coding question or need an assistance in a code, just PM me.
If you want me to create something for you, here is a Discord Mugala#5651

Currently helping Community members in a coding.
Mugala is offline   Reply With Quote
Old 25/04/2019, 06:26 PM   #3
Maker52130
Little Clucker
 
Maker52130's Avatar
 
Join Date: Aug 2016
Posts: 28
Reputation: 0
Default Re: Refresh textdraw info (kills/deaths)

Yes, thanks u!!! It was not so complicated that it.
Maker52130 is offline   Reply With Quote
Old 25/04/2019, 06:35 PM   #4
Koreadars
Big Clucker
 
Join Date: Mar 2019
Location: Czech Republic, Prdelákov.
Posts: 127
Reputation: 6
Default Re: Refresh textdraw info (kills/deaths)

Quote:
Originally Posted by Maker52130 View Post
Yes, thanks u!!! It was not so complicated that it.
Use OnPlayerDeath, cuz OnPlayerUpdate will be called many times a second.
Koreadars is offline   Reply With Quote
Old 25/04/2019, 06:41 PM   #5
Maker52130
Little Clucker
 
Maker52130's Avatar
 
Join Date: Aug 2016
Posts: 28
Reputation: 0
Default Re: Refresh textdraw info (kills/deaths)

ok ty !
Maker52130 is offline   Reply With Quote
Old 25/04/2019, 08:50 PM   #6
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,854
Reputation: 1292
Default Re: Refresh textdraw info (kills/deaths)

Wrong kind of textdraw as well! This is going to update for every player.
Pottus is offline   Reply With Quote
Old 06/05/2019, 02:31 PM   #7
Mugala
High-roller
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: Georgia, Tbilisi
Posts: 1,064
Reputation: 50
Default Re: Refresh textdraw info (kills/deaths)

Quote:
Originally Posted by Pottus View Post
Wrong kind of textdraw as well! This is going to update for every player.
I already told that and he fixed it.
using textdraw with per-player variable instead of playertextdraw is not a crime.
__________________
Coding in 8 languages including Pawn, C#, C++ and SQL.
Available for hiring.

If you have a coding question or need an assistance in a code, just PM me.
If you want me to create something for you, here is a Discord Mugala#5651

Currently helping Community members in a coding.
Mugala 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
[Pedido] Contador de kills e deaths textdraw viniciussantos664 Português/Portuguese 2 07/07/2015 08:24 PM
[HELP] Kills, Deaths, Score Stats textdraw Fantje Scripting Help 2 13/03/2015 12:43 PM
Kills And Deaths Textdraw Opah Scripting Help 3 24/11/2013 10:34 AM
TEXTDRAW SHOW KILLS AND DEATHS HELP vakhtang Help Archive 5 17/08/2010 12:44 PM
[HowTo] Score In A Textdraw i MEAN Kills And Deaths legendario Help Archive 5 23/01/2010 09:31 AM


All times are GMT. The time now is 12:12 PM.


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