I want to make sure that when the player reaches the point, he was given money.
But this does not happen, even the error does not write to the console. help me please
Code
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include('shared.lua')
function ENT:Initialize()
self:SetModel( "models/props_junk/cardboard_box003a.mdl" )
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
self:SetUseType( SIMPLE_USE )
local phys = self:GetPhysicsObject()
if (phys:IsValid()) then
phys:Wake()
end
end
local pizdabably = -500
local moneyforpochta = math.random(2500,5000)
function ENT:Use( ply, caller )
if(ply:GetNWBool("pochta") == false) then
ply:ChatPrint('Вы взяли посылку, а теперь доставьте ее к получателю')
ply:ChatPrint('Идите спокойно, что бы не уронить!')
ply:SetNWBool("pochta",true)
ply:ConCommand("dostavka")
hook.Add( "KeyPress", "keypress_use_hi", function( ply, key ) if ( key == IN_JUMP or key == IN_DUCK or key == IN_SPEED ) and ply:GetNWBool("pochta") == true then ply:SetNWBool("pochta",false) ply:addMoney(pizdabably) ply:ChatPrint('Ну бл?ть опять ты ее уронил? В который раз уже? \nВы заплатили за разбитую посылку 500$') end end)
end
if ply:GetPos():Distance(Vector(-536, -4452, -196)) < 150 and ply:GetNWBool("pochta") == true then
ply:ChatPrint('Вы доставили посылку и получили '..moneyforpochta)
ply:addMoney(moneyforpochta)
end
end
function ENT:Think( ply,caller )
end
function ENT:OnRemove()
self:Remove()
end
Player:AddMoney(number amount)
you wrote ply:addMoney not ply:AddMoney
https://wiki.darkrp.com/index.php/DarkRP.Player.AddMoney
The distance check probably isn't passing - why use a hardcoded vector? Also, why add the KeyPress hook inside of ENT:Use? You should just define it outside since it's not binded to any player or entity.
Sorry, you need to Log In to post a reply to this thread.