• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

onLook

GarQet

Own3d!
Joined
Feb 10, 2009
Messages
1,381
Solutions
14
Reaction score
81
Siemanko!
Mam mały problem...
Skrypt ogólnie działa, ale ładnie mi spamuje konsole TFSka błędem z którym nie mogę się uporać :<

Skrypt:
Code:
function onLook(cid, thing, position, lookDistance)

	local DB_points = db.getResult("SELECT `points` FROM `players` WHERE `id` = '"..getPlayerGUID(thing.uid).."';")
        points = DB_points:getDataInt("points")
        DB_points:free()

	if(isPlayer(thing.uid) == true) then
		doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == 0 and ".\nShe" or ".\nHe") .. " have "..points.." points")
	return true
	end
end

"..getPlayerGUID(thing.uid).."
Dałem thing.uid bo jak daje cid to pokazuje mi ilość danego gracza który daje look na innego.

Jak już mówiłem skrypt działa poprawnie, ale wywala błąd:
Code:
[Error - CreatureScript Interface]
data/creaturescripts/scripts/points.lua:onLook
Description:
data/creaturescripts/scripts/points.lua:3: attempt to concatenate global 'getPlayerGUID' (a function value)
stack traceback:
    data/creaturescripts/scripts/points.lua:3: in function <data/creaturescripts/scripts/points.lua:1>

Nie wiem czemu wywala błąd, uważam że wszystko jest dobrze.
Proszę o pomoc, z góry dzięki +rep :)

Wy mnie nie lubicie, że nie chcecie mi pomóc? :(
 
Last edited by a moderator:
PHP:
function onLook(cid, thing, position, lookDistance) 
	thing.stackpos = STACKPOS_TOP_CREATURE
	player = getThingFromPos(thing).uid
	if not(isPlayer(thing)) then return TRUE end
	local DB_points = db.getResult("SELECT `points` FROM `players` WHERE `id` = '"..getPlayerGUID(thing).."';") 
	if(DB_points:getID() == -1)then return TRUE end
	points = DB_points:getDataInt("points") 
    DB_points:free() 
	doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == 0 and ".\nShe" or ".\nHe") .. " have "..points.." points") 
	return TRUE
end

skutki ciągłego zapytania do bazy mogą mieć nieprzewidziane skutki, jeżeli na bocie 10 osób zrobi sobie co 100ms. zapytanie (looknie na kogoś) 10*10 = 100 zapytań w ciągu sekundy. w ciągu minuty jest to 6,000 zapytań.
Więc odradzam tą metodę...
 
Last edited:
@up
lepiej to zrobic na storage + exhaustion
onLogin
jakistamstorage = points

onLogout
database.points = jakistamstorage.

onLook
description += jakistamstorage


@topic
zaimplementuj sobie ten piekny pseudokod.
 
function onLook(cid, thing, position, lookDistance)
thing.stackpos = STACKPOS_TOP_CREATURE
player = getThingFromPos(player).uid
if not(isPlayer(thing)) then return TRUE end
local DB_points = db.getResult("SELECT `points` FROM `players` WHERE `id` = "2391"..getPlayerGUID(thing).."';")
if(DB_points:getID() == -1)then return TRUE end
points = DB_points:getDataInt("points")
DB_points:free()
doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == 5 and ".\eShe" or ".\oHe") .. " have "..points.." points")
return TRUE
end

he, ja mam tak, pewnie zle ale dałem :P
Liczą się chęci ;s
 
@up
lepiej to zrobic na storage + exhaustion
onLogin
jakistamstorage = points

onLogout
database.points = jakistamstorage.

onLook
description += jakistamstorage
ale po co mi to piszesz? ja tylko przerobiłem na działający jego skrypt, oraz go ostrzegłem o skutkach. Chciał, żeby działał - działa.

he, ja mam tak, pewnie zle ale dałem :P
Liczą się chęci ;s

wypierdalaj na tnet śmieciu zajebany.
 
ale po co mi to piszesz? ja tylko przerobiłem na działający jego skrypt, oraz go ostrzegłem o skutkach. Chciał, żeby działał - działa.

pseudokod byl dla autora tematu.
 
PHP:
function onLook(cid, thing, position, lookDistance) 
	thing.stackpos = STACKPOS_TOP_CREATURE
	player = getThingFromPos(thing).uid
	if not(isPlayer(thing)) then return TRUE end
	local DB_points = db.getResult("SELECT `points` FROM `players` WHERE `id` = '"..getPlayerGUID(thing).."';") 
	if(DB_points:getID() == -1)then return TRUE end
	points = DB_points:getDataInt("points") 
    DB_points:free() 
	doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == 0 and ".\nShe" or ".\nHe") .. " have "..points.." points") 
	return TRUE
end

skutki ciągłego zapytania do bazy mogą mieć nieprzewidziane skutki, jeżeli na bocie 10 osób zrobi sobie co 100ms. zapytanie (looknie na kogoś) 10*10 = 100 zapytań w ciągu sekundy. w ciągu minuty jest to 6,000 zapytań.
Więc odradzam tą metodę...

Code:
[Error - CreatureScript Interface]
data/creaturescripts/scripts/points.lua:onLook
Description:
(luaGetThingFromPos) Tile not found
:(
 
Code:
function onLook(cid, thing, position, lookDistance)  
	if(isPlayer(thing.uid)) then
		local res = db.getResult("SELECT `points` FROM `players` WHERE `name` = '".. getCreatureName(thing.uid) ..";")
		if(res:getID() ~= -1) then
			local points = res:getDataInt("points")
			-- tu radz sobie sam.
		end
	end
	return true
end

Btw. nie radze trzymac pola w players, ktore i tak przy login/logout sie zapisuje, lepiej stworz oddzielna tabele lub uzywaj storage.
 
Back
Top