SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Scripting Help (https://forum.sa-mp.com/forumdisplay.php?f=12)
-   -   A little question (https://forum.sa-mp.com/showthread.php?t=649575)

ivndosos 11/02/2018 10:03 AM

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

http://prntscr.com/id4qee

Mugala 11/02/2018 10:08 AM

Re: A little question
 
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 :D
PHP Code:

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;



ivndosos 11/02/2018 10:28 AM

Re: A little question
 
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?

Fratello 11/02/2018 10:39 AM

Re: A little question
 
Quote:

Originally Posted by ivndosos (Post 3991361)
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.

Mugala 11/02/2018 10:54 AM

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

PHP Code:

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.

ivndosos 11/02/2018 10:58 AM

Re: A little question
 
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."

Mugala 11/02/2018 11:01 AM

Re: A little question
 
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?

ivndosos 11/02/2018 11:13 AM

Re: A little question
 
Code:

AttachPlayerObjectToPlayer(i,heartobject[i], playerid, 0,0,1.5,0,0,0);
Code:

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 (c) 1997-2006, ITB CompuPhase


4 Errors.

Code:

            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;
}


Mugala 11/02/2018 11:15 AM

Re: A little question
 
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);

iKarim 11/02/2018 11:15 AM

Re: A little question
 
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 (Post 3991371)
actually you can create a PlayerObject for all of these players, exept him.
it's pretty simple.

PHP Code:

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.


All times are GMT. The time now is 07:51 PM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.