[Include] advFirearms3.inc - ALS Hooking - Create own weapons anytime!
#1

Introduction
Advanced Firearm System was my very first include I ever made, so I decided to update it. This time am I hooking it, and now you can create firearms yourself, anywhere, anytime.
Functions
Код:
FA::CreateFirearm(name[], weaponid, damage);
FA::GetFirearmID(name[]);
FA::GetFirearmName(id);
FA::IsValidFirearm(id);
FA::GivePlayerFirearm(playerid, FA::id, FA::ammo);
FA::GetPlayerFirearm(playerid, FA::slot);
FA::GetPlayerHoldingFirearm(playerid);
FA::IsPlayerHoldingAnyFirearm(playerid);
Explanation
FA::CreateFirearm(name[], weaponid, damage);
PHP код:
new GUN::AR16;
public 
OnGameModeInit() {
    
GUN::AR16 FA::CreateFirearm("AR-16"317);
    return 
1;

This creates the firearm and returns the ID of the firearm.

FA::GetFirearmID(name[]);
PHP код:
new GUN::AR16;
public 
OnGameModeInit() {
    
GUN::AR16 FA::CreateFirearm("AR-16"317);
    return 
1;
}
CMD:ar16(playerid) {
    new 
string[128];
    
format(string128"The ID of AR 16 are %i."FA::GetFirearmID("AR-16"));
    
SendClientMessage(playerid, -1string);
    return 
1;

This looks for the ID for that weapon, if it's not found it will return INVALID_FIREARM_ID

FA::GetFirearmName(id);
PHP код:
new GUN::AR16;
public 
OnGameModeInit() {
    
GUN::AR16 FA::CreateFirearm("AR-16"317);
    return 
1;
}
CMD:id1(playerid) {
    new 
string[128];
    
format(string128"The name of ID 1 are %s."FA::GetFirearmName(1));
    
SendClientMessage(playerid, -1string);
    return 
1;
}
CMD:idar16(playerid) {
    new 
string[128];
    
format(string128"The name of ID %i are %s."FA::GetFirearmName(GUN::AR16));
    
SendClientMessage(playerid, -1string);
    return 
1;

This looks for the name for that weapon, if it's not found it will return INVALID_FIREARM_ID

FA::IsValidFirearm(id);
PHP код:
new GUN::AR16;
public 
OnGameModeInit() {
    
GUN::AR16 FA::CreateFirearm("AR-16"317);
    return 
1;
}
CMD:ar16(playerid) {
    if(
FA::IsValidFirearm(GUN::AR16)) {
        
SendClientMessage(playerid, -1"It's a valid weapon!");
    }

This checks if the ID exists, it will return 1 if it do, else INVALID_FIREARM_ID

FA::GivePlayerFirearm(playerid, FA::id, FA::ammo);
PHP код:
new GUN::AR16;
public 
OnGameModeInit() {
    
GUN::AR16 FA::CreateFirearm("AR-16"317);
    return 
1;
}
CMD:ar16(playerid) {
    if(
FA::IsValidFirearm(GUN::AR16)) {
        
FA::GivePlayerFirearm(playeridGUN::AR16500);
    }

This basically gives the player that weapon model with ammunation.

FA::GetPlayerFirearm(playerid, FA:lot); AND FA::IsPlayerHoldingAnyFirearm(playerid);
PHP код:
new GUN::AR16;
public 
OnGameModeInit() {
    
GUN::AR16 FA::CreateFirearm("AR-16"317);
    return 
1;
}
CMD:gun(playerid) {
    if(
FA::IsPlayerHoldingAnyFirearm(playerid)) {
        
printf("Your gun model are %i."FA::GetPlayerFirearm(playerid2));
    }

This checks if you're holding any firearm, if you are, then it'll tell you which model, sorted by the slot.


Download
V3
Reply
#2

"Your gun model are %i."

is^ is^

It's vastly simple, but could be useful for lazy people. Good job.

+6 rep
Reply
#3

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
"Your gun model are %i."

is^ is^
Can you stop spamming my profile page and my threads correcting my grammar mistakes?
Reply
#4

case 2, 3, 4, 5, 6, 7, 8, 9:

could be

case 2..9:

-----------------------------------------------------------------------

pawn Код:
stock FA::GetPlayerFirearm(playerid, FA::slot) {
        if(FA::Player[playerid][FA::slot] == INVALID_FIREARM_ID)
            return INVALID_FIREARM_ID;
        else
            return FA::Player[playerid][FA::slot];
    }
Just return FA::Player[playerid][FA::slot];, same thing.

-----------------------------------------------------------------------

I don't like the spam of FA::, but that's just personal preference (or is it?).

-----------------------------------------------------------------------

etc.

Quote:
Originally Posted by Meller
Посмотреть сообщение
Can you stop spamming my profile page and my threads correcting my grammar mistakes?
Could you not get upset when someone corrects you? Or tells you what's not allowed? Arrogance.

Ignoring and announcing wrong things won't help you (I never reported your "teamviewer" thread).
Reply
#5

Can someone explain to me a basic script with this? Just write one or something. I follow your steps here and well, whenever I try and spawn a custom gun, I just get the regular weapon. I know the model is supposed to be the same, but I came to find everything was the same. I just want to be able to have two desert eagles have different names and different damage values.
Reply
#6

why is GivePlayerFirearm take FA::id but you give it GUN::id? What is the tag?
Reply
#7

Quote:
Originally Posted by Luicy.
Посмотреть сообщение
Can you stop spamming my profile page and my threads correcting my grammar mistakes?
Ignore him. hes like a auto correct.

Quote:
Originally Posted by SickAttack
Why are you still here? Go life your life.
But unfortunately he made a mistake. (facepalm)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)