• 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!

LuaSql

hesczu

New Member
Joined
Jun 14, 2007
Messages
148
Reaction score
0
SOMEBODY CAN HELP ME WITH THE LUASQL PART?

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local donatorgroup = 4
	local target = 	getPlayerName (cid)
	local ticket = 2345
	
     dofile("./config.lua")
     if sqlType == "mysql" then
         env = assert(luasql.mysql())
         con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
	 cur = assert(con:execute("UPDATE players SET group_id = 4 WHERE name = "..target..";"))



	if isPlayer (cid) then
	setPlayerGroupId(cid, donatorgroup)
	doSendAnimatedText(getCreaturePosition(cid),"Donator!",198)
	
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYAREA)
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BIGPLANTS)
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIANTICE)
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYAREA)
end
end

   doPlayerRemoveItem(cid,ticket,1)

end
 
Try this:
Code:
local donatorgroup = 4
local ticket = 2345

dofile("./config.lua")
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local env = assert(luasql.mysql())
	local con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
	local cur = assert(con:execute("UPDATE players SET group_id = 4 WHERE name = " .. getPlayerName(cid) .. ";"))

	if isPlayer(cid) == TRUE then
		setPlayerGroupId(cid, donatorgroup)
		doSendAnimatedText(getCreaturePosition(cid)," Donator!", 198)
		doSendMagicEffects(getCreaturePosition(cid), CONST_ME_HOLYAREA, CONST_ME_BIGPLANTS, CONST_ME_GIANTICE, CONST_ME_HOLYAREA)
	end
	
	doPlayerRemoveItem(cid,ticket,1)
	return TRUE
end 

function doSendMagicEffects(pos, ...)
	for _, effect in pairs(arg) do
		doSendMagicEffect(pos, effect)
	end
end
 
the both codes make my server crash, i cant understand why :S, but thanks for your help, ill try to find more help about it
 
Back
Top