#1

How can I make this code work only for guns without many ifs or a switch?
Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
	PlayerTextDrawShow(playerid, Crosshair[playerid]);
	SetTimer("RemoveCrosshair", 350, false);
        return 1;
}
Also if I attach a 3D text label to two or more players then it's working fine, they are both visible and working fine, but when the script deletes a 3D textdraw let's say by doing /deletemylabel then all the textdraws on the players disappear. How to make it like that every player has his own 3D text label that others can see? Is it created with CreatePlayer3DTextLabel? I want this for my death system, when player is dead he will have a label on him saying he's dead.
Reply
#2

For the weapon: You don't need to detect for every armed weapons, just simply check if the weaponid is not fist or other melee weapons inside the switch except armed ones then show the textdraw. Using switch is faster than using if and else.

For 3D textlabel, you need to create per-player 3Dtextlabel.

Код:
new Text3D: Label[MAX_PLAYERS]; // Global var

Label[playerid] = Create3DTextLabel(...); // Creating the label

Attach3DTextLabelToPlayer(playerid, Label[playerid], ...); // Attaching

Delete3DTextLabel(Label[playerid]); // Deleting
Reply
#3

Quote:
Originally Posted by Sjn
Посмотреть сообщение
For the weapon: You don't need to detect for every armed weapons, just simply check if the weaponid is not fist or other melee weapons inside the switch except armed ones then show the textdraw. Using switch is faster than using if and else.

For 3D textlabel, you need to create per-player 3Dtextlabel.

Код:
new Text3D: Label[MAX_PLAYERS]; // Global var

Label[playerid] = Create3DTextLabel(...); // Creating the label

Attach3DTextLabelToPlayer(playerid, Label[playerid], ...); // Attaching

Delete3DTextLabel(Label[playerid]); // Deleting
Thanks, but how can I create a switch like that? I never created any switches and wiki didn't make me smarter too.
Reply
#4

I am sorry, I just realized that detecting non firearm weapons would be a lot of work than detecting firearms ones.

PHP код:
switch (weaponid)
{
    case 
22..34:
    {
        
// Show the textdraw here
    
}

Weapon ids from 22 to 34 are firearms. So, switch between them and show the textdraw.
Reply
#5

Quote:
Originally Posted by Sjn
Посмотреть сообщение
I am sorry, I just realized that detecting non firearm weapons would be a lot of work than detecting firearms ones.

PHP код:
switch (weaponid)
{
    case 
22..34:
    {
        
// Show the textdraw here
    
}

Weapon ids from 22 to 34 are firearms. So, switch between them and show the textdraw.
Thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)