Sun
Knowledge is power - France is bacon
- Joined
- Jan 26, 2015
- Messages
- 333
- Solutions
- 22
- Reaction score
- 244
---for tfs 0.4---
I was trying to make a "complex system" inside my promotion book script, but ended up making a simplified version that works for me.
It kind of ticks me that I can't figure out how to make it the proper way, so I'm asking for assistance.
The gegg and pegg value system has a flaw
This one has been quite a challenge even up to just this point.
Ty in advance
I was trying to make a "complex system" inside my promotion book script, but ended up making a simplified version that works for me.
It kind of ticks me that I can't figure out how to make it the proper way, so I'm asking for assistance.
The gegg and pegg value system has a flaw
Code:
local cashAmount = 1000000
local gegg = 6544 -- green egg
local pegg = 6545 -- purple egg
function onUse(cid, item, fromPosition, itemEx, toPosition)
local money = getPlayerMoney(cid)
local getItem = getPlayerItemCount(cid, 12406)
local x = getPlayerItemCount(cid, gegg) -- base value (kinda like gp)
local y = getPlayerItemCount(cid, pegg) -- second value (like platinum coins)
local a = y * 100 -- means that 1 pegg has the value of 100 gegg
local z = a + x -- total amount of pegg and gegg together. This was only used in the test fase, but I beleive it will be an important part to the solution.
local b = x/100 -- returns each 100 gegg as 1
if b > 5 then -- if there's more than 500 gegg then
b = 5 -- gegg is only equals to 500
end
local c = 0 -- just a base value so it can be edited without returning errors
if math.floor(b) == 4 then -- if gegg is rounded down to 400 then
c = 1 -- will be the amount of pegg that we'll need to compensate for the gegg
elseif math.floor(b) == 3 then
c = 2
elseif math.floor(b) == 2 then
c = 3
elseif math.floor(b) == 1 then
c = 4
elseif math.floor(b) == 0 then
c = 5
else
c = 0
end -- this c part annoys me, it'll be a pain if one would like to change the amount of gegg needed
if(getPlayerPromotionLevel(cid) < 1) then --if the one using the item is a player and isn't promoted then
if z >= 500 and money >= cashAmount and getItem >= 300 then
if doPlayerRemoveMoney(cid, cashAmount) and doPlayerRemoveItem(cid, 12406, 300) and doPlayerRemoveItem(cid, gegg, b*100) and doPlayerRemoveItem(cid, pegg, c) then -- if we removed all the required items from the player then
doPlayerSetPromotionLevel(cid, 1)
doCreatureSay(cid, "you\'ve been promoted", TALKTYPE_ORANGE_1)
end
else
return doPlayerSendCancel(cid, "you need 100 crystal coins, 300 death notes and 500 eggs to be promoted.")
end
else
return doPlayerSendCancel(cid, "you\'re already promoted")
end
return true
end
This one has been quite a challenge even up to just this point.
Ty in advance
Last edited: