OnPlayerTakeDamage [help wanted]
#1

Ok, so i got a problem.

I am trying to make a script wich creates a 3dtextlabel with the damage someone takes.
I am not really sure why it's not working so please help me becouse im getting a lot of errors
I'm not verry experienced yet.

Heres my code (it's part of my bigger main code):
Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
	new Float:X, Float:Y, Float:Z;
	GetPlayerPos( playerid, X, Y, Z );
	posZ = Z;
	posX = X;
	posY = Y;
	damage = amount;
	for(new i=0; i<15; i++)
	{
 	SetTimer("Damagetimer", 100, false);
	}
	return 1;
}

public Damagetimer()
{
	posZ = posZ+0.1;
	dmg1 = Create3DTextLabel(damage,COLOR_RED,posX,posY,posZ,50.0,0);
    Delete3DTextLabel(dmg1);
    return 1;
}
Here are ther errors that i get

Код:
D:\Gta related\GTA Modern Warfare\samp\gamemodes\CODSW11.pwn(1367) : warning 213: tag mismatch
D:\Gta related\GTA Modern Warfare\samp\gamemodes\CODSW11.pwn(1368) : warning 213: tag mismatch
D:\Gta related\GTA Modern Warfare\samp\gamemodes\CODSW11.pwn(1369) : warning 213: tag mismatch
D:\Gta related\GTA Modern Warfare\samp\gamemodes\CODSW11.pwn(1370) : warning 213: tag mismatch
D:\Gta related\GTA Modern Warfare\samp\gamemodes\CODSW11.pwn(1380) : warning 213: tag mismatch
D:\Gta related\GTA Modern Warfare\samp\gamemodes\CODSW11.pwn(1381) : error 035: argument type mismatch (argument 1)
D:\Gta related\GTA Modern Warfare\samp\gamemodes\CODSW11.pwn(1386) : warning 203: symbol is never used: "RandomSpawn"
D:\Gta related\GTA Modern Warfare\samp\gamemodes\CODSW11.pwn(1370) : warning 204: symbol is assigned a value that is never used: "damage"
D:\Gta related\GTA Modern Warfare\samp\gamemodes\CODSW11.pwn(1368) : warning 204: symbol is assigned a value that is never used: "posX"
D:\Gta related\GTA Modern Warfare\samp\gamemodes\CODSW11.pwn(1369) : warning 204: symbol is assigned a value that is never used: "posY"
D:\Gta related\GTA Modern Warfare\samp\gamemodes\CODSW11.pwn(1369 -- 1386) : warning 203: symbol is never used: "strtok"
Thanks already for your replies.
Reply
#2

Give us numbers with the lines plz
Reply
#3

Sorry, here with line numbers
(thanks for the fast reply)

Код:
1363 - public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
1364 - {
1365 - 	new Float:X, Float:Y, Float:Z;
1366- 	GetPlayerPos( playerid, X, Y, Z );
1367 - 	posZ = Z;
1368 - 	posX = X;
1369 - 	posY = Y;
1370 - 	damage = amount;
1371 - 	for(new i=0; i<15; i++)
1372 - 	{
1373 - 	SetTimer("Damagetimer", 100, false);
1374 - 	}
1375 - 	return 1;
1376 - }
1378 - 
1379 - public Damagetimer()
1380 - {
1381 - 	posZ = posZ+0.1;
1382 - 	dmg1 = Create3DTextLabel(damage,COLOR_RED,posX,posY,posZ,50.0,0);
1383 -     Delete3DTextLabel(dmg1);
1384 -    return 1;
1385 - }
Reply
#4

Ok, that helped me quite a lot.
Still got some problems though,
i want to make the 3dtextlabel climb 0.1 unit 15 times over the course of 1.5 seconds
thats what im using the forloop for but still cant quite understand how to get the damage
working properly.

Код:
 1360 - public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
1360 - {
1361 - 	damage = amount;
1362 - 	for(new i=0; i<15; i++)
1363 - 	{
1364 -  	SetTimer("Damagetimer", 100, false);
1365 - 	Delete3DTextLabel(dmg1);
1366 - 	}
1367 - 	return 1;
1368 - }
1369 - 
1370public Damagetimer()
1371 - {
1372 -     GetPlayerPos( playerid, X, Y, Z );
1373 - 	dmg1 = Create3DTextLabel(damage,COLOR_RED,X,Y,Z+0.1,50.0,0);
1374 -    return 1;
1375 - }
these are ther errors

Код:
D:\Gta related\GTA Modern Warfare\samp\gamemodes\CODSW11.pwn(1362) : warning 213: tag mismatch
D:\Gta related\GTA Modern Warfare\samp\gamemodes\CODSW11.pwn(1373) : error 017: undefined symbol "playerid"
D:\Gta related\GTA Modern Warfare\samp\gamemodes\CODSW11.pwn(1374) : error 035: argument type mismatch (argument 1)
D:\Gta related\GTA Modern Warfare\samp\gamemodes\CODSW11.pwn(1378) : warning 203: symbol is never used: "RandomSpawn"
D:\Gta related\GTA Modern Warfare\samp\gamemodes\CODSW11.pwn(1362) : warning 204: symbol is assigned a value that is never used: "damage"
D:\Gta related\GTA Modern Warfare\samp\gamemodes\CODSW11.pwn(1362 -- 1378) : warning 203: symbol is never used: "strtok"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Reply
#5

You should use SetTimerEx("DamageTimer",100*i,false,"if",playerid ,amount); and change Damagetimer() to being DamageTimer(playerid, Float:amount), then in DamageTimer(..) create a new string and format it to contain the damage.
Reply
#6

Thanks for your reply

Ok, im in school right now so i wont be able to test it when im home ill see what i can do. i was thinking; could it be usefull if i use 2 timers one 3dlabelcreate timer and one 3dlabeldelete timer so i can manage when its created and deleted. The only problem left for me would be how to get the getplayerpos and the amount of damage in the timer.

Annyone any idea how i could do that
Reply
#7

Ok, so i got it to work, when i fall off something it displays my damage, I however still want it to move up. i think i have to store the Float:amount as a variable but im not sure how to do that, hope somebody could help me fix this.

Код:
1373  public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
1374  {
1375       new Float:X, Float:Y, Float:Z;
1376       new string[128];
1377  	speler = playerid;
1378    	SetTimer("Damagestarttimer", 500, false);
1379  	stringa = format(string, sizeof(string), "%.0f",amount);
1380  }
1381
1382  public Damagestarttimer()
1383  {
1384      GetPlayerPos( speler, X, Y, Z );
1385      dmg1 = Create3DTextLabel(stringa,COLOR_RED,X,Y,Z+0.1,50.0,0);
1386      SetTimer("Damagestoptimer", 500, false);
1387      Delete3DTextLabel(dmg1);
1388      return 1;
1389  }
1390
1391  public Damagestoptimer()
1392  {
1393  Delete3DTextLabel(dmg1);
1394  return 1;
1395  }
I got these errors:
Код:
D:\Gta related\GTA Modern Warfare\samp\gamemodes\CODSW11.pwn(1375) : warning 203: symbol is never used: "Z"
D:\Gta related\GTA Modern Warfare\samp\gamemodes\CODSW11.pwn(1375) : warning 203: symbol is never used: "Y"
D:\Gta related\GTA Modern Warfare\samp\gamemodes\CODSW11.pwn(1375) : warning 203: symbol is never used: "X"
D:\Gta related\GTA Modern Warfare\samp\gamemodes\CODSW11.pwn(1384) : error 017: undefined symbol "X"
D:\Gta related\GTA Modern Warfare\samp\gamemodes\CODSW11.pwn(1385) : error 035: argument type mismatch (argument 1)
D:\Gta related\GTA Modern Warfare\samp\gamemodes\CODSW11.pwn(1379) : warning 204: symbol is assigned a value that is never used: "stringa"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
EDIT: I know I have to use a for loop, but i first want to make the 3d textlabel work in a timer. If it works in the timer i can make the upward motion myself.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)