SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 13/01/2012, 11:10 PM   #1
Snowman12
Huge Clucker
 
Join Date: Jan 2011
Location: Nottingham, UK.
Posts: 445
Reputation: 23
Default Give player weapons from name

Hey,

What functions would I need to make a /getgun [WEAPON_NAME] command?

Thanks,

-Snowman12.
__________________
I must apologize, I'm very sorry for being random.

Show your support by stopping this immature user "Brian_G" from stealing images from me/and others by leaving this on your signature.
Snowman12 is offline   Reply With Quote
Old 13/01/2012, 11:52 PM   #2
Steven82
High-roller
 
Join Date: Nov 2009
Posts: 2,431
Reputation: 186
Default Re: Give player weapons from name

Your going to need the gun id's and names into an array. Have you ever looked at a vehicle name spawning system?
__________________
If you read my old posts; I apologize in advance.
Steven82 is offline   Reply With Quote
Old 13/01/2012, 11:54 PM   #3
Scenario
Godfather
 
Scenario's Avatar
 
Join Date: Feb 2010
Location: Heaven
Posts: 7,802
Reputation: 701
Default Re: Give player weapons from name

Check fsdebug and look for the "/w2" command.
Scenario is offline   Reply With Quote
Old 14/01/2012, 12:02 AM   #4
Snowman12
Huge Clucker
 
Join Date: Jan 2011
Location: Nottingham, UK.
Posts: 445
Reputation: 23
Default Re: Give player weapons from name

Sorry I don't understand whats "fsdebug"? Thanks
__________________
I must apologize, I'm very sorry for being random.

Show your support by stopping this immature user "Brian_G" from stealing images from me/and others by leaving this on your signature.
Snowman12 is offline   Reply With Quote
Old 14/01/2012, 12:04 AM   #5
Jakku
High-roller
 
Jakku's Avatar
 
Join Date: Apr 2009
Location: Heinola, Finland
Posts: 1,354
Reputation: 157
Default Re: Give player weapons from name

Quote:
Originally Posted by Snowman12 View Post
Sorry I don't understand whats "fsdebug"? Thanks
It's a default filterscript which is included in your server package. (filterscripts folder)
__________________
Jakku is offline   Reply With Quote
Old 14/01/2012, 01:12 AM   #6
iGetty
High-roller
 
iGetty's Avatar
 
Join Date: Sep 2010
Location: Falkirk, Scotland
Posts: 1,753
Reputation: 224
Default Re: Give player weapons from name

pawn Code:
dcmd_w2(playerid, params[])
{
    new idx, iString[128];
    iString = strtok(params, idx);

    if (!strlen(iString)) {
        SendClientMessage(playerid, COLOR_RED, "[USAGE]: /w2 WEAPONID/NAME (AMMO) or /weapon WEAPONID/NAME (AMMO)");
        return true;
    }

    new weaponid = GetWeaponModelIDFromName(iString);

    if (weaponid == -1) {
        weaponid = strval(iString);
        if (weaponid < 0 || weaponid > 47) {
            SendClientMessage(playerid, COLOR_RED, "[ERROR]: Invalid WEAPONID/NAME");
            return true;
        }
    }

    if (!strlen(params[idx+1])) {
        GivePlayerWeapon(playerid, weaponid, 500);

        format(iString, 128, "[SUCCESS]: You were given weapon %s (ID: %d) with 500 ammo.", aWeaponNames[weaponid], weaponid);
        SendClientMessage(playerid, COLOR_GREEN, iString);

        return true;
    }

    idx = strval(params[idx+1]);

    GivePlayerWeapon(playerid, weaponid, idx);

    format(iString, 128, "[SUCCESS]: You were given weapon %s (ID: %d) with %d ammo.", aWeaponNames[weaponid], weaponid, idx);
    SendClientMessage(playerid, COLOR_GREEN, iString);

    return true;
}

That's the /w2 command.

Check that out and maybe you'll get an idea.
iGetty is offline   Reply With Quote
Old 14/01/2012, 01:46 AM   #7
Snowman12
Huge Clucker
 
Join Date: Jan 2011
Location: Nottingham, UK.
Posts: 445
Reputation: 23
Default Re: Give player weapons from name

Thanks
__________________
I must apologize, I'm very sorry for being random.

Show your support by stopping this immature user "Brian_G" from stealing images from me/and others by leaving this on your signature.
Snowman12 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A command to Give weapons? M.A Help Archive 3 14/08/2010 06:07 PM
MOVED: problem: give player weapons via if() dugi Server Support 0 01/05/2010 10:29 AM
problem: give player weapons via if() master2die Help Archive 5 01/05/2010 07:18 AM
Give weapons when you tele? Quest123 Help Archive 1 30/10/2009 10:43 AM
Command To Give Weapons Dmac_91 Help Archive 4 27/05/2009 08:19 AM


All times are GMT. The time now is 12:44 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.