Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 56 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 4
Category: CoD4 Scripting
Scripting and coding with Call of Duty 4.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername, novemberdobby
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: Buy weapons from the wall like nazi zombies.
Efraxskills
General Member
Since: Nov 10, 2009
Posts: 41
Last: Nov 22, 2012
[view latest posts]
Level 2
Category: CoD4 Scripting
Posted: Friday, Jun. 8, 2012 07:34 pm
hi everyone.

im trying to make buyable weapons like nazi zombies, but my problem it's: how to take the player's current weapon in exchange for the new weapon? and once the player had lost the new weapon, how the player can buy again the weapon?
here's my first attemp:

Code:

main()
{
thread buy_winchester1200();
}
buy_winchester1200()

{
  trigger = getEnt( "purchase_winchester1200_trigger", "targetname" );
  cost = 300;
  
     while(1)
     {
         trigger waittill( "trigger", player );
         if( player.upgradepoints < cost )
         {
             player iPrintlnBold( "^2You don't have ^1"+cost+" ^2points" );
             continue;
         }
         if( player.upgradepoints >= cost )
         player.upgradepoints = player.upgradepoints - cost;
         player GiveWeapon("winchester1200_mp");
	 player SwitchToWeapon("winchester1200_mp");
         player SetWeaponAmmoStock( "winchester1200_mp", 28 );        
         break;
     }
}


thanks for the time guys, i hope you can help me [wave]
Share |
FzBr.d4rk
General Member
Since: Jan 23, 2011
Posts: 86
Last: Jun 7, 2016
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Saturday, Jun. 9, 2012 05:15 am
Code:

main()
{
    thread onPlayerConnect();
}
onPlayerConnect()
{
	for(;;)
	{
		level waittill("connecting", player);

		player thread onPlayerSpawned();
	}
}

onPlayerSpawned()
{
	self endon("disconnect");

	for(;;)
	{
		self waittill("spawned_player");


		self thread buy_winchester1200();
	}
}


buy_winchester1200()

{
  trigger = getEnt( "purchase_winchester1200_trigger", "targetname" );
  cost = 300;
  for( ;; )
     while(1)
     {
         trigger waittill( "trigger", player );
         if( player.upgradepoints < cost )
         {
             player iPrintlnBold( "^2You don't have ^1"+cost+" ^2points" );
             continue;
         }
         if( player.upgradepoints >= cost )
        player.upgradepoints = player.upgradepoints - cost;
         oldweapon = self GetCurrentWeapon();
         self dropItem (oldweapon);
         player GiveWeapon("winchester1200_mp");
	 player SwitchToWeapon("winchester1200_mp");
         player SetWeaponAmmoStock( "winchester1200_mp", 28 );        
         break;
     }
}

I hope it work!![thumbs_up]
Share |
Efraxskills
General Member
Since: Nov 10, 2009
Posts: 41
Last: Nov 22, 2012
[view latest posts]
Level 2
Category: CoD4 Scripting
Posted: Saturday, Jun. 9, 2012 05:47 pm
thanks DarkShark, works perfectly[thumbs_up].

now i have to solve the problem about buying the weapon again, cuz only i can buy it once. again, thanks for u help.
[wave]
Share |
Spik3d
General Member
Since: Jan 30, 2008
Posts: 130
Last: Feb 19, 2015
[view latest posts]
Level 4
Category: CoD4 Scripting
Posted: Saturday, Jun. 9, 2012 06:36 pm
DarkShark, that's bad code, you're making it way more complex than it has to be. All you should need for the one trigger is a single endless loop.

You were closer with your first attempt, but why are you breaking at the end of the loop? Do you know what that does?
Share |
Efraxskills
General Member
Since: Nov 10, 2009
Posts: 41
Last: Nov 22, 2012
[view latest posts]
Level 2
Category: CoD4 Scripting
Posted: Saturday, Jun. 9, 2012 07:35 pm
Spik3d writes...
Quote:
You were closer with your first attempt, but why are you breaking at the end of the loop? Do you know what that does?


yes, when i erase that part of code, i solve the problem. thanks a lot, both of you[thumbs_up].
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 4 : CoD4 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»