Axel Posted February 7, 2012 Posted February 7, 2012 Is there a way to cancel the removing of weapons when u use spawnPlayer ? Or is there a way u can keep the weapons when u respawn? Thanks for help
Sparrow Posted February 7, 2012 Posted February 7, 2012 (edited) nvm Edited February 7, 2012 by Guest
Kenix Posted February 7, 2012 Posted February 7, 2012 1. spawnPlayer takeAllWeapons 2. local tWeap = { } local tTimer = { } function table.empty( t ) if type( t ) ~= "table" then return false end return not next( t ) end local function giveWeaponsFromTable( source ) if not table.empty( tWeap[ source ] ) then if isElement( source ) then for _,v in pairs( tWeap[ source ] ) do giveWeapon( source,v[1],v[2],false ) end return true end return false end return false end local function getAllWeapons( source,ammo ) if isElement( source ) then local Table = { } for i = 0,12 do local weap = getPedWeapon ( source, i ) if not ammo then table.insert( Table,weap ) else local ammos = getPedTotalAmmo( source,i ) if ammos > 0 then table.insert( Table, { weap, ammos } ) end end end return Table end return false end addEventHandler( "onPlayerWasted",root, function( ) tWeap[ source ] = getAllWeapons( source,true ) end ) addEventHandler( "onPlayerSpawn",root, function( ) tTimer[ source ] = setTimer( giveWeaponsFromTable,300,1,source ) tWeap[ source ] = nil end ) addEventHandler( "onPlayerQuit",root, function( ) tWeap[ source ] = nil tTimer[ source ] = nil end ) Updated.
Axel Posted February 7, 2012 Author Posted February 7, 2012 Well.. that didn't work in mta paradise respawn..
Kenix Posted February 7, 2012 Posted February 7, 2012 Try test it in play gm. Not forget use /debugscript 3
Kenix Posted February 7, 2012 Posted February 7, 2012 Yeah i find little problem. Server local tWeap = { } local tTimer = { } function table.empty( t ) if type( t ) ~= "table" then return false end return not next( t ) end local function giveWeaponsFromTable( source ) if not table.empty( tWeap[ source ] ) then if isElement( source ) then for _,v in pairs( tWeap[ source ] ) do giveWeapon( source,v[1],v[2],false ) end tWeap[ source ] = nil return true end return false end return false end local function getAllWeapons( source,ammo ) if isElement( source ) then local Table = { } for i = 0,12 do local weap = getPedWeapon ( source, i ) if not ammo then table.insert( Table,weap ) else local ammos = getPedTotalAmmo( source,i ) if ammos then table.insert( Table, { weap, ammos } ) end end end return Table end return false end addEventHandler( "onPlayerWasted",root, function( ) tWeap[ source ] = getAllWeapons( source,true ) end ) addEventHandler( "onPlayerSpawn",root, function( ) tTimer[ source ] = setTimer( giveWeaponsFromTable,300,1,source ) end ) addEventHandler( "onPlayerQuit",root, function( ) tWeap[ source ] = nil tTimer[ source ] = nil end ) Tested.
Axel Posted February 7, 2012 Author Posted February 7, 2012 It worked just fine.Thank you very much, it is very usefull!
Axel Posted February 7, 2012 Author Posted February 7, 2012 Well i found a problem, when someone changes his skin, he looses all his weapons
Kenix Posted February 7, 2012 Posted February 7, 2012 Well i found a problem, when someone changes his skin, he looses all his weapons I test it in runcode and in freeroam and i not lost weapons
Castillo Posted February 7, 2012 Posted February 7, 2012 When you change your skin via Admin panel, you lose your weapons.
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