SA-MP Forums Archive
[Include] advFirearms3.inc - ALS Hooking - Create own weapons anytime! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] advFirearms3.inc - ALS Hooking - Create own weapons anytime! (/showthread.php?tid=613794)



advFirearms3.inc - ALS Hooking - Create own weapons anytime! - Luicy. - 31.07.2016

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", 31, 7);
    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", 31, 7);
    return 
1;
}
CMD:ar16(playerid) {
    new 
string[128];
    
format(string, 128, "The ID of AR 16 are %i.", FA::GetFirearmID("AR-16"));
    
SendClientMessage(playerid, -1, string);
    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", 31, 7);
    return 
1;
}
CMD:id1(playerid) {
    new 
string[128];
    
format(string, 128, "The name of ID 1 are %s.", FA::GetFirearmName(1));
    
SendClientMessage(playerid, -1, string);
    return 
1;
}
CMD:idar16(playerid) {
    new 
string[128];
    
format(string, 128, "The name of ID %i are %s.", FA::GetFirearmName(GUN::AR16));
    
SendClientMessage(playerid, -1, string);
    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", 31, 7);
    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", 31, 7);
    return 
1;
}
CMD:ar16(playerid) {
    if(
FA::IsValidFirearm(GUN::AR16)) {
        
FA::GivePlayerFirearm(playerid, GUN::AR16, 500);
    }
} 
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", 31, 7);
    return 
1;
}
CMD:gun(playerid) {
    if(
FA::IsPlayerHoldingAnyFirearm(playerid)) {
        
printf("Your gun model are %i.", FA::GetPlayerFirearm(playerid, 2));
    }
} 
This checks if you're holding any firearm, if you are, then it'll tell you which model, sorted by the slot.


Download
V3


Re: advFirearms3.inc - ALS Hooking - Create own weapons anytime! - SickAttack - 31.07.2016

"Your gun model are %i."

is^ is^

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

+6 rep


Re: advFirearms3.inc - ALS Hooking - Create own weapons anytime! - Luicy. - 31.07.2016

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?


Re: advFirearms3.inc - ALS Hooking - Create own weapons anytime! - SickAttack - 31.07.2016

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).


Re: advFirearms3.inc - ALS Hooking - Create own weapons anytime! - oSAINTo - 21.08.2016

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.


Re: advFirearms3.inc - ALS Hooking - Create own weapons anytime! - OneDay - 21.08.2016

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


Re: advFirearms3.inc - ALS Hooking - Create own weapons anytime! - WhiteGhost - 21.08.2016

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)