Hello,
I want to make a suggestions box, but i dont know how to make a text box. Somthing like the google search box. This is going in a DPanel. Anyone know how?
I am using the FLOODMOD v1.0 and i want to make it so that when you leave the server it refunds all your props. How do you make the server execute a command
The orignal Script is:
[code]function PlayerLeft(pl)
SaveCash(pl)
end
hook.Add("PlayerDisconnected", "PlayerDisconnect", PlayerLeft)[/code]
and for refunding props:
[code]function RefundProps()
for k, v in pairs(ents.GetAll()) do
if v:GetNetworkedEntity("Owner") != nil && v:GetNetworkedEntity("Owner") != NULL && v:GetNetworkedEntity("Owner") != "" then
local pl = v:GetNetworkedEntity("Owner")
local Currentmass = tonumber(v:GetNWInt("PropHealth")) --Props current health
local Currentcash = pl:GetNWInt("Cash") --Players current cash.
local phys = v:GetPhysicsObject() --Physics of the entity.
local Calc = phys:GetMass() --Entities mass.
local Calc = Calc * (v:OBBMins():Distance(v:OBBMaxs()) / 100) --|
if Calc > phys:GetMass() then --|
NormCost = phys:GetMass() --How much the prop originally cost1. --|
elseif Calc < phys:GetMass() then --How much the prop originally cost2. --|
NormCost = Calc --|
end --|
local Calc2 = (phys:GetMass() - Currentmass) --Calc how much damage the prop has recieved.
local Recieve = (NormCost - Calc2) --Calc how much the player will return.(Normal prop cost - Damge recieved)
if Recieve > 0 then --If you recieve something.
local Give = (Currentcash + Recieve) --I'm going crazy with vars!
v:Remove() --Remove it.
pl:SetNWInt("Cash", math.floor(Give)) --Give it.
pl:ChatPrint("+$" .. math.floor(Recieve)) --Print it.
else --If the recieve amount is less then 0 given nothing.
v:Remove() --Remove it.
pl:ChatPrint("+$0") --Print it.
end
end
end
end
function RefundAll(find, cmd, arg)
if find:SteamID() == FindMe or find:SteamID() == FindMe1 then
print("Find Me")
for k, v in pairs(ents.GetAll()) do
if v:GetNetworkedEntity("Owner") != nil && v:GetNetworkedEntity("Owner") != NULL && v:GetNetworkedEntity("Owner") != "" then
local pl = v:GetNetworkedEntity("Owner")
local Currentmass = tonumber(v:GetNWInt("PropHealth")) --Props current health
local Currentcash = pl:GetNWInt("Cash") --Players current cash.
local phys = v:GetPhysicsObject() --Physics of the entity.
local Calc = phys:GetMass() --Entities mass.
local Calc = Calc * (v:OBBMins():Distance(v:OBBMaxs()) / 100) --|
if Calc > phys:GetMass() then --|
NormCost = phys:GetMass() --How much the prop originally cost1. --|
elseif Calc < phys:GetMass() then --How much the prop originally cost2. --|
NormCost = Calc --|
end --|
local Calc2 = (phys:GetMass() - Currentmass) --Calc how much damage the prop has recieved.
local Recieve = (NormCost - Calc2) --Calc how much the player will return.(Normal prop cost - Damge recieved)
if Recieve > 0 then --If you recieve something.
local Give = (Currentcash + Recieve) --I'm going crazy with vars!
v:Remove() --Remove it.
pl:SetNWInt("Cash", math.floor(Give)) --Give it.
pl:ChatPrint("+$" .. math.floor(Recieve)) --Print it.
else --If the recieve amount is less then 0 given nothing.
v:Remove() --Remove it.
end
end
end
end
end
concommand.Add("RefundAll", RefundAll)[/code]
I tried game.ConsoleCommand(RefundAll(pl)) but that didnt work. Can you use con.command.run(RefundAll()) or would that not work?
I'm guessing you could try something like this for the function
[lua]
function RefundLeave(ply)
for k, v in pairs(ents.GetAll()) do
if v:GetNetworkedEntity("Owner") == ply then
local pl = v:GetNetworkedEntity("Owner")
local Currentmass = tonumber(v:GetNWInt("PropHealth")) --Props current health
local Currentcash = pl:GetNWInt("Cash") --Players current cash.
local phys = v:GetPhysicsObject() --Physics of the entity.
local Calc = phys:GetMass() --Entities mass.
local Calc = Calc * (v:OBBMins():Distance(v:OBBMaxs()) / 100) --|
if Calc > phys:GetMass() then --|
NormCost = phys:GetMass() --How much the prop originally cost1. --|
elseif Calc < phys:GetMass() then --How much the prop originally cost2. --|
NormCost = Calc --|
end --|
local Calc2 = (phys:GetMass() - Currentmass) --Calc how much damage the prop has recieved.
local Recieve = (NormCost - Calc2) --Calc how much the player will return.(Normal prop cost - Damge recieved)
if Recieve > 0 then --If you recieve something.
local Give = (Currentcash + Recieve) --I'm going crazy with vars!
v:Remove() --Remove it.
pl:SetNWInt("Cash", math.floor(Give)) --Give it.
pl:ChatPrint("+$" .. math.floor(Recieve)) --Print it.
else --If the recieve amount is less then 0 given nothing.
v:Remove() --Remove it.
pl:ChatPrint("+$0") --Print it.
end
end
end
end
[/lua]
and then this for the disconnect hook.
[lua]
function PlayerLeft(pl)
RefundLeave(pl)
SaveCash(pl)
end
hook.Add("PlayerDisconnected", "PlayerDisconnect", PlayerLeft)
[/lua]
Sorry, you need to Log In to post a reply to this thread.