Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AddCSLuaFile("cl_init.lua");
- AddCSLuaFile("shared.lua");
- include("shared.lua");
- function ENT:Initialize()
- self:SetModel("models/props_junk/wood_crate002a.mdl");
- self:PhysicsInit(SOLID_VPHYSICS);
- self:SetMoveType(MOVETYPE_VPHYSICS);
- self:SetSolid(SOLID_VPHYSICS);
- self:SetHealth(FS_Box_Health);
- self:SetDTInt(1, 0);
- self:SetDTInt(2, 0);
- self:SetDTInt(3, 0);
- self:SetDTInt(4, 0);
- self:SetDTInt(5, 0);
- self:SetDTInt(6, 0);
- self:SetDTInt(7, 0);
- self:SetDTInt(8, 0);
- self:SetDTString(1, "none");
- self:GetPhysicsObject():SetMass(105);
- self:SetPos(self:GetPos()+self:GetUp()*32);
- end;
- function ENT:SpawnFunction(ply, trace)
- local ent = ents.Create("fs_box");
- ent:SetPos(trace.HitPos + trace.HitNormal * 8);
- ent:Spawn();
- ent:Activate();
- return ent;
- end;
- function ENT:OnTakeDamage(dmginfo)
- if FS_Box_CanBeDestroyed then
- self:SetHealth(self:Health()-dmginfo:GetDamage());
- local effectData = EffectData();
- effectData:SetStart(dmginfo:GetDamagePosition());
- effectData:SetOrigin(dmginfo:GetDamagePosition());
- effectData:SetScale(8);
- util.Effect("BloodImpact", effectData, true, true);
- if (self:Health()<=0) then
- for i=1, math.Round(self:GetDTInt(1)*FS_Box_ContentScaleOnDestroyed) do
- local content = ents.Create("fs_melon")
- content:SetAngles(Angle(0,math.random(0, 360),0));
- content:SetPos(self:GetPos()+(self:GetUp()*math.random(0, 25))+(self:GetRight()*math.random(-40, 40))+(self:GetForward()*math.random(-20, 20)));
- content:Spawn();
- content:GetPhysicsObject():SetVelocity(Vector(math.random(-8, 8), math.random(-8, 8), math.random(0, 32)));
- end;
- for i=1, math.Round(self:GetDTInt(2)*FS_Box_ContentScaleOnDestroyed) do
- local content = ents.Create("fs_cabbage")
- content:SetAngles(Angle(0,math.random(0, 360),0));
- content:SetPos(self:GetPos()+(self:GetUp()*math.random(0, 25))+(self:GetRight()*math.random(-40, 40))+(self:GetForward()*math.random(-20, 20)));
- content:Spawn();
- content:GetPhysicsObject():SetVelocity(Vector(math.random(-8, 8), math.random(-8, 8), math.random(0, 32)));
- end;
- for i=1, math.Round(self:GetDTInt(3)*FS_Box_ContentScaleOnDestroyed) do
- local content = ents.Create("fs_watermelon")
- content:SetAngles(Angle(0,math.random(0, 360),0));
- content:SetPos(self:GetPos()+(self:GetUp()*math.random(0, 25))+(self:GetRight()*math.random(-40, 40))+(self:GetForward()*math.random(-20, 20)));
- content:Spawn();
- content:GetPhysicsObject():SetVelocity(Vector(math.random(-8, 8), math.random(-8, 8), math.random(0, 32)));
- end;
- for i=1, math.Round(self:GetDTInt(4)*FS_Box_ContentScaleOnDestroyed) do
- local content = ents.Create("fs_tomato")
- content:SetAngles(Angle(0,math.random(0, 360),0));
- content:SetPos(self:GetPos()+(self:GetUp()*math.random(0, 25))+(self:GetRight()*math.random(-40, 40))+(self:GetForward()*math.random(-20, 20)));
- content:Spawn();
- content:GetPhysicsObject():SetVelocity(Vector(math.random(-8, 8), math.random(-8, 8), math.random(0, 32)));
- end;
- for i=1, math.Round(self:GetDTInt(5)*FS_Box_ContentScaleOnDestroyed) do
- local content = ents.Create("fs_orange")
- content:SetAngles(Angle(0,math.random(0, 360),0));
- content:SetPos(self:GetPos()+(self:GetUp()*math.random(0, 25))+(self:GetRight()*math.random(-40, 40))+(self:GetForward()*math.random(-20, 20)));
- content:Spawn();
- content:GetPhysicsObject():SetVelocity(Vector(math.random(-8, 8), math.random(-8, 8), math.random(0, 32)));
- end;
- for i=1, math.Round(self:GetDTInt(6)*FS_Box_ContentScaleOnDestroyed) do
- local content = ents.Create("fs_apple")
- content:SetAngles(Angle(0,math.random(0, 360),0));
- content:SetPos(self:GetPos()+(self:GetUp()*math.random(0, 25))+(self:GetRight()*math.random(-40, 40))+(self:GetForward()*math.random(-20, 20)));
- content:Spawn();
- content:GetPhysicsObject():SetVelocity(Vector(math.random(-8, 8), math.random(-8, 8), math.random(0, 32)));
- end;
- for i=1, math.Round(self:GetDTInt(7)*FS_Box_ContentScaleOnDestroyed) do
- local content = ents.Create("fs_lemon")
- content:SetAngles(Angle(0,math.random(0, 360),0));
- content:SetPos(self:GetPos()+(self:GetUp()*math.random(0, 25))+(self:GetRight()*math.random(-40, 40))+(self:GetForward()*math.random(-20, 20)));
- content:Spawn();
- content:GetPhysicsObject():SetVelocity(Vector(math.random(-8, 8), math.random(-8, 8), math.random(0, 32)));
- end;
- for i=1, math.Round(self:GetDTInt(8)*FS_Box_ContentScaleOnDestroyed) do
- local content = ents.Create("fs_potato")
- content:SetAngles(Angle(0,math.random(0, 360),0));
- content:SetPos(self:GetPos()+(self:GetUp()*math.random(0, 25))+(self:GetRight()*math.random(-40, 40))+(self:GetForward()*math.random(-20, 20)));
- content:Spawn();
- content:GetPhysicsObject():SetVelocity(Vector(math.random(-8, 8), math.random(-8, 8), math.random(0, 32)));
- end;
- self:Remove();
- end;
- end;
- end;
- function ENT:Use(activator, caller)
- if (!self.nextUse or CurTime() >= self.nextUse) then
- if (activator:GetEyeTrace().Entity == self) and (activator:GetPos():Distance(self:GetPos())<FS_Use_Distance) then
- if (self:GetDTString(1) == activator:Nick()) then
- for k, v in pairs(ents.FindInSphere(self:GetPos(), 128)) do
- if (v:GetClass() == "fs_salesman") then
- if (self:GetDTInt(1)>0) or (self:GetDTInt(2)>0) or (self:GetDTInt(3)>0) or (self:GetDTInt(4)>0) or (self:GetDTInt(5)>0) or
- (self:GetDTInt(6)>0) or (self:GetDTInt(7)>0) or (self:GetDTInt(8)>0) then
- self.owner:SendLua("local tab={Color(255,255,255),[[Hello ]],Color(0,75,255),[["..self.owner:Nick().."]],Color(255,255,255),[[!]]}chat.AddText(unpack(tab))");
- v:EmitSound("vo/npc/male01/nice.wav", 70, 100);
- local totalAmount = 0;
- if (self:GetDTInt(1)>0) then
- local money = math.Round(self:GetDTInt(1)*FS_Melon_Price);
- totalAmount = totalAmount + money;
- if (GAMEMODE.Version == "2.4.3") then
- self.owner:AddMoney(money);
- else
- self.owner:addMoney(money);
- end;
- if (self:GetDTInt(1) > 1) then
- self.owner:SendLua("local tab={Color(255,255,255),[[You got ]],Color(25,255,25),[["..money.."$]],Color(255,255,255),[[ for selling ]],Color(213,213,25),[["..self:GetDTInt(1).." Melons]],Color(255,255,255),[[.]]}chat.AddText(unpack(tab))");
- elseif (self:GetDTInt(1) == 1) then
- self.owner:SendLua("local tab={Color(255,255,255),[[You got ]],Color(25,255,25),[["..money.."$]],Color(255,255,255),[[ for selling ]],Color(213,213,25),[["..self:GetDTInt(1).." Melon]],Color(255,255,255),[[.]]}chat.AddText(unpack(tab))");
- end;
- self:SetDTInt(1, 0);
- end;
- if (self:GetDTInt(2)>0) then
- local money = math.Round(self:GetDTInt(2)*FS_Cabbage_Price);
- totalAmount = totalAmount + money;
- if (GAMEMODE.Version == "2.4.3") then
- self.owner:AddMoney(money);
- else
- self.owner:addMoney(money);
- end;
- if (self:GetDTInt(2) > 1) then
- self.owner:SendLua("local tab={Color(255,255,255),[[You got ]],Color(25,255,25),[["..money.."$]],Color(255,255,255),[[ for selling ]],Color(177,222,160),[["..self:GetDTInt(2).." Cabbages]],Color(255,255,255),[[.]]}chat.AddText(unpack(tab))");
- elseif (self:GetDTInt(2) == 1) then
- self.owner:SendLua("local tab={Color(255,255,255),[[You got ]],Color(25,255,25),[["..money.."$]],Color(255,255,255),[[ for selling ]],Color(177,222,160),[["..self:GetDTInt(2).." Cabbage]],Color(255,255,255),[[.]]}chat.AddText(unpack(tab))");
- end;
- self:SetDTInt(2, 0);
- end;
- if (self:GetDTInt(3)>0) then
- local money = math.Round(self:GetDTInt(3)*FS_Watermelon_Price);
- totalAmount = totalAmount + money;
- if (GAMEMODE.Version == "2.4.3") then
- self.owner:AddMoney(money);
- else
- self.owner:addMoney(money);
- end;
- if (self:GetDTInt(3) > 1) then
- self.owner:SendLua("local tab={Color(255,255,255),[[You got ]],Color(25,255,25),[["..money.."$]],Color(255,255,255),[[ for selling ]],Color(119,214,25),[["..self:GetDTInt(3).." Watermelons]],Color(255,255,255),[[.]]}chat.AddText(unpack(tab))");
- elseif (self:GetDTInt(3) == 1) then
- self.owner:SendLua("local tab={Color(255,255,255),[[You got ]],Color(25,255,25),[["..money.."$]],Color(255,255,255),[[ for selling ]],Color(119,214,25),[["..self:GetDTInt(3).." Watermelon]],Color(255,255,255),[[.]]}chat.AddText(unpack(tab))");
- end;
- self:SetDTInt(3, 0);
- end;
- if (self:GetDTInt(4)>0) then
- local money = math.Round(self:GetDTInt(4)*FS_Tomato_Price);
- totalAmount = totalAmount + money;
- if (GAMEMODE.Version == "2.4.3") then
- self.owner:AddMoney(money);
- else
- self.owner:addMoney(money);
- end;
- if (self:GetDTInt(4) > 1) then
- self.owner:SendLua("local tab={Color(255,255,255),[[You got ]],Color(25,255,25),[["..money.."$]],Color(255,255,255),[[ for selling ]],Color(175,0,0),[["..self:GetDTInt(4).." Tomatoes]],Color(255,255,255),[[.]]}chat.AddText(unpack(tab))");
- elseif (self:GetDTInt(4) == 1) then
- self.owner:SendLua("local tab={Color(255,255,255),[[You got ]],Color(25,255,25),[["..money.."$]],Color(255,255,255),[[ for selling ]],Color(175,0,0),[["..self:GetDTInt(4).." Tomato]],Color(255,255,255),[[.]]}chat.AddText(unpack(tab))");
- end;
- self:SetDTInt(4, 0);
- end;
- if (self:GetDTInt(5)>0) then
- local money = math.Round(self:GetDTInt(5)*FS_Orange_Price);
- totalAmount = totalAmount + money;
- if (GAMEMODE.Version == "2.4.3") then
- self.owner:AddMoney(money);
- else
- self.owner:addMoney(money);
- end;
- if (self:GetDTInt(5) > 1) then
- self.owner:SendLua("local tab={Color(255,255,255),[[You got ]],Color(25,255,25),[["..money.."$]],Color(255,255,255),[[ for selling ]],Color(246,165,42),[["..self:GetDTInt(5).." Oranges]],Color(255,255,255),[[.]]}chat.AddText(unpack(tab))");
- elseif (self:GetDTInt(5) == 1) then
- self.owner:SendLua("local tab={Color(255,255,255),[[You got ]],Color(25,255,25),[["..money.."$]],Color(255,255,255),[[ for selling ]],Color(246,165,42),[["..self:GetDTInt(5).." Orange]],Color(255,255,255),[[.]]}chat.AddText(unpack(tab))");
- end;
- self:SetDTInt(5, 0);
- end;
- if (self:GetDTInt(6)>0) then
- local money = math.Round(self:GetDTInt(6)*FS_Apple_Price);
- totalAmount = totalAmount + money;
- if (GAMEMODE.Version == "2.4.3") then
- self.owner:AddMoney(money);
- else
- self.owner:addMoney(money);
- end;
- if (self:GetDTInt(6) > 1) then
- self.owner:SendLua("local tab={Color(255,255,255),[[You got ]],Color(25,255,25),[["..money.."$]],Color(255,255,255),[[ for selling ]],Color(138,239,95),[["..self:GetDTInt(6).." Apples]],Color(255,255,255),[[.]]}chat.AddText(unpack(tab))");
- elseif (self:GetDTInt(6) == 1) then
- self.owner:SendLua("local tab={Color(255,255,255),[[You got ]],Color(25,255,25),[["..money.."$]],Color(255,255,255),[[ for selling ]],Color(138,239,95),[["..self:GetDTInt(6).." Apple]],Color(255,255,255),[[.]]}chat.AddText(unpack(tab))");
- end;
- self:SetDTInt(6, 0);
- end;
- if (self:GetDTInt(7)>0) then
- local money = math.Round(self:GetDTInt(7)*FS_Lemon_Price);
- totalAmount = totalAmount + money;
- if (GAMEMODE.Version == "2.4.3") then
- self.owner:AddMoney(money);
- else
- self.owner:addMoney(money);
- end;
- if (self:GetDTInt(7) > 1) then
- self.owner:SendLua("local tab={Color(255,255,255),[[You got ]],Color(25,255,25),[["..money.."$]],Color(255,255,255),[[ for selling ]],Color(225,255,0),[["..self:GetDTInt(7).." Lemons]],Color(255,255,255),[[.]]}chat.AddText(unpack(tab))");
- elseif (self:GetDTInt(7) == 1) then
- self.owner:SendLua("local tab={Color(255,255,255),[[You got ]],Color(25,255,25),[["..money.."$]],Color(255,255,255),[[ for selling ]],Color(225,255,0),[["..self:GetDTInt(7).." Lemon]],Color(255,255,255),[[.]]}chat.AddText(unpack(tab))");
- end;
- self:SetDTInt(7, 0);
- end;
- if (self:GetDTInt(8)>0) then
- local money = math.Round(self:GetDTInt(8)*FS_Potato_Price);
- totalAmount = totalAmount + money;
- if (GAMEMODE.Version == "2.4.3") then
- self.owner:AddMoney(money);
- else
- self.owner:addMoney(money);
- end;
- if (self:GetDTInt(8) > 1) then
- self.owner:SendLua("local tab={Color(255,255,255),[[You got ]],Color(25,255,25),[["..money.."$]],Color(255,255,255),[[ for selling ]],Color(125,82,17),[["..self:GetDTInt(8).." Potatoes]],Color(255,255,255),[[.]]}chat.AddText(unpack(tab))");
- elseif (self:GetDTInt(8) == 1) then
- self.owner:SendLua("local tab={Color(255,255,255),[[You got ]],Color(25,255,25),[["..money.."$]],Color(255,255,255),[[ for selling ]],Color(125,82,17),[["..self:GetDTInt(8).." Potato]],Color(255,255,255),[[.]]}chat.AddText(unpack(tab))");
- end;
- self:SetDTInt(8, 0);
- end;
- self.owner:SendLua("local tab={Color(255,255,255),[[You got ]],Color(25,255,25),[["..totalAmount.."$ ]],Color(255,255,255),[[total.]]}chat.AddText(unpack(tab))");
- self:EmitSound("vehicles/atv_ammo_open.wav");
- else
- v:EmitSound("vo/npc/male01/sorry0"..math.random(1, 3)..".wav", 70, 100);
- self.owner:SendLua("local tab={Color(255,255,255),[[You don't have anything to sell!]]}chat.AddText(unpack(tab))");
- end;
- end;
- end;
- self.nextUse = CurTime() + 0.5;
- end;
- if (self:GetDTString(1) == "none") then
- self:EmitSound("vehicles/atv_ammo_close.wav");
- self:SetDTString(1, activator:Nick());
- self.owner = activator;
- end;
- end;
- end;
- end;
- function ENT:PhysicsCollide(data, phys)
- local curTime = CurTime();
- if (data.DeltaTime > 0.1) then
- timer.Simple(0, function()
- if ((data.HitEntity:GetClass() == "fs_melon") and self:GetDTInt(1)<FS_Box_MaxHold_Melon) then
- self:SetDTInt(1, self:GetDTInt(1)+1);
- self:EmitSound("physics/wood/wood_box_impact_soft"..math.random(1, 3)..".wav");
- data.HitEntity:VisualEffect();
- end;
- if ((data.HitEntity:GetClass() == "fs_cabbage") and self:GetDTInt(2)<FS_Box_MaxHold_Cabbage) then
- self:SetDTInt(2, self:GetDTInt(2)+1);
- self:EmitSound("physics/wood/wood_box_impact_soft"..math.random(1, 3)..".wav");
- data.HitEntity:VisualEffect();
- end;
- if ((data.HitEntity:GetClass() == "fs_watermelon") and self:GetDTInt(3)<FS_Box_MaxHold_Watermelon) then
- self:SetDTInt(3, self:GetDTInt(3)+1);
- self:EmitSound("physics/wood/wood_box_impact_soft"..math.random(1, 3)..".wav");
- data.HitEntity:VisualEffect();
- end;
- if ((data.HitEntity:GetClass() == "fs_tomato") and self:GetDTInt(4)<FS_Box_MaxHold_Tomato) then
- self:SetDTInt(4, self:GetDTInt(4)+1);
- self:EmitSound("physics/wood/wood_box_impact_soft"..math.random(1, 3)..".wav");
- data.HitEntity:VisualEffect();
- end;
- if ((data.HitEntity:GetClass() == "fs_orange") and self:GetDTInt(5)<FS_Box_MaxHold_Orange) then
- self:SetDTInt(5, self:GetDTInt(5)+1);
- self:EmitSound("physics/wood/wood_box_impact_soft"..math.random(1, 3)..".wav");
- data.HitEntity:VisualEffect();
- end;
- if ((data.HitEntity:GetClass() == "fs_apple") and self:GetDTInt(6)<FS_Box_MaxHold_Apple) then
- self:SetDTInt(6, self:GetDTInt(6)+1);
- self:EmitSound("physics/wood/wood_box_impact_soft"..math.random(1, 3)..".wav");
- data.HitEntity:VisualEffect();
- end;
- if ((data.HitEntity:GetClass() == "fs_lemon") and self:GetDTInt(7)<FS_Box_MaxHold_Lemon) then
- self:SetDTInt(7, self:GetDTInt(7)+1);
- self:EmitSound("physics/wood/wood_box_impact_soft"..math.random(1, 3)..".wav");
- data.HitEntity:VisualEffect();
- end;
- if ((data.HitEntity:GetClass() == "fs_potato") and self:GetDTInt(8)<FS_Box_MaxHold_Potato) then
- self:SetDTInt(8, self:GetDTInt(8)+1);
- self:EmitSound("physics/wood/wood_box_impact_soft"..math.random(1, 3)..".wav");
- data.HitEntity:VisualEffect();
- end;
- end)
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement