Jump to content

Now me,now tables.


Bzz335

Recommended Posts

Hm,see the IDs of weapon in table?(5,24,25,28,30,33,44)

So,when player will spawn if he's in team "Killers" then

  
local positionsofthespawn={ 
[1]={x,y,z,5,24,25,28,30,33,44}, --Spawn o_O 
} 
local killers = createTeam("Killers",255,204,153) 
addEventHandler("OnPlayerSpawn",root, 
function() 
local playerTeam = getPlayerTeam ( source ) 
local team = getTeamName ( playerTeam )   
    if team=="Killers" then 
    giveWeapon(source,here,myammo) 
    end 
end 
) 

I must get IDs , but how?Please,help.Thanks.

Link to comment
  • Moderators
local positionsofthespawn={ 
[1]={x,y,z,["weapons"]={5,24,25,28,30,33,44}}, --Spawn o_O 
} 
  
  

First of all, tables are working with an index.

Since you didn't save it's spawn location, you don't know what weapons he must use.

I normally give the weapons when I spawn him, not sure if that is a bad habit, except personally I have never had any problems with that.

so:

local spawnTable = positionsofthespawn[math.random(#positionsofthespawn)] 
spawnPlayer(player,spawnTable[1],spawnTable[2],spawnTable[3]) 
  
local weaponTable = spawnTable["weapons"] -- {5,24,25,28,30,33,44} 
for i=1,#weaponTable do 
     giveWeapon(player,weaponTable[i]) 
end 
  

That is how it works.

Link to comment

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