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

[request]web-guild-system NPC

Gesior.pl

Mega Noob&LOL 2012
Senator
Joined
Sep 18, 2007
Messages
2,987
Solutions
102
Reaction score
3,436
Location
Poland
GitHub
gesior
I made House Auction/Sell-Buy system in ACC maker. Its script from ym NPC:
Code:
function onThink()
	dofile("./config.lua")
	env = assert(luasql.mysql())
	con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
	cur = assert(con:execute("SELECT `cid`, `houseid` FROM `house_add_in_game`;"))
	row = cur:fetch({}, "a")
		while row do
			housecid = row.cid
			houseid = row.houseid
			--if player online
			--bank = getPlayerStorageValue(housecid,300)
			--bank = bank - 1
			--setPlayerStorageValue(housecid,300, bank)
			--else
			--tutaj ma zmieniac w bazie danych dane
			--end
			--if kase odjeto z konta
			setHouseOwner(houseid, housecid)
			assert(con:execute("DELETE FROM `house_add_in_game` WHERE `houseid` = '" .. houseid .. "' ;"))
			assert(con:execute("UPDATE `houses` SET `owner` = '" .. housecid .. "' WHERE `id` = '" .. houseid .. "';"))
			--if kase odjeto z konta END
			row = cur:fetch (row, "a")
		end
con:close()
env:close()
end
How can I check is player online or not? If he is online NPC should change storage_id value in game. If he isnt online NPC should change storage_id value in database by SQL command.
2. How NPC can set guild ID/nick?
When i added code after "function onThink()" in my NPC:
Code:
doPlayerSetGuildId("4", "1")
and run TFS i see error:
Code:
data/npc/sctripts/banko.lua:9: attempt to call global 'doPlayerSetGuildId' (a nil value)
What is wrong? Guild commands work fine on TFS 0.2.6?
 
It doesnt work :(
Is here anyone who know how to write this script (take cash from bank account - storage ID 300 when player is online).
EDIT:
It work :p
I have GUID in database, not cid. I was trying to use "isPlayer(cid)" with GUID :>
First version of working NPC (if someone have problems with LUA + PHP page)
house_check_time = 0
function onThink()
if os.time() > house_check_time then
house_check_time = os.time() + 5
dofile("./config.lua")
env = assert(luasql.mysql())
con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
cur = assert(con:execute("SELECT `cid`, `houseid`, `price`, `name` FROM `house_add_in_game`;"))
row = cur:fetch({}, "a")
while row do
houseid = row.houseid
guid = row.cid
name = row.name
price = row.price
cid = getPlayerByName(name)
price = stringToVariant(price)
price = variantToNumber(price)
price = price + row.price
if isPlayer(cid) == TRUE then
player_cash = getPlayerStorageValue(cid, 300)
if player_cash > price or player_cash == price then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You won house!")
player_cash = player_cash - price
setPlayerStorageValue(cid, 300, player_cash)
setHouseOwner(houseid, guid)
assert(con:execute("DELETE FROM `house_add_in_game` WHERE `houseid` = '" .. houseid .. "' ;"))
assert(con:execute("UPDATE `houses` SET `owner` = '" .. guid .. "' WHERE `id` = '" .. houseid .. "';"))
else
house_check_time = os.time() + 12
doPlayerSendCancel(cid, "You won house, but you dont have enought cash in bank.")
end
else
--what to do when player is not online
end
row = cur:fetch (row, "a")
end
con:close()
env:close()
end
end
 
Last edited:
Back
Top