| Blockland Forums > Modification Help |
| Question(s) |
| << < (2/6) > >> |
| Placid:
Alright. Thanks guys. I've actually got another question; I've been trying to add a weapon to someone's inventory through a script. I've been looking at the addItem script, but I can't seem to figure out where I'm going wrong. I've got it cycling through the variables, but it can't seem to tell whether the slot is empty or not. edit: stuff i forgot to add the code. --- Code: --- %tool=%player.tool[%i]; echo("wat1"); if(%tool==0) { echo("wat2"); %player.tool[%i]=$GunNames[%i]; %player.weaponCount++; messageClient(%c,'',"\c5" @ $GunNames[%g] SPC "has been bought!"); %c.score = %c.score-$GunPrices[%g]; break; } --- End code --- the %i is a for loop for the player's slots. ignore the echo, it's for me trying to find where it's stopping. it's running through this for loop, but it doesn't sense that %tool is empty. |
| Chrono:
I believe -1 is an empty slot, but just to make sure, instead of using ==0, use < 1 |
| Bauklotz:
I would just recommend doing like: if(!isObject(%player.tool[%i])) --- Quote from: otto-san on March 19, 2011, 12:22:57 PM ---Dohoh. They're still arrays, just a very dumb form of them. --- End quote --- They are ways of setting a variable without using eval. $variable[$amount] = "hurr durr"; is a replacement to eval("$variable" @ $amount @ " = \"hurr durr\";"); |
| Placid:
Alright, forget it. Every time I fix one bug, another one comes up. When I fix that one, one that i've already fixed comes up again. Thanks for all your help, learned a lot. |
| Placid:
Double post, bump. I looked back at the script and realized some of my errors. I only have one problem, now: it won't add the tool. It doesn't work with if(!isObject(%player.tool[%i)) or if(%player.tool < 1) it always senses that that is true edit: oh holy stuff i'm a handicap, i started %i at 0 and it's counting 0 as a slot problem still remains, it's counting slot 1 with a hammer as unfilled |
| Navigation |
| Message Index |
| Next page |
| Previous page |