Give player weapons from name
#1

Hey,

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

Thanks,

-Snowman12.
Reply
#2

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

Check fsdebug and look for the "/w2" command.
Reply
#4

Sorry I don't understand whats "fsdebug"? Thanks
Reply
#5

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)
Reply
#6

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.
Reply
#7

Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)