[HELP] I new to using tables. How do I have it so if playermodel = any value in table?
7 replies, posted
Like I said in the title.
If I have a table like this.
[LUA]
Playermodels ={
"models/humans/Group01/Female_01.mdl",
"models/humans/Group01/Female_02.mdl",
"models/humans/Group01/Female_03.mdl",
"models/humans/Group01/Female_04.mdl",
"models/humans/Group01/Female_06.mdl",
"models/humans/Group01/Female_07.mdl",
"models/humans/Group02/Female_01.mdl",
"models/humans/Group02/Female_03.mdl",
"models/humans/Group02/Female_06.mdl"
}
[/LUA]
So how would I have it so like
[LUA]
if ply:GetModel = Playermodels{}?
[/LUA]
* you're not calling GetModel
* you're using the assignment operator rather than the equality operator
* you're using the wrong braces
* random question mark
* you need to loop through the table
I'm not saying thats what I'm doing I'm asking how would I do it ^ that was just a random thing I put in case some people don't understand what I'm talking about and I'm pretty sure those are the right braces
[editline]25th November 2016[/editline]
oh I know what you mean with braces I think are you talking about these? []
[QUOTE=nedredl;51427725]* you're not calling GetModel
* you're using the assignment operator rather than the equality operator
* you're using the wrong braces
* random question mark
* you need to loop through the table[/QUOTE]
Why would he need to loop through the table?
[lua]
ply:SetModel( table.Random( Playermodels ) );
[/lua]
[QUOTE=James xX;51427761]Why would he need to loop through the table?
[lua]
ply:SetModel( table.Random( Playermodels ) );
[/lua][/QUOTE]
I'm not trying to set model to a random model in that table
I'm trying to recieve if the players playermodel is one of the models inside of the table.
[QUOTE=MLPG;51427771]I'm not trying to set model to a random model in that table
I'm trying to recieve if the players playermodel is one of the models inside of the table.[/QUOTE]
Ah yeah sorry, thought you wanted the playermodel to be one of those.
[lua]
table.HasValue( Playermodels, ply:GetModel() );
[/lua]
[QUOTE=James xX;51427783]
[lua]
table.HasValue
[/lua][/QUOTE]
Didn't know about this function, thanks.
thx alot I saw table.HasValue but didn't know it could be used this way I'll try it out
Sorry, you need to Log In to post a reply to this thread.