What's wrong in this?
#1

I'm trying to make a Taser.
Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
 if(gPlayerClass[playerid] == Policeman)
	 {
	    if(issuerid != INVALID_PLAYER_ID && weaponid == 23)
	    {
	         ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0);
	    }
	 }
    return 1;
}
It's not working.
Reply
#2

You likely want to check the gPlayerClass of the issuer, not the target. That also implies you want to move the INVALID_PLAYER_ID check in that condition too.
Reply
#3

Quote:
Originally Posted by TheCman
Посмотреть сообщение
You likely want to check the gPlayerClass of the issuer, not the target. That also implies you want to move the INVALID_PLAYER_ID check in that condition too.
Okay, I didn't understand (lol)
Reply
#4

Err...
PHP код:
public OnPlayerTakeDamage(playeridissueridFloatamountweaponidbodypart)
{
    if(
        
issuerid != INVALID_PLAYER_ID &&
        
gPlayerClass[issuerid] == Policeman &&
        
weaponid == 23
    
)
        
ApplyAnimation(playerid"CRACK""crckdeth2"4.010000);

    return 
1;

Something like that.
Reply
#5

bumping this thread to draw attention\n
Not working
Reply
#6

First check if you have any other scripts loaded that are using "OnPlayerTakeDamage" function, Only use it in one script
2nd, sometimes the animation dosen't work correctly so try this.
PHP код:
public OnPlayerTakeDamage(playeridissueridFloatamountweaponidbodypart)
{
        if(
gPlayerClass[killerid] == Policeman)
        {
        if(
issuerid != INVALID_PLAYER_ID && weaponid == 23)
        {
                 
ClearAnimations(playerid);
                 
ApplyAnimation(playerid"CRACK""crckdeth2"4.010000);
                 
ApplyAnimation(playerid"CRACK""crckdeth2"4.010000);
                 
ApplyAnimation(playerid"CRACK""crckdeth2"4.010000);
        }
        }
        return 
1;

Reply
#7

I recommend using OnPlayerWeaponShot for what you're doing.

https://sampwiki.blast.hk/wiki/OnPlayerWeaponShot

Код:
Return Values:
      0 - Prevent the bullet from causing damage.
Is something you should also do for tasers.

An example:

PHP код:
public OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
{
    if(
hittype == BULLET_HIT_TYPE_PLAYER)
   {
         if(
gPlayerClass[playerid] == Policeman && weaponid == 23)
         {
            
ApplyAnimation(hitid"CRACK""crckdeth2"4.010000);
            
//Just to ensure it works, we'll send a message to the playerid:
           
SendClientMessage(playerid, -1"You hit someone with your taser.");
           return 
0// player wont take damage.
         
}
    }
    return 
1;

I also recommend making a variable for tasers when the player uses the /taser command OR however it's issued.

I don't know if it's possible in your script for that class player to just be wielding an ordinary Silenced Pistol but it's a suggestion.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)