• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

See IT Please

Stewie

Family Guy # ;3
Joined
May 3, 2010
Messages
786
Reaction score
12
Location
TV
i would like a command for gods,for add premium points,

here function

Code:
function doAddPoints(cid, points)
    db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end

like that:

Code:
/addpoints Name of player,XXX

Thx !!!
 
Not tested.

LUA:
local function addPoints(name, points)
	return db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(name) .. ";")
end

function onSay(cid, words, param, channel)
	local t = string.explode(param, ",")
	if t[1] or t[2] == "" then
		doPlayerSendCancel(cid, "Command param required.")
		return true
	end
	
	local pid = getPlayerByNameWildcard(t[1])
	if(not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid))) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Player " .. pid .. " not found.")
		return true
	end
	
	if not tonumber(t[2]) then
		doPlayerSendCancel(cid, "Sorry, not possible.")
	else
		addPoints(t[1], t[2])
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have added " .. t[2] .. " premium points to " .. t[1] .. ".")
	end

	return true
end
 
Last edited:
LUA:
function onSay(cid, words, t, channel)
	if not t or t == '' then
		return doPlayerSendCancel(cid, 'Command param required.')
	end

	t = string.explode(t, ',')
	t[2] = tonumber(t[2])
	if #t ~= 2 or not t[2] then
		return doPlayerSendCancel(cid, 'Invalid parameters.')
	end

	local pid = getPlayerByNameWildcard(t[1])
	if not pid or (isPlayerGhost(pid) and getPlayerGhostAccess(pid) > getPlayerGhostAccess(cid)) then
		return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'Player ' .. t[1] .. ' not found.')
	end

	db.executeQuery('UPDATE `accounts` SET `premium_points` = `premium_points` + ' .. t[2] .. ' WHERE `id` = ' .. getPlayerAccountId(pid) .. ';')
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have added ' .. t[2] .. ' premium points to ' .. t[1] .. '.')
 
	return true
end
 
@up

hate u guys. U always use varialbes that does not make any sense for someone else who reads the code and for not so pro people sometimes it's hard to understand wth is what, if the code is longers. LIke "t", why the fuck not just call it "param"?
 
t = string.explode(t, ',')

There is your explanation of t.

yes, I do fucking know how to read! Just saying, if u would have 999 lines of code with t, a, z ,b , c, l, k, it would be confusing to remember and understand what is what. Assigning names to variables that makes sense is one of the thing any good programmer/scripter should do.
 
I don't think everyone that have their own ot is blind richux. If people see a t and wanna know the explanation of it, search for local t or t = and you'll find the explanation for it. Easy as that. People that doesn't know how to search for an explanation shouldn't be having their own ot.
 
@up

hate u guys. U always use varialbes that does not make any sense for someone else who reads the code and for not so pro people sometimes it's hard to understand wth is what, if the code is longers. LIke "t", why the fuck not just call it "param"?
Why write "param" if you can use "t" instead? Besides the script compile time is a few microseconds shorter and memory usage smaller by a few bytes.

Richux, this is a very tiny code and doesn't really need special variable names. How can someone get confused over this?!
 
Why write "param" if you can use "t" instead? Besides the script compile time is a few microseconds shorter and memory usage smaller by a few bytes.

Richux, this is a very tiny code and doesn't really need special variable names. How can someone get confused over this?!

@up

hate u guys. U always use varialbes that does not make any sense for someone else who reads the code and for not so pro people sometimes it's hard to understand wth is what, if the code is longers. LIke "t", why the fuck not just call it "param"?

yes, I do fucking know how to read! Just saying, if u would have 999 lines of code with t, a, z ,b , c, l, k, it would be confusing to remember and understand what is what. Assigning names to variables that makes sense is one of the thing any good programmer/scripter should do.

It's not about this particular code, but about the style in general. And if u do such variables in short codes, ull do them in long ones too.
 
It's not about this particular code, but about the style in general. And if u do such variables in short codes, ull do them in long ones too.
And who cares? If you use any decent text editor, you'll be able to highlight all variables of that name by just selecting one.
 
Back
Top