SA-MP Forums Archive
Give player weapons from name - 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: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Give player weapons from name (/showthread.php?tid=310816)



Give player weapons from name - Snowman12 - 13.01.2012

Hey,

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

Thanks,

-Snowman12.


Re: Give player weapons from name - Steven82 - 13.01.2012

Your going to need the gun id's and names into an array. Have you ever looked at a vehicle name spawning system?


Re: Give player weapons from name - Scenario - 13.01.2012

Check fsdebug and look for the "/w2" command.


Re: Give player weapons from name - Snowman12 - 14.01.2012

Sorry I don't understand whats "fsdebug"? Thanks


Re: Give player weapons from name - Jakku - 14.01.2012

Quote:
Originally Posted by Snowman12
Посмотреть сообщение
Sorry I don't understand whats "fsdebug"? Thanks
It's a default filterscript which is included in your server package. (filterscripts folder)


Re: Give player weapons from name - iGetty - 14.01.2012

pawn Код:
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.


Re: Give player weapons from name - Snowman12 - 14.01.2012

Thanks