[Bug/SRV 0.3.7] Actor dies of Molotov,flamethrower
#1

The actor always die from the flamethrower and Molotov without hp

PHP код:
/**
 * GAMEMODE
 **/
#define GAMEMODE_NAME "game (lite version)"
#include <a_samp>
#include <a_actor>
#define MAX_MSG_SIZE (256)
#define COLOR_DEFAULT (0xAAAAAAFF)
main()
{
    print(
"\n----------------------------------");
    
printf(" Gamemode '%s' loaded",GAMEMODE_NAME);
    print(
"----------------------------------\n");
}
public 
OnGameModeInit()
{
    
// Don't use these lines if it's a filterscript
    
SetGameModeText("Blank Script");
    
AddPlayerClass(01958.37831343.157215.3746269.1425000000);
    return 
1;
}
public 
OnGameModeExit()
{
    return 
1;
}
public 
OnPlayerRequestClass(playeridclassid)
{
    
SetPlayerPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraPos(playerid1958.37831343.157215.3746);
    
SetPlayerCameraLookAt(playerid1958.37831343.157215.3746);
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    return 
1;
}
public 
OnPlayerSpawn(playerid)
{
    return 
1;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
    return 
1;
}
public 
OnVehicleSpawn(vehicleid)
{
    return 
1;
}
public 
OnVehicleDeath(vehicleidkillerid)
{
    return 
1;
}
public 
OnPlayerText(playeridtext[])
{
    return 
1;
}
new 
botid[MAX_ACTORS];
public 
OnPlayerCommandText(playeridcmdtext[])
{
    if (
strcmp("/mbot"cmdtexttrue10) == 0)
    {
    
        new 
Float:xFloat:yFloat:zFloat:a;
        
GetPlayerPos(playeridx,y,z);
        
GetPlayerFacingAngle(playerida);
    
        for(new 
iMAX_ACTORSi++) {
            if(!
IsValidActor(i)) {
                
CreateActor(random(299), x,y,za);
                
SetActorHealth(i100.0);
                
//ApplyActorAnimation(botid[i], "PED", "WALK_drunk", 4.1, 1, 1, 1, 1, 0);
                //ApplyActorAnimation(botid[i], "CHAINSAW", "CSAW_1", 4.1, 1, 1, 1, 1, 0);
                //SetActorInvulnerable(botid[i], true);
                
break;
            }
        }
        return 
1;
    }
    
    if (
strcmp("/dbot"cmdtexttrue10) == 0)
    {
        for(new 
iMAX_ACTORSi++) {
            if(
IsValidActor(i)) DestroyActor(i);
        }
        return 
1;
    }
    if (
strcmp("/hbot"cmdtexttrue10) == 0)
    {
        for(new 
iMAX_ACTORSi++) {
            if(
IsValidActor(i)) SetActorHealth(i0.0);
        }
        return 
1;
    }
    if (
strcmp("/h2bot"cmdtexttrue10) == 0)
    {
        for(new 
iMAX_ACTORSi++) {
            
SetActorHealth(i100.0);
        }
        return 
1;
    }
    if (
strcmp("/abot"cmdtexttrue10) == 0)
    {
        for(new 
iMAX_ACTORSi++) {
            if(
IsValidActor(i)) {
                new 
msg[MAX_MSG_SIZE];
                new 
Float:a;
                
                
GetActorFacingAngle(ia);
                
format(msgMAX_MSG_SIZE"GetActorFacingAngle actor %d current_angle %.1f"ia);
                
SendClientMessage(playeridCOLOR_DEFAULTmsg);
                
                
SetActorFacingAngle(i180.0);
                
                
GetActorFacingAngle(ia);
                
format(msgMAX_MSG_SIZE"SetActorFacingAngle actor %d set 180.0 current_angle %.1f"ia);
                
SendClientMessage(playeridCOLOR_DEFAULTmsg);
            }
        }
              return 
1;
    }
    
    return 
0;
}
public 
OnPlayerGiveDamageActor(playeriddamaged_actoridFloat:amountweaponidbodypart) {
    if(
IsValidActor(damaged_actorid)) {
        new 
msg[MAX_MSG_SIZE];
        new 
Float:hp;
        
GetActorHealth(damaged_actoridhp);
        
format(msgMAX_MSG_SIZE"OnGiveDMG player %d <weaponid %d dmg %.1f> actor %d hp %.1f"playeridweaponidamountdamaged_actoridhp);
        
SendClientMessage(playeridCOLOR_DEFAULTmsg);
    }
    return 
1;

Reply
#2

you can fix it!
pawn Код:
public OnPlayerGiveDamageActor(playerid, damaged_actorid, Float: amount, weaponid, bodypart)
{
    new string[128], attacker[MAX_PLAYER_NAME];
    new weaponname[24];
    GetPlayerName(playerid, attacker, sizeof (attacker));
    GetWeaponName(weaponid, weaponname, sizeof (weaponname));
 
    format(string, sizeof(string), "%s has made %.0f damage to actor id %d, weapon: %s", attacker, amount, damaged_actorid, weaponname);
    SendClientMessageToAll(0xFFFFFFFF, string);
 
    if(!IsActorInvulnerable(damaged_actorid)) //Check if actor is vulnerable
    {
        new Float:health;
        GetActorHealth(damaged_actorid, health); //Get current health
        if(weaponid==37)amount=9;
        SetActorHealth(damaged_actorid, health-amount); //Apply damage, set new health
    }
    return 1;
}
wiki
pawn Код:
The weaponid will return 37 (flame thrower) from any fire sources (e.g. molotov, 18)
Reply
#3

Quote:
Originally Posted by long76
Посмотреть сообщение
you can fix it!
pawn Код:
public OnPlayerGiveDamageActor(playerid, damaged_actorid, Float: amount, weaponid, bodypart)
{
    new string[128], attacker[MAX_PLAYER_NAME];
    new weaponname[24];
    GetPlayerName(playerid, attacker, sizeof (attacker));
    GetWeaponName(weaponid, weaponname, sizeof (weaponname));
 
    format(string, sizeof(string), "%s has made %.0f damage to actor id %d, weapon: %s", attacker, amount, damaged_actorid, weaponname);
    SendClientMessageToAll(0xFFFFFFFF, string);
 
    if(!IsActorInvulnerable(damaged_actorid)) //Check if actor is vulnerable
    {
        new Float:health;
        GetActorHealth(damaged_actorid, health); //Get current health
        if(weaponid==37)amount=9;
        SetActorHealth(damaged_actorid, health-amount); //Apply damage, set new health
    }
    return 1;
}
wiki
pawn Код:
The weaponid will return 37 (flame thrower) from any fire sources (e.g. molotov, 18)
Thanks
Official fixes us to wait who knows?
Reply
#4

Quote:
Originally Posted by long76
Посмотреть сообщение
you can fix it!
pawn Код:
public OnPlayerGiveDamageActor(playerid, damaged_actorid, Float: amount, weaponid, bodypart)
{
    new string[128], attacker[MAX_PLAYER_NAME];
    new weaponname[24];
    GetPlayerName(playerid, attacker, sizeof (attacker));
    GetWeaponName(weaponid, weaponname, sizeof (weaponname));
 
    format(string, sizeof(string), "%s has made %.0f damage to actor id %d, weapon: %s", attacker, amount, damaged_actorid, weaponname);
    SendClientMessageToAll(0xFFFFFFFF, string);
 
    if(!IsActorInvulnerable(damaged_actorid)) //Check if actor is vulnerable
    {
        new Float:health;
        GetActorHealth(damaged_actorid, health); //Get current health
        if(weaponid==37)amount=9;
        SetActorHealth(damaged_actorid, health-amount); //Apply damage, set new health
    }
    return 1;
}
wiki
pawn Код:
The weaponid will return 37 (flame thrower) from any fire sources (e.g. molotov, 18)
It is not my bug fixes. When I shoot the actor from the flamethrower or Molotov he falls to the ground

P.S.:
If worked
PHP код:
OnPlayerGiveDamageActor (playeriddamaged_actoridFloatamountweaponidbodypart); + SetActorInvulnerable (actoridtrue); 
I process myself to damage.

But the function does not return if the switches on
PHP код:
SetActorInvulnerable(actoridtrue); 
Reply
#5

after created actor use SetActorInvulnerable(actorid, true);. it should work.
pawn Код:
public OnPlayerGiveDamageActor(playerid, damaged_actorid, Float: amount, weaponid, bodypart)
{
    new string[128], attacker[MAX_PLAYER_NAME];
    new weaponname[24];
    GetPlayerName(playerid, attacker, sizeof (attacker));
    GetWeaponName(weaponid, weaponname, sizeof (weaponname));
 
    format(string, sizeof(string), "%s has made %.0f damage to actor id %d, weapon: %s", attacker, amount, damaged_actorid, weaponname);
    SendClientMessageToAll(0xFFFFFFFF, string);
        new Float:health;
        GetActorHealth(damaged_actorid, health); //Get current health
        if(weaponid==37)amount=9;
        SetActorHealth(damaged_actorid, health-amount); //Apply damage, set new health
    return 1;
}
Reply
#6

Quote:
Originally Posted by long76
Посмотреть сообщение
after created actor use SetActorInvulnerable(actorid, true);. it should work.
pawn Код:
public OnPlayerGiveDamageActor(playerid, damaged_actorid, Float: amount, weaponid, bodypart)
{
    new string[128], attacker[MAX_PLAYER_NAME];
    new weaponname[24];
    GetPlayerName(playerid, attacker, sizeof (attacker));
    GetWeaponName(weaponid, weaponname, sizeof (weaponname));
 
    format(string, sizeof(string), "%s has made %.0f damage to actor id %d, weapon: %s", attacker, amount, damaged_actorid, weaponname);
    SendClientMessageToAll(0xFFFFFFFF, string);
        new Float:health;
        GetActorHealth(damaged_actorid, health); //Get current health
        if(weaponid==37)amount=9;
        SetActorHealth(damaged_actorid, health-amount); //Apply damage, set new health
    return 1;
}
You checked his example?

When enabled SetActorInvulnerable (actorid, true);
Stop working OnPlayerGiveDamageActor(playerid, damaged_actorid, Float: amount, weaponid, bodypart);

If SetActorInvulnerable (actorid, true);
OnPlayerGiveDamageActor (playerid, damaged_actorid, Float: amount, weaponid, bodypart) does not work

My script:
PHP код:
/**
 * GAMEMODE : game (lite version)
 * revision : 0.1 @9 may 2015
 * author   : fERO aka Logofero
 **/
#define GAMEMODE_NAME "game (lite version)"
#include <a_samp>
#include <a_actor>
#define MAX_MSG_SIZE (256)
#define COLOR_DEFAULT (0xAAAAAAFF)
main()
{
    print(
"\n----------------------------------");
    
printf(" Gamemode '%s' loaded",GAMEMODE_NAME);
    print(
"----------------------------------\n");
}
public 
OnGameModeInit()
{
    
SetGameModeText(GAMEMODE_NAME);
    
AddPlayerClass(00.0,0.0,5.00.0000000);
    return 
1;
}
public 
OnGameModeExit()
{
    return 
1;
}
public 
OnPlayerRequestClass(playeridclassid)
{
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    return 
1;
}
public 
OnPlayerSpawn(playerid)
{
    return 
1;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
     return 
1;
}
public 
OnVehicleSpawn(vehicleid)
{
    return 
1;
}
public 
OnVehicleDeath(vehicleidkillerid)
{
    return 
1;
}
public 
OnPlayerText(playeridtext[])
{
    return 
1;
}
public 
OnPlayerUpdate(playerid)
{
    return 
1;
}
public 
OnPlayerCommandText(playeridcmdtext[])
{
    if (
strcmp("/kill"cmdtexttrue10) == 0)
    {
          
SetPlayerHealth(playerid0);
        return 
1;
    }
    
    if (
strcmp("/mbot"cmdtexttrue10) == 0)
    {
        new 
Float:xFloat:yFloat:zFloat:a;
        
GetPlayerPos(playeridx,y,z);
        
GetPlayerFacingAngle(playerida);
    
        new 
id CreateActor(random(299), x,y,za);
        
//SetActorHealth(id, 100.0);
        //ApplyActorAnimation(id, "PED", "WALK_drunk", 4.1, 1, 1, 1, 1, 0);
        //ApplyActorAnimation(id, "CHAINSAW", "CSAW_1", 4.1, 1, 1, 1, 1, 0);
        
SetActorInvulnerable(idtrue); // <- Enabled!
        
return 1;
    }
    
    if (
strcmp("/dbot"cmdtexttrue10) == 0)
    {
        for(new 
iMAX_ACTORSi++) {
            if(
IsValidActor(i)) DestroyActor(i);
        }
        return 
1;
    }
    if (
strcmp("/hbot"cmdtexttrue10) == 0)
    {
        for(new 
iMAX_ACTORSi++) {
            if(
IsValidActor(i)) SetActorHealth(i0.0);
        }
        return 
1;
    }
    if (
strcmp("/h2bot"cmdtexttrue10) == 0)
    {
        for(new 
iMAX_ACTORSi++) {
            if(
IsValidActor(i)) SetActorHealth(i100.0);
        }
        return 
1;
    }
    if (
strcmp("/abot"cmdtexttrue10) == 0)
    {
        for(new 
iMAX_ACTORSi++) {
            if(
IsValidActor(i)) {
                new 
msg[MAX_MSG_SIZE];
                new 
Float:a;
                
                
GetActorFacingAngle(ia);
                
format(msgMAX_MSG_SIZE"GetActorFacingAngle actor %d current_angle %.1f"ia);
                
SendClientMessage(playeridCOLOR_DEFAULTmsg);
                
                
SetActorFacingAngle(i180.0);
                
                
GetActorFacingAngle(ia);
                
format(msgMAX_MSG_SIZE"SetActorFacingAngle actor %d set 180.0 current_angle %.1f"ia);
                
SendClientMessage(playeridCOLOR_DEFAULTmsg);
            }
        }
        return 
1;
    }
    return 
0;
}
public 
OnPlayerGiveDamage(playeriddamagedidFloat:amountweaponidbodypart) {
    return 
1;
}
public 
OnPlayerGiveDamageActor(playeriddamaged_actoridFloat:amountweaponidbodypart) { //does not work!
new string[128], attacker[MAX_PLAYER_NAME];
    new 
weaponname[24];
    
GetPlayerName(playeridattackersizeof (attacker));
    
GetWeaponName(weaponidweaponnamesizeof (weaponname));
    
format(stringsizeof(string), "%s has made %.0f damage to actor id %d, weapon: %s"attackeramountdamaged_actoridweaponname);
    
SendClientMessageToAll(0xFFFFFFFFstring);
    new 
Float:health;
    
GetActorHealth(damaged_actoridhealth); //Get current health
    
if(weaponid==37)amount=9;
    
SetActorHealth(damaged_actoridhealth-amount); //Apply damage, set new health
    
return 1;

Add:

if SetActorInvulnerable (actorid,false);
OnPlayerGiveDamageActor (playerid, damaged_actorid, Float: amount, weaponid, bodypart); work!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)