The whole idea is to have a button on my map so that the player can interact with it and some object would just get removed or deleted from the map. Is there any way to do that? Thanks!
This should work. You can name the variables whatever you want. Just make sure that the targetnames match with Radiant.
Thanks for your solution but it didn't work. I added a trigger_use on the button, edited trigger_use target name as remove_tree (Since I'm removing tree as a object). I replaced target name of the button as remove_tree_button. I've also renamed targetnames of trees to tree.
On the script side I was confused, I renamed object_name as remove_tree_button, on the second line, I replaced object_trigger_name as remove_tree and that was it. Do I have to edit the targetname of the trigger to match the tree's targetname?
//have to make trigger watch function for arrays of triggers function waitForTrigger() { cost = level.defaultTreesCost; if(isDefined(self.zombie_cost) { cost = self.zombie_cost; } self waittill("trigger", who); //to check for cost if(level.treesCostMoney) { if(isPlayer(who) && who.score >= cost) { //totally removes tree from world self delete(); //can use hide(); instead to just hide the tree and show(); to make it visible again } } else { if(isPlayer(who)) { //totally removes tree from world self delete(); //can use hide(); instead to just hide the tree and show(); to make it visible again } } }
Last Edit: January 09, 2017, 02:52:37 pm by buttkicker845
I made a tutorial series that will work for this. In the tutorial it is for shootables, but if you use trigger uses, and add a hintstring and hintcursor, it will work the same.
As far as the first answer, firstly, get rid of all the "level."'s. There is no need for that. But he set up level.object as the tree, and level.object_trigger as the trigger. You need to add to level.object_trigger the targetname value you used on your trigger use and add to level.object the targetname value you added to the tree.
If you watch the tut, you'll see a more dynamic way of doing this, plus it should help you with multiple trees, using an array instead of just getent.
And buttkicker I think you forgot to delete the tree or object, you deleted the trigger
//have to make trigger watch function for arrays of triggers function waitForTrigger() { cost = level.defaultTreesCost; if(isDefined(self.zombie_cost) { cost = self.zombie_cost; } self waittill("trigger", who); //to check for cost if(level.treesCostMoney) { if(isPlayer(who) && who.score >= cost) { //totally removes tree from world self delete(); //can use hide(); instead to just hide the tree and show(); to make it visible again } } else { if(isPlayer(who)) { //totally removes tree from world self delete(); //can use hide(); instead to just hide the tree and show(); to make it visible again } } }
Last Edit: January 09, 2017, 02:59:18 pm by MakeCents
//have to make trigger watch function for arrays of triggers function waitForTrigger() { cost = level.defaultTreesCost; if(isDefined(self.zombie_cost) { cost = self.zombie_cost; } self waittill("trigger", who); //to check for cost models = getEntArray(self.target, "targetname"); if(level.treesCostMoney) { if(isPlayer(who) && who.score >= cost) {
//totally removes tree from world for(i = 0; i < models.size(); i++) { models[i] delete(); } self delete(); //can use hide(); instead to just hide the tree and show(); to make it visible again } } else { if(isPlayer(who)) { //totally removes tree from world for(i = 0; i < models.size(); i++) { models[i] delete(); } self delete(); //can use hide(); instead to just hide the tree and show(); to make it visible again } } }
//have to make trigger watch function for arrays of triggers function waitForTrigger() { cost = level.defaultTreesCost; if(isDefined(self.zombie_cost) { cost = self.zombie_cost; } self waittill("trigger", who); //to check for cost models = getEntArray(self.target, "targetname"); if(level.treesCostMoney) { if(isPlayer(who) && who.score >= cost) {
//totally removes tree from world for(i = 0; i < models.size(); i++) { models[i] delete(); } self delete(); //can use hide(); instead to just hide the tree and show(); to make it visible again } } else { if(isPlayer(who)) { //totally removes tree from world for(i = 0; i < models.size(); i++) { models[i] delete(); } self delete(); //can use hide(); instead to just hide the tree and show(); to make it visible again } } }
Cool, but there is still a slight issue with your code, such as if the player does not have enough points the script will end anyway, and i think a typo on your .size(). And If may make a slight adjustment...
//have to make trigger watch function for arrays of triggers function waitForTrigger() { cost = level.defaultTreesCost; if(isDefined(self.zombie_cost))//edit, missing bracket { cost = self.zombie_cost; } if(!isdefined(cost)) { cost = 0; } while(isdefined(self)) { wait(1);//so they can't spam the trigger self waittill("trigger", who); //to check for cost if(isPlayer(who) && who.score >= cost) { models = getEntArray(self.target, "targetname"); //totally removes tree from world foreach(model in models) { model delete(); } self delete(); //can use hide(); instead to just hide the tree and show(); to make it visible again return; } } }
Last Edit: January 09, 2017, 03:24:03 pm by MakeCents
Thanks for you all for helping, I have got the script in my gsc, however how do I get this to work on Radient side? I renamed trigger_use on the elevator button, added hint_string (Which doesn't display in-game) and added a target on trigger_use to target the trees.
Sorry I am quite new to scripting, majority of gsc scripts are from tutorials etc.