1. Simple SetPlayerHealth not working || 2. Unknown 'tag mismatch' warning. -
RajatPawar - 16.12.2012
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!
Re: 1. Simple SetPlayerHealth not working || 2. Unknown 'tag mismatch' warning. -
RedCrossER - 16.12.2012
Well You want deduct all player's health with -1 or just 1 player?
Re: 1. Simple SetPlayerHealth not working || 2. Unknown 'tag mismatch' warning. -
Lordzy - 16.12.2012
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 "
' ".
Re: 1. Simple SetPlayerHealth not working || 2. Unknown 'tag mismatch' warning. -
RajatPawar - 16.12.2012
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.
Re: 1. Simple SetPlayerHealth not working || 2. Unknown 'tag mismatch' warning. -
Djole1337 - 16.12.2012
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
Re: 1. Simple SetPlayerHealth not working || 2. Unknown 'tag mismatch' warning. -
RajatPawar - 16.12.2012
Nope, ^ As I said, I already defined HouseLabel as Text3D and things..
Re: 1. Simple SetPlayerHealth not working || 2. Unknown 'tag mismatch' warning. -
Vince - 16.12.2012
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.
Re: 1. Simple SetPlayerHealth not working || 2. Unknown 'tag mismatch' warning. -
Konstantinos - 16.12.2012
^^ Agreed.
Show us your enumeration.
Re: 1. Simple SetPlayerHealth not working || 2. Unknown 'tag mismatch' warning. -
RajatPawar - 16.12.2012
pawn Код:
enum HouseInfo
{
Owner[MAX_PLAYER_NAME],
Owned,
Price,
Float:XPos,
Float:YPos,
Float:ZPos,
VirtualWorld,
Text3D:HouseLabel
}
new hInfo[MAX_HOUSES][HouseInfo];
Re: 1. Simple SetPlayerHealth not working || 2. Unknown 'tag mismatch' warning. -
Konstantinos - 16.12.2012
The problem is this
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.