if(!level.allow_vender)// If vending machines are not allowed then say a message
{
player iPrintlnBold("^2Sorry, fat rats are not allowed on this server");
continue;
}
if(isDefined(dir)) // If the script_origin is placed correctly in the map, then make a bottle pop out
{
self playSound("vender_drop"); // Play the bottle drop sound
if(isDefined(level.venderbottles[level.venderbottlescurrent]))
level.venderbottles[level.venderbottlescurrent] delete(); // If we have gone over the limit for max bottle in the map, delete the oldest one
level.venderbottles[level.venderbottlescurrent] = spawn("script_model",self.origin); // Spawn the bottle
level.venderbottles[level.venderbottlescurrent].angles = dir.angles;// Set the angles of the bottle
level.venderbottles[level.venderbottlescurrent] setModel("com_bottle" + (randomInt(4) + 1)); // Set random bottle model
point = dir.origin;
origin = level.venderbottles[level.venderbottlescurrent].origin + mapsmp_utility::vector_Scale(anglestoup(level.venderbottles[level.venderbottlescurrent].angles),4 + randomFloat(1));
velocity = VectorNormalize(origin - point);// Calculate velocity and direction of the impact
velocity = mapsmp_utility::vector_Scale(velocity,10000 + randomInt(5000));
level.venderbottles[level.venderbottlescurrent] physicsLaunch(point, velocity); // Make the bottle fly!
level.venderbottlescurrent++;
if(level.venderbottlescurrent >= level.venderbottlesmax)
level.venderbottlescurrent = 0;
}
if(isDefined(player.healthwait))// If the player has already used the vending machine then...
{
num = randomInt(100);
if(num < 20)
player iPrintlnBold("^2When was the last time you saw a fat rat?");
else if(num >= 20 && num < 40)
player iPrintlnBold("^1Careful! You'll break it!");// Say one of these random messages
else if(num >= 40 && num < 60)
player iPrintlnBold("^3Oh no! There's none left!");
else if(num >= 60 && num < 80)
player iPrintlnBold("^4You're hungry ain't ya?");
else
player iPrintlnBold("^5Woof");
continue;
}
player.healthwait = true;
if(player.health < player.maxhealth)// If the players health is not at the max
{
player.health = player.maxhealth;// Set the players health to the max
player iPrintlnBold("^2mmm... ^1y^2u^3m^4m^5y^6!");// Say these messages if the player was healed
player iPrintlnBold("^1Health Restored!");
}
else
player iPrintlnBold("^2You already have full health, but ^1y^2u^3m^4m^5y^6! ^2anyway!");// If the player already has full health then say this message
player thread healthwait();
}
}
healthwait()
{
self endon("disconnect"); // Kill the tread if the player disconnects
wait level.vender_wait; // Wait how long level.vender_wait is
self.healthwait = undefined; // Make self.healthwait undefined
}