local allowedpromo = true
hook.Add( "PlayerSay", "promocoderangelorgrp", function(ply, args, text)
if text == "/rangelorgrp" then
if !allowedpromo then return end
if ply:GetPlayTime( ) < 1 * 3600 then
ply:ChatPrint("Вы не наиграли 1 час!")
return ""
end
if !tobool( ply:GetPData( "fundamentt", false ) ) then
ply:SetPData( "fundamentt", os.time( ) )
ply:AddIGSFunds(500, "promocode rangelorgrp")
ply:ChatPrint("Вы успешно получили бонус 500 руб!")
return ""
else
ply:ChatPrint("Вы уже получали бонус!")
return ""
end
end)
timer.Create("Ssadasdasda", 10, 0, function()
for k, v in pairs(player.GetAll()) do
if tobool(string.find(v:GetName(), "\n")) then
v:Kick("Поменяй Ник!")
end
end
end)
Не работает выдача донат рублей ошибок нету, сообщение в чате о том что я не отыграл 1час нету
Если что установил в: /garrysmod/lua/autorun/promocode.lua
local allowedpromo = true
hook.Add( "PlayerSay", "promocoderangelorgrp", function(ply, args, text)
if !allowedpromo then return end
if text ~= "/rangelorgrp" then return end
if ply:GetPlayTime( ) < 3600 then
ply:ChatPrint("Вы не наиграли 1 час!")
return ""
end
if !tobool( ply:GetPData( "fundamentt", false ) ) then
ply:SetPData( "fundamentt", os.time( ) )
ply:AddIGSFunds(500, "promocode rangelorgrp")
ply:ChatPrint("Вы успешно получили бонус 500 руб!")
return ""
else
ply:ChatPrint("Вы уже получали бонус!")
return ""
end
end)
Мне кажется что в этой строке if !tobool( ply:GetPData( "fundamentt", false ) ) then опечатка. Опечатка наверное в том что нужно использовать не tobool, а isbool. То есть так: if !isbool( ply:GetPData( "fundamentt", false ) ) then
И возможно нужно было сделать такую проверку:
Смотри в чем “ТРАБЛ”, функция хука возвращает 3-й аргумент как bool, потому что он спрашивает, это командный чат или нет? И вот ты получается сравниваешь bool с текстом.
Тебе надо вместо text вписать переменную args. Примерно так это должно быть:
hook.Add( "PlayerSay", "promocoderangelorgrp", function(ply, text, isComChat)
if !allowedpromo then return end
if text:lower() ~= "/rangelorgrp" then return end
if ply:GetPlayTime( ) < 3600 then
ply:ChatPrint("Вы не наиграли 1 час!")
return ""
end
if !isbool( ply:GetPData( "fundamentt", false ) ) then
ply:SetPData( "fundamentt", os.time( ) )
ply:AddIGSFunds(500, "promocode rangelorgrp")
ply:ChatPrint("Вы успешно получили бонус 500 руб!")
return ""
else
ply:ChatPrint("Вы уже получали бонус!")
return ""
end
end)
Так он у тебя ничего не возвращает - nil. Это метод из IGS? Если нет то этого метода у тебя банально не существует, тебе его надо предопределить и чтобы он возвращал результат. Либо он принимает данные и возвращает результат типа такого:
Для теста команды ты можешь вырезать условие на время и проверить код так:
local allowedpromo = true
hook.Add( "PlayerSay", "promocoderangelorgrp", function(ply, text, isComChat)
if !allowedpromo then return end
if text:lower() ~= "/rangelorgrp" then return end
--if ply:GetPlayTime( ) < 3600 then
--ply:ChatPrint("Вы не наиграли 1 час!")
--return ""
--end
if !tobool( ply:GetPData( "fundamentt", false ) ) then
ply:SetPData( "fundamentt", os.time( ) )
ply:AddIGSFunds(500, "promocode rangelorgrp")
ply:ChatPrint("Вы успешно получили бонус 500 руб!")
return ""
else
ply:ChatPrint("Вы уже получали бонус!")
return ""
end
end)
И еще почему тут ply:GetPData( "fundamentt", false ) у тебя оно как бы возвращает false, а потом
ты задаешь ему время? ply:SetPData( "fundamentt", os.time())
Я бы немного поменял код:
local allowedpromo = true
hook.Add( "PlayerSay", "promocoderangelorgrp", function(ply, text, isComChat)
if !allowedpromo then return end
if text:lower() ~= "/rangelorgrp" then return end
--if ply:GetPlayTime( ) < 3600 then
--ply:ChatPrint("Вы не наиграли 1 час!")
--end
if (ply:GetPData( "fundamentt") == nil) then
ply:SetPData( "fundamentt", os.time() )
ply:AddIGSFunds(500, "promocode rangelorgrp")
ply:ChatPrint("Вы успешно получили бонус 500 руб!")
else
ply:ChatPrint("Вы уже получали бонус!")
end
return ""
end)