Bzz335 Posted February 6, 2014 Posted February 6, 2014 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.
Moderators IIYAMA Posted February 6, 2014 Moderators Posted February 6, 2014 First of all: you made a typo: "OnPlayerSpawn" . "onPlayerSpawn"
Bzz335 Posted February 7, 2014 Author Posted February 7, 2014 IIyama,just miss print. Thanks,manawydan.
Bzz335 Posted February 7, 2014 Author Posted February 7, 2014 UP. How I can use ipairs? Give me example,please.
Moderators IIYAMA Posted February 7, 2014 Moderators Posted February 7, 2014 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.
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