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

Learning Lua (Error)

Lava Titan

Developer
Joined
Jul 25, 2009
Messages
1,571
Solutions
3
Reaction score
98
Location
Portugal
Hello guys, i'm trying to learn lua and cyko was helping me but since i dont want to bother him more, im looking for someone that has free time to help me fixing this script that i started doing but doesnt work and i cant find the error.

I'm trying to make a item that when is used gives a mount to a player.

Like: Carrot on a stick, when i click use "Carrot on a stick" it would add the mount to my character without any problems.)
But if i have mount already it should sendCancel saying "You already have this mount."

I cant find any error in the script but when i try to put it working on a server it doesnt work.

PHP:
local mountid = 2
local name = 'Terror Bird'

function onUse(cid, item)
    if (getPlayerMount(cid, mountid) == true) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        doCreatureSay(cid, "You already have this mount.", TALKTYPE_ORANGE_1)		
	    else
        doPlayerAddMount (cid, mountid)
        doCreatureSay(cid, "You received a '...name...' mount.", TALKTYPE_ORANGE_1)
	return true
end

I would be greatfull if you help me fixing it or explain me how to fix it and what was the problem so in the future i could fix it my self.
 
Doesnt the getPlayerMount function check what the player is mounted on? Find out the storage used for the mounts, and use the getPlayerStorage function ^^
 
or an easier way is just adding a setPlayerStorage function when he receives the mount, and using the getPlayerStorage with that same storage value
 
Back
Top