Results 1 to 5 of 5
  1. #1
    Arasonic's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Posts
    569
    Reputation
    11
    Thanks
    115

    Removing points from only the guy purchasing

    Yeeeeeeeeeah.
    When using this code, when someone purchase Ammo, it doesnt take away 200 points, it takes away.. pretty much alot more since its foreach player.
    Is there any fix to make it only take the points away from the guy purchasing? This has really been annoying me >.<

    Code:
    AmmOMatic(pos, angle)
    {
    	block = spawn("script_model", pos );
    	block setModel("com_plasticcase_friendly");
    	block.angles = angle;
    	block Solid();
    	block CloneBrushmodelToScriptmodel( level.airDropCrateCollision );
          self thread AmmoThink(pos);
          wait 0.01;
    }
    
    AmmoThink(pos)
    {
            self endon("disconnect");
            for(;;)
            {
                    foreach(player in level.players)
                    {
                    if(distance(pos, player.origin) <75 && player.cash >= 200)
                    Player SetLowerMessage(1, "Press ^3[{+activate}] ^7to purchase Ammo", undefined, 25);
                    else if(distance(pos, player.origin) <75 && player.cash < 200)
                    Player SetLowerMessage(1, "You do not have enough ^1Cash!", undefined, 50);
                    if(distance(pos, player.origin) <75 && player.cash >= 200 && Player UseButtonPressed())
                    {
                            player thread refillAmmo();
                    }
                    if(distance(pos, player.origin) >75) Player ClearLowerMessage(1);
                    }
                    wait 0.05;
           }
    }
    
    refillAmmo()
    {
    	weaponList = self GetWeaponsListAll();
    
    	foreach ( weaponName in weaponList )
    	{
    		if ( isSubStr( weaponName, "grenade" ) )
    		{
    			if ( self getAmmoCount( weaponName ) >= 1 )
    				continue;
    		} 
    		self.cash -= 200;
    		self giveMaxAmmo( weaponName );
    	}
    }

  2. #2
    Yamato's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    839
    Reputation
    13
    Thanks
    154
    My Mood
    Amazed
    I think that I know what are you trying...., a ammo box for a zombie mod or something similar.

    Try to reduce the price and see if works.

  3. #3
    Arasonic's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Posts
    569
    Reputation
    11
    Thanks
    115
    ...
    You do realize that would still make it cost more than its supposed to?

  4. #4
    Yamato's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    839
    Reputation
    13
    Thanks
    154
    My Mood
    Amazed
    Code:
       else if(distance(pos, player.origin) <75 && player.cash < 200)
    In this line of the code, you putted <200, try to put =200

  5. #5
    Arasonic's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Posts
    569
    Reputation
    11
    Thanks
    115
    Alright, to clear two things:
    That means less than, so it wouldnt matter <-- forget that, I saw now what you meant, but I dont think it'd do anything
    It only takes 200 when nobody is in the match
    Last edited by Arasonic; 12-06-2010 at 06:30 AM.