Bonika

Untitled

Jan 13th, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.69 KB | None | 0 0
  1. local sql = exports.rise_mysql:getConnection()
  2.  
  3. local sentAdv = {}
  4. local advTimers = {}
  5. local calls = {}
  6.  
  7. function addPhone(p)
  8. local number = math.random(111111, 999999)
  9. exports.rise_item:giveItem(p,8,tonumber(number),1,0)
  10. end
  11. addEvent('phone:addPhone', true)
  12. addEventHandler('phone:addPhone', root, addPhone)
  13.  
  14. function sendMessage(p, f, n, t)
  15. if tonumber(n) and tonumber(n) >= 111111 and tonumber(n) <= 999999 then
  16. local target = getPlayerPhoneNumber(tonumber(n))
  17. if target then
  18. exports.rise_chat:sendLocalMeAction(p, 'küldött egy sms-t.')
  19. exports.rise_chat:sendLocalMeAction(target, 'kapott egy sms-t.')
  20. triggerClientEvent(target, 'phone:createNewMessageC', target, f, t)
  21. dbExec(sql, 'INSERT INTO phone_sms SET fr=?, t=?, msg=?', f, tonumber(n), t)
  22. else
  23. outputChatBox('#DC143C[RiseMTA]:#ffffff Sikertelen üzenetküldés! Ezen a számon előfizető nem található!', p, 0, 0, 0, true)
  24. end
  25. else
  26. exports.rise_infobox:addNotificationFelsoS(p, 'Sikertelen üzenetküldés.\nHibás telefonszám.', 'info')
  27. end
  28. end
  29. addEvent('phone:sendMessageS', true)
  30. addEventHandler('phone:sendMessageS', root, sendMessage)
  31.  
  32. function loadMessages(p, n)
  33. local qh = dbPoll(dbQuery(sql, 'SELECT fr, msg FROM phone_sms WHERE t=? ORDER BY dat DESC', n), -1)
  34. local t = {}
  35. for k, v in pairs(qh) do
  36. t[#t+1] = {v['fr'], v['msg']}
  37. end
  38. triggerClientEvent(p, 'phone:loadMessagesC', p, t)
  39. end
  40. addEvent('phone:loadMessagesS', true)
  41. addEventHandler('phone:loadMessagesS', root, loadMessages)
  42.  
  43. function sendAdv(p, t, s, n)
  44. local price = string.len(t)*250
  45. if not (sentAdv[p] and advTimers[p]) then
  46. if price > 250 then
  47. if p:getData('char:money') >= price then
  48. outputChatBox("#DC143C[RiseMTA]:#ffffffA hírdetés feladása összesen "..price..'Ft-ba került. Köszönjük.', p, 0, 0, 0, true)
  49. if advTimers[p] then
  50. sentAdv[p] = setTimer(function(p) sentAdv[p] = nil end, 1000*5*60, 1, p)
  51. else
  52. advTimers[p] = setTimer(function(p) advTimers[p] = nil end, 1000*5*60, 1, p)
  53. end
  54. p:setData('char:money', p:getData('char:money')-price)
  55. for k, v in pairs(getElementsByType('player')) do
  56. if v:getData('phone:ads') then
  57. outputChatBox('#FFFFFF==================== [ #05afb5RiseCity újság#FFFFFF ] ====================', v, 2, 216, 55, true)
  58. outputChatBox('#05afb5HÍRDETÉS:#FFFFFF '..t..'', v, 2, 216, 55, true)
  59. outputChatBox('#05afb5Kapcsolat:#FFFFFF '..n..' (('..p:getData('char:name')..')).', v, 2, 216, 55, true)
  60. end
  61. end
  62. else
  63. exports.rise_infobox:addNotificationFelsoS(p, 'Nincs elég pénzed', 'error')
  64. end
  65. end
  66. else
  67. outputChatBox('#DC143C[RiseMTA]:#ffffff 5 percenként maximum 2 hírdetést tudsz feladni.', p, 0, 0, 0, true)
  68. end
  69. end
  70. addEvent('phone:sendAdvS', true)
  71. addEventHandler('phone:sendAdvS', root, sendAdv)
  72.  
  73. function sendAdvIllegal(p, t, s, n)
  74. local price = string.len(t)*250
  75. if not (sentAdv[p] and advTimers[p]) then
  76. if price > 250 then
  77. local send = true
  78. for i, d in pairs(RisenionBlackList) do
  79. if exports.rise_dashboard:isInGroup(p, d) then
  80. send = false
  81. break
  82. end
  83. end
  84. if send then
  85. if p:getData('char:money') >= price then
  86. outputChatBox("#DC143C[RiseMTA]:#ffffffA hírdetés feladása összesen "..price..'Ft-ba került. Köszönjük.', p, 0, 0, 0, true)
  87. if advTimers[p] then
  88. sentAdv[p] = setTimer(function(p) sentAdv[p] = nil end, 1000*5*60, 1, p)
  89. else
  90. advTimers[p] = setTimer(function(p) advTimers[p] = nil end, 1000*5*60, 1, p)
  91. end
  92. p:setData('char:money', p:getData('char:money')-price)
  93. for k, v in pairs(getElementsByType('player')) do
  94. if v:getData('phone:ads') then
  95. local show = true
  96. for i, d in pairs(RisenionBlackList) do
  97. if exports.rise_dashboard:isInGroup(v, d) then
  98. show = false
  99. break
  100. end
  101. end
  102. if show then
  103. outputChatBox('#FFFFFF==================== [ #b54e05RiseCity DarkWeb#FFFFFF ] ====================', v, 2, 216, 55, true)
  104. outputChatBox('#b54e05HÍRDETÉS:#FFFFFF '..t..'', v, 2, 216, 55, true)
  105. outputChatBox('#b54e05Kapcsolat:#FFFFFF '..n..' (('..p:getData('char:name')..')).', v, 2, 216, 55, true)
  106. end
  107. end
  108. end
  109. else
  110. exports.rise_infobox:addNotificationFelsoS(p, 'Nincs elég pénzed', 'error')
  111. end
  112. end
  113. end
  114. else
  115. outputChatBox('#DC143C[RiseMTA]:#ffffff 5 percenként maximum 2 hírdetést tudsz feladni.', p, 0, 0, 0, true)
  116. end
  117. end
  118. addEvent('phone:sendAdvIllegalS', true)
  119. addEventHandler('phone:sendAdvIllegalS', root, sendAdvIllegal)
  120.  
  121. function startCall(p, myNum, num)
  122. local t = getPlayerPhoneNumber(num)
  123. if t then
  124. if t ~= p then
  125. if not calls[t] then
  126. calls[p] = t
  127. calls[t] = p
  128. triggerClientEvent(t, 'phone:startRingC', t, myNum, num)
  129. triggerClientEvent(p, 'phone:setCallerScreenC', p)
  130. else
  131. outputChatBox('#DC143C[RiseMTA]:#ffffff A hívott szám pillanatnyilag nem kapcsolható!', p, 0, 0, 0, true)
  132. end
  133. else
  134. outputChatBox('#DC143C[RiseMTA]:#ffffff A hívott szám pillanatnyilag nem kapcsolható!', p, 0, 0, 0, true)
  135. end
  136. end
  137. end
  138. addEvent('phone:startCallS', true)
  139. addEventHandler('phone:startCallS', root, startCall)
  140.  
  141. function endCall(p)
  142. triggerClientEvent(calls[p], 'phone:endCallC', calls[p])
  143. triggerClientEvent(root, 'phone:stopRingSoundC', root, calls[p])
  144. triggerClientEvent(root, 'phone:stopRingSoundC', root, p)
  145. outputChatBox('#DC143C[RiseMTA]:#ffffff Vége a hívásnak!', p, 0, 0, 0, true)
  146. outputChatBox('#DC143C[RiseMTA]:#ffffff Vége a hívásnak!', calls[p], 0, 0, 0, true)
  147. calls[calls[p]] = nil
  148. calls[p] = nil
  149. end
  150. addEvent('phone:endCallS', true)
  151. addEventHandler('phone:endCallS', root, endCall)
  152.  
  153. function sendPlayerCallerText(p, n, t)
  154. exports.rise_chat:localIC(p, t, '', ' ((telefonba))')
  155. triggerClientEvent(calls[p], 'phone:addPlayerCallerTextC', calls[p], n, t)
  156. triggerClientEvent(p, 'phone:addPlayerCallerTextC', p, n, t)
  157. end
  158. addEvent('phone:sendPlayerCallerTextS', true)
  159. addEventHandler('phone:sendPlayerCallerTextS', root, sendPlayerCallerText)
  160.  
  161. function startRingSound(p, n)
  162. triggerClientEvent(root, 'phone:startRingSoundC', root, p, n)
  163. end
  164. addEvent('phone:startRingSoundS', true)
  165. addEventHandler('phone:startRingSoundS', root, startRingSound)
  166.  
  167. function stopRingSound(p)
  168. triggerClientEvent(root, 'phone:stopRingSoundC', root, p)
  169. end
  170. addEvent('phone:stopRingSoundS', true)
  171. addEventHandler('phone:stopRingSoundS', root, stopRingSound)
  172.  
  173. function getPlayerPhoneNumber(n)
  174. local r = false
  175. for k, v in pairs(getElementsByType('player')) do
  176. if exports.rise_item:hasItem(v, 8, n) or exports.rise_item:hasItem(v, 8, tostring(n)) then
  177. r = v
  178. break
  179. end
  180. end
  181. return r
  182. end
Advertisement
Add Comment
Please, Sign In to add comment