• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action OnUse Item = Give Reward

Ekt

New Member
Joined
Sep 11, 2011
Messages
58
Reaction score
0
Location
127.0.0.1
Hello here it is another of my simple scripts, NOTE: I AM LEARNING LUA, PLEASE CORRECT ME IF I DID IT BAD.

Lua:
function onUse(cid, item, frompos, item2, topos) 

       if item.actionid == 212121 then 
           queststatus = getPlayerStorageValue(cid,212121) 
           if queststatus == -1 and getPlayerLevel(cid) >= 50 then -- if is more than level 50
               doPlayerSendTextMessage(cid,22,"Here is your reward!") 
               doPlayerAddItem(cid,2160,2) -- edit item id 2160 to your item you want to give reaching this level.
               setPlayerStorageValue(cid,212121,1) 
           else 
               doPlayerSendCancel(cid,"It is empty or you don't have enough level.") 
           
       end 

       return TRUE 
end

XML
Lua:
 <action actionid="212121." event="script" value="rewardchest.lua"/>
Comment!
 
It's cool, but doesn't need this <action actionid="212121." event="script" value="rewardchest.lua"/> the ".".

Just 212121.
Don't you tested the script? Just turn on the server if you need :S
 
First of all there is no actionid 212121 coz the max number is 65535 , and u dont need to write if item.actionid == XXX then coz its already in the actions.xml :)

anyways i fixed ur script here u go

Lua:
function onUse(cid, item, frompos, item2, topos) 
	if getPlayerStorageValue(cid,10400) ~= 1 and getPlayerLevel(cid) >= 50 then -- if is more than level 50
        doPlayerSendTextMessage(cid,22,"Here is your reward!") 
        doPlayerAddItem(cid,2160,2) -- edit item id 2160 to your item you want to give reaching this level.
        setPlayerStorageValue(cid, 10400, 1) 
    else 
        doPlayerSendCancel(cid,"It is empty or you don't have enough level.") 
 
    end 
 
return TRUE 
end

Lua:
<action actionid="21212" event="script" value="rewardchest.lua"/>
 
Last edited:
Lua:
function onUse(cid, item, frompos, item2, topos) 
	if getPlayerLevel(cid) >= 50 then -- if is more than level 50
		    if getPlayerStorageValue(cid,10400) ~= 1 then
    			    doPlayerSendTextMessage(cid,22,"Here is your reward!") 
   			    doPlayerAddItem(cid,2160,2) -- edit item id 2160 to your item you want to give reaching this level.
     			    setPlayerStorageValue(cid, 10400, 1) 
		else
      		  doPlayerSendCancel(cid,"If quest compited") 
		end
    else 
        doPlayerSendCancel(cid,"It is empty or you don't have enough level.") 
    end 
return TRUE 
end

hmm? ^^
 
More Better...

Code:
function onUse(cid, item, frompos, item2, topos) 
	if getPlayerLevel(cid) >= 200 then -- if is more than level 50
		    if getPlayerStorageValue(cid,10400) ~= 1 then
    			    doPlayerSendTextMessage(cid,22,"Here is your reward!") 
   			    doPlayerAddItem(cid,2160,2) -- edit item id 2160 to your item you want to give reaching this level.
			    doRemoveItem(item.uid,1)
     			    setPlayerStorageValue(cid, 10400, 1) 
		else
      		  doPlayerSendCancel(cid,"Ya la quest esta completa") 
		end
    else
        doPlayerSendCancel(cid,"No tienes el nivel necesario.") 
    end 
return TRUE 
end
 
Back
Top