Ir para conteúdo

Featured Replies

Postado
  • Este é um post popular.

Olá pessoal, trago para vocês um script talkaction que add e remove premium points por comandos in-game.

Primeira, vá em data/talkactions/talkactions.xml e add a tag:

<talkaction words="/addpoints;/removepoints" access="3" script="premium_points.lua"/>

Depois crie um arquivo chamado premium_points.lua em data/talkactions/scripts/ e coloque esse código dentro:

function onSay(cid, words, param)

	local t = string.explode(param, ",")
	
	if param == '' then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Missing params.")
		return true
	end  
	
	local player, balance, pid = getPlayerByName(t[1]), t[2], getPlayerByNameWildcard(t[1])  
	
	if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then   
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "That players doesnt exist or is offline.")  
		return true  
	end
	
	if t[2] == null then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Missing ammount of points.")
		return true
	end 
	
	local accountName = getPlayerAccount(player)
	local accountPoints = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `name` = '" .. accountName .. "' LIMIT 1;")
	local points = tonumber(accountPoints:getDataInt("premium_points"))
	local name = getPlayerName(cid)
	
	if(words == "/addpoints") then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You added "..balance.." premium points to "..t[1].." account.")
		doPlayerSendTextMessage(player, MESSAGE_STATUS_CONSOLE_ORANGE, "You got "..balance.." premium points from "..name..".")  
		points = (points+balance)
		db.query("UPDATE `accounts` SET `premium_points` = " .. points .. " WHERE `name`='" .. accountName .. "' LIMIT 1;")
	elseif (words == "/removepoints") then
		points = (points-balance)
		if points < 0 then
			doPlayerSendTextMessage(player, MESSAGE_STATUS_CONSOLE_ORANGE, ""..name.." removed all your premium points.")
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You removed all "..t[1].." account premium points.")
			db.query("UPDATE `accounts` SET `premium_points` = '0' WHERE `name`='" .. accountName .. "' LIMIT 1;")
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You removed "..balance.." premium points to "..t[1].." account.")
			db.query("UPDATE `accounts` SET `premium_points` = " .. points .. " WHERE `name`='" .. accountName .. "' LIMIT 1;")	
			doPlayerSendTextMessage(player, MESSAGE_STATUS_CONSOLE_ORANGE, ""..name.." removed "..balance.." premium points from your account.") 
		end
	end
	
	return true
end  

Para usar é simples: /COMANDO PLAYER, QUANTIDADE

 

exemplo: /addpoints Luan, 10

 

Créditos: Shispa

 

Bem simples né pessoal? Espero que ajude, abraços e até mais!

  • Respostas 15
  • Visualizações 6k
  • Created
  • Última resposta

Top Posters In This Topic

  • 5 weeks later...
Postado

_erro_de_bosta.png

to tendo esse erro, Luan, tenta arrumar o seu tópico... tem umas coisinhas erradas...

"data/talkactions/actions/ e coloque esse código dentro:"

"exemplo: !Addpoints Luan, 10" 

 

Não manjo nada de scripts, mas errinhos assim eu sei ver :P

Se Ajudei Rep+ pra mim ^^

tumblr_lyd1xtGgx81qf9l6uo1_500.gif

  • 1 month later...

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo