• 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 Simple first script[please currect it]

CM Pepsi

New Member
Joined
Sep 11, 2009
Messages
153
Reaction score
0
Location
Bremen
Hello,

the following script is my first script so something is wrong.

Please currect it and explain my misstake!

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

local I = 1

if item.uid = 1945 and (getPlayerSex(cid) == 1) then
   setPlayerStorageValue(cid,4000)
   
  if getPlayerStorageValue(cid,4000) then

   doPlayerAddOutfit(cid,maleOutfit[I],3)
   setPlayerStorageValue(cid,4000,1)

elseif item.uid = 1945 and (getPlayerSex(cid) == 2) then
    setPlayerStorageValue(cid,4000)

    if getPlayerStorageValue(cid,4000) then

  doPlayerAddOutfit (cid,femaleOutfit[I],3)
  setPlayerStorageValue(cid,4000,1)

else doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "Already have all Addons")

end

end

end

end

thanks:p

Edit: I relly dont understand how to give a storage value...

PHP:
if item.uid = 1945 and (getPlayerSex(cid) == 1) then
   setPlayerStorageValue(cid,4000)
   
  if getPlayerStorageValue(cid,4000) then

Scripting is logik so I thought:

If a item have the id 1945 and the player have sex = male then give the player the storage value 4000. If a player with the storage value of 4000 will do it then he will get all male addons and the storage value will be set down to 1.
 
Last edited:
LUA:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local storage = 7856 -- the storage player gets:)

	if(item.uid == 1658 and getPlayerStorageValue(cid, storage) ~= 1) then
		setPlayerStorageValue(cid, storage, 1)
		-- if not have storage //code//
		-- Receive addon?
		return true
	end
	if(item.uid == 1658 and getPlayerStorageValue(cid) == 1) then
		doCreatureSay(cid, "You have already received this storage, leave!", 18)
		-- message comes if already have this storage already. //code//
		return true
	end
	return true
end

I hope you know how to add addons/outfits, just look at the functions :)
Btw - I'm tired can't do it myself :(
 
thanks :)

PHP:
  function onUse(cid, item, fromPosition, itemEx, toPosition)

local storage = 1200

local I = 1


        if(item.uid == 1945 and getPlayerStorageValue(cid, 1200) ~= 1 and getPlayerSex(cid) == 1) then
                setPlayerStorageValue(cid, 1200, 1)
                doPlayerAddOutfit(cid,maleOutfit[I],3)
                
                return true
        end

        if(item.uid == 1945 and getPlayerStorageValue(cid, 1200) ~= 1 and getPlayerSex(cid) == 0) then
                  setPlayerStorageValue(cid, 1200, 1)
                  doPlayerAddOutfit(cid,femaleOutfit[I],3)

                return true
        end


        if(item.uid == 1945 and getPlayerStorageValue(cid) == 1) then
                doCreatureSay(cid, "You already have all addons!", 18)

                return true
        end
        return true
end
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if (item.itemid == 1945) then
		doTransformItem(item.uid, item.itemid + 1)
	elseif (item.itemid == 1946) then
		doTransformItem(item.uid, item.itemid - 1)
	end

	if (getPlayerStorageValue(cid, 1200) >= 1) then
		doPlayerSendCancel(cid, "Sorry, not posible.")
	else
		if (getPlayerSex(cid) == 0) then
			for i = 1, #femaleOutfits do
				doPlayerAddOutfit(cid, femaleOutfits[i], 3)
			end
		elseif (getPlayerSex(cid) == 1) then
			for i = 1, #maleOutfits do
				doPlayerAddOutfit(cid, maleOutfits[i], 3)
			end
		end
	end
	return true
end
 
I got scared:confused:

A mate made...

local storage = 1200


function onUse(cid, item, fromPosition, itemEx, toPosition)

if item.itemid == 1945 then
new_id = 1946
elseif item.itemid == 1946 then
new_id = 1945
end
doTransformItem(item.uid,new_id)

if getPlayerStorageValue(cid, storage) == -1 then
setPlayerStorageValue(cid, storage, 1)
doPlayerAddAddons(cid, 1)
doPlayerAddAddons(cid, 2)
return true
end

if getPlayerStorageValue(cid) == 1 then
return doCreatureSay(cid, "You already have all addons!", 18)
end
return true
end

Why:

if getPlayerStorageValue(cid, storage) == -1 then

If a player have the Storage Value 1200 and 1200 is like -1? Crazy? How should be a number as 1200 like -1?


Why:

if (getPlayerStorageValue(cid, 1200) >= 1) then

Same. Why should be the storage value 1200 like 1 or bigger then 1200?
 
Last edited:
@up
Your first question:
Well, its simple, if u haven't done a quest, then the server recognize your StorageValue as -1 :)
Dunno why, but it is so
Didn't really get your other question, but if u write the whole script, then its easy to find out :)
Ow, if u mean Salitys script, then if <<<(getPlayerStorageValue(cid, 1200) >= 1) then >>>
means that if players storageKey 1200 has a value that is >= 1 then u cant do the quest:)
in that case u get a cancel message "Sorry, not posible."
 
Last edited:
Yeah but the player can use the "switch" to get the addons anytime so can't know what storage value the palyer have while use the "switch"?
 
@up ok :)
@CM Pepsi
Didn't really get the point of your question, so I can't help you at the moment
 
PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if (item.itemid == 1945) then
		doTransformItem(item.uid, item.itemid + 1)
	elseif (item.itemid == 1946) then
		doTransformItem(item.uid, item.itemid - 1)
	end

	if (getPlayerStorageValue(cid, 1200) >= 1) then
		doPlayerSendCancel(cid, "Sorry, not posible.")
	else
		if (getPlayerSex(cid) == 0) then
			for i = 1, #femaleOutfits do
				doPlayerAddOutfit(cid, femaleOutfits[i], 3)
			end
		elseif (getPlayerSex(cid) == 1) then
			for i = 1, #maleOutfits do
				doPlayerAddOutfit(cid, maleOutfits[i], 3)
			end
		end
	end
	return true
end

I don't understand the script.

PHP:
if (item.itemid == 1945) then
		doTransformItem(item.uid, item.itemid + 1)

1.)if the item (the switch) have the id 1945 then what??? transform what???item.uid, item.itemid +1?????

2.) Idk how we can give the player a storage value. We dont know what storage value the player have before doing the quest so how to use...
setPlayerStorageValue(uid,valueid, newvalue) -- Adds a new value-id to the storage map of player
 
doTransformItem(item.uid, item.itemid + 1)

It's hmm... doTransformItem(which item should be changed?, what is new id of item)

And now...
item.uid - get current unique value of thing.
item.itemid + 1 - get current item id of thing and add 1, so if we have thing with id 1945 new value will be 1945 :)

@Edit:
Player have value -1 before doing quest.
 
It's hmm... doTransformItem(which item should be changed?, what is new id of item)

And now...
item.uid - get current unique value of thing.
item.itemid + 1 - get current item id of thing and add 1, so if we have thing with id 1945 new value will be 1945 :)

@Edit:
Player have value -1 before doing quest.


You mean 1946. :thumbup:
 
Back
Top