[CODE]chat.AddText(
"You have been randomly given a ",
tostring(weapons[primaryweapon].name),
" a ",
tostring(weapons[secondaryweapon].name),
" and a ",
tostring(weapons[grenade].name),
" by the base cat god.",
"\n\nHappy traiting!")[/CODE]
Gives and error and no text is shown. However the good thing is the rest of the script still works fine and it doesn't crash the server. It just skips this snippet.
FYI 'weapons' is an array, 'secondaryweapon' is a number, and 'name' is a column name.
Example:
[CODE]local weapons = {
{["type"]="primary", ["name"]="weapon_zm_shotgun", ["ammo"]="Buckshot", ["clipsize"]=24}
}[/CODE]
I would like to show you this wonderful function that someone showed me when I had a problem like this.
[url]http://wiki.garrysmod.com/page/Global/unpack[/url]
Basically, a table
[code]
local chat = {
"You have been randomly given a ",
weapons[primaryweapon].name,
" a ",
weapons[secondaryweapon].name,
" and a ",
weapons[grenade].name,
" by the base cat god.",
"\n\nHappy traiting!"
}
print(unpack{chat})
[/code]
would produce a sentence of:
"You have been randomly given a PRIMARYGUN a SECONDARYGUN and a GREANADE by the base cat god.
Happy traiting!"
I'll check it out.
Thanks.
[editline]2nd June 2013[/editline]
Thanks for your help but it wasn't doing what I wanted it to which was to put the message in the players chat.
Working code:
[CODE]ply:ChatPrint("\n\nYou have been randomly given a "..weapons[primaryweapon].name.." a "..weapons[secondaryweapon].name.." and a "..weapons[grenade].name.." by the base cat god.".."\n\nHappy traiting!")[/CODE]
Thanks again!
Sorry, you need to Log In to post a reply to this thread.