Jump to content

use all weapons


Dolinho

Recommended Posts

This is quite laborious.

Saw this in the MTA wiki. I thought it was What do I want to but I am mistaken.

function giveWeapons(player, weaponsString) 
    local weaponsTable = split(weaponsString, ';') --split the string by the semi colon 
    for k,v in ipairs(weaponsTable) do --for all the split values do 
        weaponId = gettok(v, 1, string.byte(',')) --get the weapon ID using gettok, retrieve the first token 
        weaponAmmo = gettok(v, 2, string.byte(',')) --get the ammo using gettok, retrieve the second token 
        if (weaponId ~= nil and weaponAmmo ~= nil) then --if neither of them is invalid 
            giveWeapon(player, weaponId, weaponAmmo) --give the player the weapons 
        end 
    end 
end 

Link to comment
  • 5 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...