1. Simple SetPlayerHealth not working || 2. Unknown 'tag mismatch' warning.
#1

I set this timer for reducing a player's health every 10 seconds, (for testing).
It's a simple enough function, should work, but instead of reducing health, it kills my player, reduces the health to 0 directly.
I forwarded the function, set the timer correctly.
pawn Код:
forward LH(playerid); //At the top.
pawn Код:
SetTimer("LH",10000,true); //Under OnPlayerSpawn.
The function:
pawn Код:
public LH(playerid)
{
      new Float:health;
      SetPlayerHealth(playerid,GetPlayerHealth(playerid, health)-1);
     return 1;
}
---------------------------------------------------------------------
Problem 2:
pawn Код:
Line 1123: format(st,sizeof(st),"INSERT INTO `playerhouses` (`Price`, `xpos`, `ypos`, `zpos`, `virtualworld`, `labeltext`) VALUES ('%i','%f', '%f', '%f', '%i', `%s`)",HousePrice,hInfo[id][XPos],hInfo[id][YPos],hInfo[id][ZPos],hInfo[id][VirtualWorld],hInfo[id][HouseLabel]);
Quote:

C:\Users\Rajat\Desktop\SAMP\gamemodes\MySQL.pwn(11 23) : warning 213: tag mismatch

Gives a 'tag mismatch' warning. I removed all values one by one, and removing labeltext stopped the warning. In the enum, I defined 'HouseLabel' as Text3D, already.
--------------------------------------------------------------------
Help would be greatly appreciated!
Reply
#2

Well You want deduct all player's health with -1 or just 1 player?
Reply
#3

You must use SetTimerEx to use 'playerid' in the timer.
pawn Код:
public OnPlayerSpawn(playerid)
{
 SetTimerEx("LH", 10000, true, "d", playerid);
 return 1;
}

forward LH(playerid);
public LH(playerid)
{
 new Float:hp[MAX_PLAYERS];
 GetPlayerHealth(playerid, hp[playerid]);
 SetPlayerHealth(playerid, hp[playerid]-1);
 return 1;
}
2: I think you must use symbol " ' ".
Reply
#4

Quote:
Originally Posted by Lordz™
Посмотреть сообщение
You must use SetTimerEx to use 'playerid' in the timer.
pawn Код:
public OnPlayerSpawn(playerid)
{
 SetTimerEx("LH", 10000, true, "d", playerid);
 return 1;
}

forward LH(playerid);
public LH(playerid)
{
 new Float:hp[MAX_PLAYERS];
 GetPlayerHealth(playerid, hp[playerid]);
 SetPlayerHealth(playerid, hp[playerid]-1);
 return 1;
}
2: I think you must use symbol " ' ".
Thanks a lot for the fix @ problem 1!
But for the 2nd, I have used ', `, no symbol, everything, still shows the error.
Reply
#5

pawn Код:
format(st,sizeof(st), "INSERT INTO `playerhouses` (`Price`, `xpos`, `ypos`, `zpos`, `virtualworld`, `labeltext`) VALUES ('%i', '%f', '%f', '%f', '%i', '%s')", HousePrice,hInfo[id][XPos], hInfo[id][YPos], hInfo[id][ZPos], hInfo[id[VirtualWorld], hInfo[id][HouseLabel]);
As I can see this syntax is ok, you should check your variables.

For Lordz, making error in sql syntax WON'T show any error/warining in compiler
Reply
#6

Nope, ^ As I said, I already defined HouseLabel as Text3D and things..
Reply
#7

Quote:
Originally Posted by Lordz™
Посмотреть сообщение
pawn Код:
new Float:hp[MAX_PLAYERS];
What exactly is the purpose of that? This is a local, temporary variable. The array is completely unnecessary.
Reply
#8

^^ Agreed.

Show us your enumeration.
Reply
#9

pawn Код:
enum HouseInfo
{
Owner[MAX_PLAYER_NAME],
Owned,
Price,
Float:XPos,
Float:YPos,
Float:ZPos,
VirtualWorld,
Text3D:HouseLabel
}
new hInfo[MAX_HOUSES][HouseInfo];
Reply
#10

The problem is this
pawn Код:
hInfo[id][HouseLabel]
You cannot format a message and displays the HouseLabel. What I suggest you is a new variable (string) which stores the text from the label and then insert into the formatted text the variable's text, not the HouseLabel.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)