Dany Alex Posted April 26, 2016 Posted April 26, 2016 How to make weapons can be taken in one dimension only? --------------------------- -- Weapon window --------------------------- function addWeapon(leaf, amount) if type(leaf) ~= 'table' then leaf = getSelectedGridListLeaf(wndWeapon, 'weaplist') amount = getControlNumber(wndWeapon, 'amount') if not amount or not leaf then return end end server.giveMeWeapon(leaf.id, amount) end wndWeapon = { 'wnd', text = 'Give weapon', width = 250, controls = { { 'lst', id='weaplist', width=230, height=280, columns={ {text='Weapon', attr='name'} }, rows={xml='weapons.xml', attrs={'id', 'name'}}, onitemdoubleclick=function(leaf) addWeapon(leaf, 500) end }, {'br'}, {'txt', id='amount', text='500', width=60}, {'btn', id='add', onclick=addWeapon}, {'btn', id='close', closeswindow=true} } } function giveWeaponCommand(cmd, weapon, amount) weapon = tonumber(weapon) or getWeaponIDFromName(weapon) if not weapon then return end amount = amount and tonumber(amount) or 500 server.giveMeWeapon(math.floor(weapon), amount) end addCommandHandler('give', giveWeaponCommand) addCommandHandler('wp', giveWeaponCommand) Looking for a nice server freeroam or do you have fun?
Miika Posted April 27, 2016 Posted April 27, 2016 Use getElementDimension to check if player is in right dimension. Change the dimension to whatever you need. function addWeapon(leaf, amount) if (getElementDimension(localPlayer) == 2) then if type(leaf) ~= 'table' then leaf = getSelectedGridListLeaf(wndWeapon, 'weaplist') amount = getControlNumber(wndWeapon, 'amount') if not amount or not leaf then return end end server.giveMeWeapon(leaf.id, amount) else -- outputChatBox("You need to be at right dimension to get weapons!") end end function giveWeaponCommand(cmd, weapon, amount) if (getElementDimension(localPlayer) == 2) then weapon = tonumber(weapon) or getWeaponIDFromName(weapon) if not weapon then return end amount = amount and tonumber(amount) or 500 server.giveMeWeapon(math.floor(weapon), amount) else -- outputChatBox("You need to be at right dimension to get weapons!") end end addCommandHandler('give', giveWeaponCommand) addCommandHandler('wp', giveWeaponCommand) Real motorbike backflip / frontflip script: https://forum.mtasa.com/viewtopic.php?f=108&t=98191
Dany Alex Posted April 27, 2016 Author Posted April 27, 2016 Not working ... Looking for a nice server freeroam or do you have fun?
Miika Posted April 28, 2016 Posted April 28, 2016 Post your errors ... Real motorbike backflip / frontflip script: https://forum.mtasa.com/viewtopic.php?f=108&t=98191
Dany Alex Posted April 28, 2016 Author Posted April 28, 2016 not working in any dimension and not working button from f1 weapon Looking for a nice server freeroam or do you have fun?
..:D&G:.. Posted April 28, 2016 Posted April 28, 2016 --------------------------- -- Weapon window --------------------------- function addWeapon(leaf, amount) if type(leaf) ~= 'table' then leaf = getSelectedGridListLeaf(wndWeapon, 'weaplist') amount = getControlNumber(wndWeapon, 'amount') if not amount or not leaf then return end end server.giveMeWeapon(leaf.id, amount) end wndWeapon = { 'wnd', text = 'Give weapon', width = 250, controls = { { 'lst', id='weaplist', width=230, height=280, columns={ {text='Weapon', attr='name'} }, rows={xml='weapons.xml', attrs={'id', 'name'}}, onitemdoubleclick=function(leaf) addWeapon(leaf, 500) end }, {'br'}, {'txt', id='amount', text='500', width=60}, {'btn', id='add', onclick=addWeapon}, {'btn', id='close', closeswindow=true} } } local dimension = 1 local thePlayer = getLocalPlayer() function giveWeaponCommand(cmd, weapon, amount) if (getElementDimension(thePlayer) == dimension) then weapon = tonumber(weapon) or getWeaponIDFromName(weapon) if not weapon then return end amount = amount and tonumber(amount) or 500 server.giveMeWeapon(math.floor(weapon), amount) else outputChatBox("You cannot take a weapon as you are not in the right dimension!", 255, 0, 0) end end addCommandHandler('give', giveWeaponCommand) addCommandHandler('wp', giveWeaponCommand) MTA:Rust Pre-Alpha Build v.0.3: https://forum.mtasa.com/viewtopic.php?f=114&t=97848 2Pac: ''Only God can judge me!''
Dany Alex Posted April 29, 2016 Author Posted April 29, 2016 Tnx bro:* Looking for a nice server freeroam or do you have fun?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now