Sup, So I am in need of a script for buying ammo, no not a max ammo. One where there are triggers all over the map and each can only be bought once, like the ones in Zombie Seelow and I think TMG Castle.
Sup, So I am in need of a script for buying ammo, no not a max ammo. One where there are triggers all over the map and each can only be bought once, like the ones in Zombie Seelow and I think TMG Castle.
Cheers, With Kind Regards, Andy Whelan
I have not seen these maps or the ammo purchase, are they something like this?
Code Snippet
Plaintext
BuyAmmoOnce(){ //This function can be added to your mapname.gsc //thread BuyAmmoOnce();//add this up in function threads trigs = getentarray("ammotrig","targetname");//change ammotrig to your triggers kvps for(i=0;i<trigs.size;i++){ trigs[i] thread OneTimeAmmo(); } } OneTimeAmmo(){ cost = 500; if(isdefined(self.zombie_cost)) cost = self.zombie_cost;//can set up different prices per trigger self setCursorHint("HINT_NOICON"); self sethintstring("Press &&1 to buy ammo [Cost: " + cost + "]"); while(1){ self waittill("trigger",player); if(player.score+5>=cost){ current_weapon = player getCurrentWeapon(); if(WeaponType( current_weapon ) != "grenade"){ player maps\_zombiemode_score::minus_to_player_score( cost ); player PlayLocalSound("cha_ching"); player giveMaxAmmo(current_weapon); break; } player iprintlnbold("No ammo for grenades"); //delete this after testing }else{ player PlayLocalSound("no_cha_ching"); } wait(.5); } if(isdefined(self.target)){ ammoBox = getent(self.target,"targetname");//the target kvp for trigger and targetname of script_model ammoBox delete(); } self delete(); }
Last Edit: June 10, 2015, 12:22:19 pm by MakeCents
I have not seen these maps or the ammo purchase, are they something like this?
Code Snippet
Plaintext
BuyAmmoOnce(){ //This function can be added to your mapname.gsc //thread BuyAmmoOnce();//add this up in function threads trigs = getentarray("ammotrig","targetname");//change ammotrig to your triggers kvps for(i=0;i<trigs.size;i++){ trigs[i] thread OneTimeAmmo(); } } OneTimeAmmo(){ cost = 500; if(isdefined(self.zombie_cost)) cost = self.zombie_cost;//can set up different prices per trigger self setCursorHint("HINT_NOICON"); self sethintstring("Press &&1 to buy ammo [Cost: " + cost + "]"); while(1){ self waittill("trigger",player); if(player.score+5>=cost){ current_weapon = player getCurrentWeapon(); if(WeaponType( current_weapon ) != "grenade"){ player maps\_zombiemode_score::minus_to_player_score( cost ); player PlayLocalSound("cha_ching"); player giveMaxAmmo(current_weapon); break; } player iprintlnbold("No ammo for grenades"); //delete this after testing }else{ player PlayLocalSound("no_cha_ching"); } wait(.5); } self delete(); }
That does look like it would work, I'll give it a try. Thanks Double Post Merge: June 10, 2015, 11:31:50 amThe script works perfectly, thank you very much. But one more with, how would I make it so the ammo box model disappear?
Last Edit: June 10, 2015, 11:31:50 am by Andy Whelan
That does look like it would work, I'll give it a try. Thanks Double Post Merge: June 10, 2015, 11:31:50 amThe script works perfectly, thank you very much. But one more with, how would I make it so the ammo box model disappear?
If you are using an ammo box script_model to represent the trigger, you can set it as the target of the trigger, using w, so it is auto numbered, which will allow you to make one prefab and just copy it everywhere you want it, and then just add this: