SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 11/02/2018, 10:03 AM   #1
ivndosos
Huge Clucker
 
ivndosos's Avatar
 
Join Date: Sep 2014
Location: Russian Federation, Kaliningrad.
Posts: 406
Reputation: 18
Default A little question

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

http://prntscr.com/id4qee
ivndosos is offline   Reply With Quote
Old 11/02/2018, 10:08 AM   #2
Mugala
Gangsta
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: behind u
Posts: 645
Reputation: 30
Default 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
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;

__________________
here to help
Mugala is offline   Reply With Quote
Old 11/02/2018, 10:28 AM   #3
ivndosos
Huge Clucker
 
ivndosos's Avatar
 
Join Date: Sep 2014
Location: Russian Federation, Kaliningrad.
Posts: 406
Reputation: 18
Default 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?
ivndosos is offline   Reply With Quote
Old 11/02/2018, 10:39 AM   #4
Fratello
Huge Clucker
 
Fratello's Avatar
 
Join Date: May 2016
Location: Howard University
Posts: 325
Reputation: 38
Default Re: A little question

Quote:
Originally Posted by ivndosos View Post
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.
__________________
"It's not what you expect from life; But what life expect from you!"
Fratello is offline   Reply With Quote
Old 11/02/2018, 10:54 AM   #5
Mugala
Gangsta
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: behind u
Posts: 645
Reputation: 30
Default 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.
__________________
here to help
Mugala is offline   Reply With Quote
Old 11/02/2018, 10:58 AM   #6
ivndosos
Huge Clucker
 
ivndosos's Avatar
 
Join Date: Sep 2014
Location: Russian Federation, Kaliningrad.
Posts: 406
Reputation: 18
Default 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."
ivndosos is offline   Reply With Quote
Old 11/02/2018, 11:01 AM   #7
Mugala
Gangsta
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: behind u
Posts: 645
Reputation: 30
Default 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?
__________________
here to help
Mugala is offline   Reply With Quote
Old 11/02/2018, 11:13 AM   #8
ivndosos
Huge Clucker
 
ivndosos's Avatar
 
Join Date: Sep 2014
Location: Russian Federation, Kaliningrad.
Posts: 406
Reputation: 18
Default 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;
}
ivndosos is offline   Reply With Quote
Old 11/02/2018, 11:15 AM   #9
Mugala
Gangsta
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: behind u
Posts: 645
Reputation: 30
Default 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);
__________________
here to help
Mugala is offline   Reply With Quote
Old 11/02/2018, 11:15 AM   #10
iKarim
Gangsta
 
iKarim's Avatar
 
Join Date: Oct 2015
Posts: 584
Reputation: 135
Default 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 View Post
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.
iKarim is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[QUESTION] Kind a team based question Dirkon Scripting Help 1 24/03/2013 08:05 PM
Question regarding playerid (noob question!) Mattjones17 Help Archive 5 27/10/2010 04:21 PM
Data type question.. (and mac address question) DarrenReeder Help Archive 2 21/10/2010 08:20 PM
Hello all i got one question (very easy to answer J.I.C question) SAMPfan109 General 0 06/03/2010 04:43 PM


All times are GMT. The time now is 10:53 PM.


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