float GetResourceLimit(entity e, int resource_type)
{
+ if(!IS_PLAYER(e))
+ return 0; // no limits on non-players
+
float limit;
switch (resource_type)
{
amount = M_ARGV(2, float);
float max_amount = GetResourceLimit(e, resource_type); // TODO: should allow overriding these limits if cheats are enabled!
float amount_wasted = 0;
- if (amount > max_amount)
+ if (amount > max_amount && max_amount)
{
amount_wasted = amount - max_amount;
amount = max_amount;
void GiveResource(entity receiver, int resource_type, float amount)
{
- if (amount == 0)
+ if (amount <= 0)
{
return;
}
void GiveResourceWithLimit(entity receiver, int resource_type, float amount,
float limit)
{
- if (amount == 0)
+ if (amount <= 0)
{
return;
}
resource_type = M_ARGV(1, int);
amount = M_ARGV(2, float);
limit = M_ARGV(3, float);
- if (amount == 0)
+ if (amount <= 0)
{
return;
}
void TakeResource(entity receiver, int resource_type, float amount)
{
- if (amount == 0)
+ if (amount <= 0)
{
return;
}
}
resource_type = M_ARGV(1, int);
amount = M_ARGV(2, float);
- if (amount == 0)
+ if (amount <= 0)
{
return;
}
void TakeResourceWithLimit(entity receiver, int resource_type, float amount,
float limit)
{
- if (amount == 0)
+ if (amount <= 0)
{
return;
}
resource_type = M_ARGV(1, int);
amount = M_ARGV(2, float);
limit = M_ARGV(3, float);
- if (amount == 0)
+ if (amount <= 0)
{
return;
}