Quote:
Originally Posted by Cubical
Could someone tell me which one of these is right, or if both of them are wrong?
NPC Code:
("clientr.type." @ itemrealname)[2] + quanity;
NPC Code:
("clientr.type." @ itemrealname[2]) + quanity;
|
First of all, I wouldn't use
type because it may be reserved. I'd use something like
itemtype instead.
If the player you want to manipulate has focus you would do something like this:
PHP Code:
clientr.(@ itemtype).(@ itemrealname)[2] += quantity;
// assuming your setup is something like
// clientr.grenade.flashbang = {some_var, some_var, QUANTITY, etc}
// or clientr.gun.famas = {some_var, some_var, QUANTITY, etc}
//Remember:
temp.foo += 2;
//is a shorter way of doing
temp.foo = temp.foo + 2;
You should also be very careful when dealing with important things like items that all of your data is verified on the serverside. How are you getting "quantity"? Trust nothing from the client because it can always be changed if the person knows what they're doing.
edit:
Ideally it would probably be better to have the itemtype in the array, and have clientr.items.itemname = {itemtype, etc, etc};
That way, you can easily get all of the players items doing something like temp.items = clientr.items.getDynamicVarNames();
I have to go to class, hope this helped.