SA-MP Forums Archive
A little question - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: A little question (/showthread.php?tid=649575)



A little question - ivndosos - 11.02.2018

How do I make that heart sign above head when someone's hit?

http://prntscr.com/id4qee


Re: A little question - Mugala - 11.02.2018

it's an object ID 1240 which is attached to a player.

well I have a cooldown between posts and I'll make an example
PHP код:
OnPlayerTakeDamage/OnPlayerGiveDamage
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid,X,Y,Z);
new 
obj CreateObject(1240,X,Y,Z+1.5,0,0,0);
AttachObjectToPlayer(obj,playerid,0,0,1.5,0,0,0);
SetTimerEx("DestroyThisAttachedObject",1000,0,"i",obj);
forward DestroyThisAttachedObject(obj);
public 
DestroyThisAttachedObject(obj)
{
    
DestroyObject(obj);
    return 
1;




Re: A little question - ivndosos - 11.02.2018

Works good, but if I fall or get hit I can see that above my head, It's pretty bothersome how can I disable so I can't view it but other people can?


Re: A little question - Fratello - 11.02.2018

Quote:
Originally Posted by ivndosos
Посмотреть сообщение
Works good, but if I fall or get hit I can see that above my head, It's pretty bothersome how can I disable so I can't view it but other people can?
It's not possible.


Re: A little question - Mugala - 11.02.2018

actually you can create a PlayerObject for all of these players, exept him.
it's pretty simple.

PHP код:
OnPlayerTakeDamage/OnPlayerGiveDamage 
new Float:X,Float:Y,Float:Z
GetPlayerPos(playerid,X,Y,Z);
for(new 
0GetPlayerPoolSize(); <= ji++)
{
    if(
!= playerid)
    {
        new 
obj[i] = CreatePlayerObject(i,1240,X,Y,Z+1.5,0,0,0); 
        
AttachPlayerObjectToPlayer(i,obj[i],playerid,0,0,1.5,0,0,0); 
        
SetTimerEx("DestroyThisAttachedObject",1000,0,"ii",i,obj[i]);
    }
}
forward DestroyThisAttachedObject(playerid,obj); 
public 
DestroyThisAttachedObject(playerid,obj

    
DestroyPlayerObject(playerid,obj); 
    return 
1

P.S. @Fratello, everything is possible if scripter wants.


Re: A little question - ivndosos - 11.02.2018

You mean if I hit a player, only he will have it and not me? or you mean everyone will have it?

"for all of these players, exept him."


Re: A little question - Mugala - 11.02.2018

when you hit a player, he'll get this icon, which will be visible for everyone but not for him.
it's what u asked for yeah?


Re: A little question - ivndosos - 11.02.2018

Код:
AttachPlayerObjectToPlayer(i,heartobject[i], playerid, 0,0,1.5,0,0,0);
Код:
C:\Users\yan\Desktop\LS DM\gamemodes\DBv1.pwn(1893) : error 028: invalid subscript (not an array or too many subscripts): "heartobject"
C:\Users\yan\Desktop\LS DM\gamemodes\DBv1.pwn(1893) : warning 215: expression has no effect
C:\Users\yan\Desktop\LS DM\gamemodes\DBv1.pwn(1893) : error 001: expected token: ";", but found "]"
C:\Users\yan\Desktop\LS DM\gamemodes\DBv1.pwn(1893) : error 029: invalid expression, assumed zero
C:\Users\yan\Desktop\LS DM\gamemodes\DBv1.pwn(1893) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Код:
    	new Float:x, Float:y, Float:z;
    	GetPlayerPos(playerid, x,y,z);
    	for(new i = 0, j = GetPlayerPoolSize(); i <= j; i ++)
    	{
	    	new heartobject = CreateObject(i,1240, x,y,z+1.5,0,0,0);
            AttachPlayerObjectToPlayer(i,heartobject[i], playerid, 0,0,1.5,0,0,0);
	    	SetTimerEx("HeartObject", 3000,0,"ii", i, heartobject[i]);
		}
 		return 1;
}

forward HeartObject(playerid,heartobject);
public HeartObject(playerid,heartobject)
{
   DestroyPlayerObject(heartobject);
   return 1;
}



Re: A little question - Mugala - 11.02.2018

this code is right > AttachPlayerObjectToPlayer(i,heartobject[i], playerid, 0,0,1.5,0,0,0);
u're using heartobject = CreatePlayer... or heartobject[i] = CreatePlayerObj... ?

u must add here a playerid > DestroyPlayerObject(playerid,heartobject);


Re: A little question - iKarim - 11.02.2018

Why are you accessing it like that? It obviously is not an array. Remove the [i], it's a normal variable.

Quote:
Originally Posted by Mugalito
Посмотреть сообщение
actually you can create a PlayerObject for all of these players, exept him.
it's pretty simple.

PHP код:
for(new 0GetPlayerPoolSize(); <= ji++)
{
     new 
obj[i] = CreatePlayerObject(i,1240,X,Y,Z+1.5,0,0,0); 
That's wrong as well, you can't initialize an array with a variable as it's size, since the arrays are initialized on compilation time instead of run time.