Jump to content

Now me,now tables.


Bzz335

Recommended Posts

Posted

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.

Police job script progress: 100%

Courier job script progress::7%

  • Moderators
Posted

First of all:

you made a typo:

"OnPlayerSpawn"

.

"onPlayerSpawn"

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

  • Moderators
Posted
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.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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