PDA

View Full Version : warning tag mismatch


Cerealguy
05/01/2015, 07:48 PM
new Ping;

Ping = GetPlayerPing(playerid)*NetStats_PacketLossPercent (playerid);

? S:

Divergent
05/01/2015, 08:33 PM
Hmm. I've never worked with that function, but maybe try something like this?

new ping = GetPlayerPing(playerid);
new packetLoss = NetStats_PacketLossPercent(playerid);

new whatever = ping*packetLoss;

If not, post the actual error code.

Larceny
05/01/2015, 08:36 PM
NetStats_PacketLossPercent(playerid); is a float.

You have to convert to integer or vice-versa.

http://wiki.sa-mp.com/wiki/Float
http://wiki.sa-mp.com/wiki/Floatround

Cerealguy
05/01/2015, 08:39 PM
Same error...

Larceny
05/01/2015, 08:41 PM
Show your code.

xVIP3Rx
05/01/2015, 08:43 PM
NetStats_PacketLossPercent(playerid); is a float.

You have to convert to integer or vice-versa.

http://wiki.sa-mp.com/wiki/Float
http://wiki.sa-mp.com/wiki/Floatround

As Larceny said, Like this

new Float:Ping;
Ping = GetPlayerPing(playerid)*NetStats_PacketLossPercent (playerid);

Cerealguy
05/01/2015, 08:57 PM
no work, do not get the error but the ping goes: 10048451520

ping no is float , i need this:

Example: Ping : 190 and Packetloss is 0.4 ... 190*0.4

Beckett
05/01/2015, 08:59 PM
Show what you did.

Cerealguy
05/01/2015, 09:12 PM
new
colorPING,
Ping = GetPlayerPing(playerid),
Float:Packet = NetStats_PacketLossPercent(playerid),
Delay

;
drunknew = GetPlayerDrunkLevel(playerid);
Delay = Ping*Packet;

//------------[CHECK PING]-----------------

// if(NetStats_PacketLossPercent(playerid) >= 0.0 && NetStats_PacketLossPercent(playerid) <= 0.5){
if(0 > Delay < 190 ) {
colorPING = 0x00FF00FF;
TextDrawSetString(TextdrawPingMStats[playerid], "STABLE"); }
// else if(0.5 < NetStats_PacketLossPercent(playerid) <= 0.9) {
else if(190 < Delay < 230) {
colorPING = 0xFFFF00FF;
TextDrawSetString(TextdrawPingMStats[playerid], "NORMAL");}
else {
colorPING = 0xFF0000FF;
TextDrawSetString(TextdrawPingMStats[playerid], "LAGGING");}

TextDrawColor(TextdrawPingMStats[playerid], colorPING);
TextDrawShowForPlayer(playerid, TextdrawPingMStats[playerid]);

Larceny
05/01/2015, 09:18 PM
new Float:Delay = floatmul(float(GetPlayerPing(playerid)), NetStats_PacketLossPercent(playerid));

Btw:

if(0 > Delay < 190 ) {

Delay will never be negative.

Cerealguy
05/01/2015, 09:30 PM
new Float:Delay = floatmul(float(GetPlayerPing(playerid)), NetStats_PacketLossPercent(playerid));

Btw:

if(0 > Delay < 190 ) {

Delay will never be negative.

no work. S:

Schneider
05/01/2015, 09:35 PM
new
colorPING,
Ping = GetPlayerPing(playerid),
Float:Packet = NetStats_PacketLossPercent(playerid),
Float:Delay
;
Delay = Ping*Packet;

Cerealguy
05/01/2015, 09:40 PM
Sorry remove this (NO WORK)


new string[128], string2[128], Ping = GetPlayerPing(playerid);
new Float:hola;
new Float:PacketLoss = NetStats_PacketLossPercent(playerid);
format(string, sizeof(string), "%.2f", PacketLoss);
hola = floatstr(string);
format(string2, sizeof(string2), "%d", hola*Ping);
SendClientMessage(playerid, -1,string2);


other idea?

Schneider
05/01/2015, 09:54 PM
new string[12], Ping = GetPlayerPing(playerid);
new Float:PacketLoss = NetStats_PacketLossPercent(playerid);
format(string, sizeof(string), "%.2f", (PacketLoss*Ping));
SendClientMessage(playerid, -1,string);

Cerealguy
05/01/2015, 10:01 PM
new string[12], Ping = GetPlayerPing(playerid);
new Float:PacketLoss = NetStats_PacketLossPercent(playerid);
format(string, sizeof(string), "%.2f", (PacketLoss*Ping));
SendClientMessage(playerid, -1,string);

gives a wrong value

Jefff
05/01/2015, 10:05 PM
new Float:Ping = float(GetPlayerPing(playerid))*NetStats_PacketLoss Percent(playerid);

ikkentim
05/01/2015, 10:06 PM
gives a wrong value

Try %f instead of %.2f. If you still get wrong values, what values are you getting?

Cerealguy
05/01/2015, 10:09 PM
new Float:Ping = float(GetPlayerPing(playerid))*NetStats_PacketLoss Percent(playerid);

no work friend, get 1120210202

i need this: Example:

Ping : 190 and Packetloss is 0.4 ... 190*0.4 = 76

Total = 76 < i need this

ikkentim
05/01/2015, 10:26 PM
try


new string[32];
new ping = GetPlayerPing(playerid);
new Float:pl = NetStats_PacketLossPercent(playerid);

format(string, sizeof(string), "%d x %f = %f", ping, pl, (ping*pl));
SendClientMessage(playerid, -1,string); this makes debugging easier

Cerealguy
05/01/2015, 10:30 PM
try


new string[32];
new ping = GetPlayerPing(playerid);
new Float:pl = NetStats_PacketLossPercent(playerid);

format(string, sizeof(string), "%d x %f = %f", ping, pl, (ping*pl));
SendClientMessage(playerid, -1,string); this makes debugging easier

Dude, I need that total is introduced into a variable

to use in:

if(0 > Variable with the total < 190 ) {
colorPING = 0x00FF00FF;
TextDrawSetString(TextdrawPingMStats[playerid], "STABLE");
}

ikkentim
05/01/2015, 10:35 PM
Dude, I need that total is introduced into a variable

to use in:

if(0 > Variable with the total < 190 ) {
colorPING = 0x00FF00FF;
TextDrawSetString(TextdrawPingMStats[playerid], "STABLE");
}
you are trying to find your problem, therefore you need to debug your code. if you do not wish to debug, thus not find your problems, fine, don't debug, but why then bother asking questions here then. Printing out the data you have is the easiest way of debugging. If, in a multiplication one of both values are faulty (say the ping) you'll be able to say that the other value is not the issue. this way you get closer and closer to bug.

Vince
05/01/2015, 10:39 PM
Wow, seriously. Two pages for such a simple issue. To calculate with floating point values all operands must be floating point values. Thus:

new
Float:ping,
Float:loss;

ping = float(GetPlayerPing(playerid));
loss = NetStats_PacketLossPercent(playerid);

new result = floatround(ping * loss);


By my knowledge that should do it.

Also this if-statement is just wrong and will never work.
if(0 > Variable with the total < 190 )
This checks if 0 is greater than "variable", which is never true. The correct statement is:
if(0 <= Variable with the total < 190 )

Cerealguy
05/01/2015, 10:59 PM
Wow, seriously. Two pages for such a simple issue. To calculate with floating point values all operands must be floating point values. Thus:

new
Float:ping,
Float:loss;

ping = float(GetPlayerPing(playerid));
loss = NetStats_PacketLossPercent(playerid);

new result = floatround(ping * loss);


By my knowledge that should do it.

Also this if-statement is just wrong and will never work.
if(0 > Variable with the total < 190 )
This checks if 0 is greater than "variable", which is never true. The correct statement is:
if(0 <= Variable with the total < 190 )

I had not seen this 0 > , yes is 0<= , and apparently works, but gives the warning tag mismatch in 3 ln


Ping = float(GetPlayerPing(playerid));
Loss = NetStats_PacketLossPercent(playerid);
new Delay = floatround(Ping * Loss);

Vince
06/01/2015, 12:10 AM
The code I posted above does not generate warnings (actually compiled it to be sure), so you've changed something else.

Cerealguy
06/01/2015, 12:22 AM
http://puu.sh/e801T/42487b4ed2.png