[Include] Creating a robbable actor!
#1

Introduction
Inspired by GTA V store robbery. actor_robbery.inc imitates it! You basically aim at the actor and the actor will play 3 animation sequence, the actor will either give you the money or you will leave empty handed. The picture below explains it all.

Animation Sequence
  1. SHP_Rob_HandsUp
  2. SHP_Rob_GiveCash
  3. DUCK_cower
Functions
Код:
Function:
	CreateActorRobbery

Info:
	Creates the robbery actor according to the position set.

Param:
* skinid -> Skin ID of the robbery actor
* Float:x -> Coordinate X of the robbery actor
* Float:y -> Coordinate X of the robbery actor
* Float:z -> Coordinate X of the robbery actor
* Float:ang -> Facing angle of the robbery actor
* actor_vwid -> virtualid of the robbery actor
* r_moneymin -> Minimum money to be robbed from the robbery actor
* r_moneymax -> Maximum money to be robbed from the robbery actor
Код:
Function:
	GetActorRobberyData

Info:
	Retrieves the actor data

Param:
	* actorid -> ID of robbery actor you want to retrieve data from. 
	* &skinid -> Skin ID of the robbery actor
	* &Float:x -> Coordinate X of the robbery actor
	* &Float:y -> Coordinate X of the robbery actor
	* &Float:z -> Coordinate X of the robbery actor
	* &Float:ang -> Facing angle of the robbery actor
	* &actor_vwid -> virtualid of the robbery actor
	* &r_moneymin -> Minimum money to be robbed from the robbery actor
	* &r_moneymax -> Maximum money to be robbed from the robbery actor
Код:
Function: 
	GetActorFreeID

Info:	
	Retrieves the unused ID of an actor.

Param:
	None
Callbacks
Код:
//OnPlayerStartRobbery is called when the player aims at an actor.
forward OnPlayerStartRobbery(playerid, actorid, robbed_recently);

//OnPlayerFinishRobbery is called when the 3 animation sequence has been played.
forward OnPlayerFinishRobbery(playerid, actorid, robbedmoney, type);
EXAMPLE CODE
pawn Код:
public OnPlayerStartRobbery(playerid, actorid, robbed_recently)
{
    new string[128];
    if(robbed_recently)
    {
        format(string, sizeof(string), "ActorID: %i -> has been robbed recently, please try again later!");
        SendClientMessage(playerid, -1, string);
        return 0;
    }
    else
    {
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));

        format(string, sizeof(string), "Player %s(%i) has begun robbing actorid: %i", name, playerid, actorid);
        SendClientMessage(playerid, -1, string);
    }
    return 1;
}


public OnPlayerFinishRobbery(playerid, actorid, robbedmoney, type)
{
    new string[128];

    switch(type)
    {
        case TYPE_SUCCESS:
        {
            format(string, sizeof(string), "[ROBBERY SUCCESS]: You have manage to steal $%i from actorid: %i", robbedmoney, actorid);
            SendClientMessage(playerid, -1, string);

            format(string, sizeof(string), "~w~You stole~n~~g~$%i", robbedmoney);
            GameTextForPlayer(playerid, string, 6000, 1);  
        }
        case TYPE_FAILED:
        {
            SendClientMessage(playerid, -1, "[ROBBERY FAILED]: Cashier refused to give money!");
            GameTextForPlayer(playerid, "~r~Robbery Failed", 6000, 1);
        }
        case TYPE_UNFINISHED:
        {
            SendClientMessage(playerid, -1, "[ROBBERY FAILED]: You have gone too far away from the actor, he managed to call 911! RUN!");
            GameTextForPlayer(playerid, "~r~Robbery Failed", 6000, 1);
        }
    }
    SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 2);
    return 1;
}
Screenshots: Click Me!

Download: Click Me!
Reply
#2

Decent work.

+rep
Reply
#3

Well done.

+rep.
Reply
#4

Nice work
Reply
#5

Good work mate!

Rep+
Reply
#6

Nice include, gonna use it right away.
Reply
#7

Very nice
Reply
#8

Looks pretty great.
Reply
#9

Added example code!

pawn Код:
public OnPlayerStartRobbery(playerid, actorid, robbed_recently)
{
    new string[128];
    if(robbed_recently)
    {
        format(string, sizeof(string), "ActorID: %i -> has been robbed recently, please try again later!");
        SendClientMessage(playerid, -1, string);
        return 0;
    }
    else
    {
        new name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, sizeof(name));

        format(string, sizeof(string), "Player %s(%i) has begun robbing actorid: %i", name, playerid, actorid);
        SendClientMessage(playerid, -1, string);
    }
    return 1;
}


public OnPlayerFinishRobbery(playerid, actorid, robbedmoney, type)
{
    new string[128];

    switch(type)
    {
        case TYPE_SUCCESS:
        {
            format(string, sizeof(string), "[ROBBERY SUCCESS]: You have manage to steal $%i from actorid: %i", robbedmoney, actorid);
            SendClientMessage(playerid, -1, string);

            format(string, sizeof(string), "~w~You stole~n~~g~$%i", robbedmoney);
            GameTextForPlayer(playerid, string, 6000, 1);  
        }
        case TYPE_FAILED:
        {
            SendClientMessage(playerid, -1, "[ROBBERY FAILED]: Cashier refused to give money!");
            GameTextForPlayer(playerid, "~r~Robbery Failed", 6000, 1);
        }
        case TYPE_UNFINISHED:
        {
            SendClientMessage(playerid, -1, "[ROBBERY FAILED]: You have gone too far away from the actor, he managed to call 911! RUN!");
            GameTextForPlayer(playerid, "~r~Robbery Failed", 6000, 1);
        }
    }
    SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 2);
    return 1;
}

Thanks @all
Reply
#10

Nice mate!
Reply
#11

good job
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)