quick question
#6

Quote:
Originally Posted by iNuBe
Посмотреть сообщение
but sir i'm but a simple scripter and it takes a lot of time to find this out on y own why not use my professional scripting brothers who know better
pawn Код:
// ** INCLUDES

#include <a_samp>

// ** VARIABLES

// *** GLOBAL VARIABLES

// **** GENERAL

new gActor,
bool:gActorDead = false;

// ** MAIN

main()
{
    print("Loaded \"killable_actor.amx\".");
}

// ** CALLBACKS

public OnGameModeInit()
{
    gActor = CreateActor(0, 136.6050, -74.2258, 1.4297, 0.0);
    SetActorInvulnerable(gActor, false);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    GivePlayerWeapon(playerid, 26, 500);
    return 1;
}

public OnPlayerGiveDamageActor(playerid, damaged_actorid, Float:amount, weaponid, bodypart)
{
    new Float:health;
    GetActorHealth(gActor, health);

    if(health >= 0.0)
    {
        SetActorHealth(gActor, health - amount);
    }

    if(!gActorDead && (health - amount) <= 0.0)
    {
        gActorDead = true;

        OnActorDeath(damaged_actorid, playerid, weaponid);
    }
    return 1;
}

forward OnActorDeath(actorid, killerid, reason);
public OnActorDeath(actorid, killerid, reason)
{
    if(!IsValidActor(actorid)) return 0;

    if(IsValidWeaponID(reason))
    {
        new weapon_name[20];
        if(reason == 0)
        {
            strcat(weapon_name, "Fists");
        }
        else
        {
            GetWeaponName(reason, weapon_name, sizeof(weapon_name));
        }

        new string[144];
        format(string, sizeof(string), "%s (%d) killed the actor #%d - %s.", PlayerName(killerid), killerid, actorid, weapon_name);
        SendClientMessageToAll(0x9F3535FF, string);
    }
    return 1;
}

// ** FUNCTIONS

forward bool:IsValidWeaponID(weaponid);
public bool:IsValidWeaponID(weaponid)
{
    if(weaponid < 0 || weaponid > 46) return false;

    switch(weaponid)
    {
        case 0, 19, 20, 21, 48: return false;
        default: return true;
    }
    return false;
}

stock PlayerName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    return name;
}
Reply


Messages In This Thread
quick question - by iNuBe - 18.12.2015, 19:39
Re: quick question - by SickAttack - 18.12.2015, 19:43
Re: quick question - by iNuBe - 18.12.2015, 19:51
Re: quick question - by SickAttack - 18.12.2015, 20:31
Re: quick question - by iNuBe - 18.12.2015, 21:28
Re: quick question - by SickAttack - 18.12.2015, 21:50

Forum Jump:


Users browsing this thread: 1 Guest(s)