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

Lua Assassin star doesn't end?

Thunder OT 8.0

New Member
Joined
Jan 24, 2014
Messages
16
Reaction score
0
My assassin star script:

Code:
function onUseWeapon(cid, var)
rand = math.random(1,5)
if rand >= 10 and rand < 11 then
doPlayerRemoveItem(cid,7368,1)
else
    return doCombat(cid, combat, var)
end
end

Hmm? :P

I always have one left it never disappear :p I think math random 1,5 means 1 out of 5 it disappear?
 
Last edited by a moderator:
I suppose its here you edit that right?
In items.xml

Code:
    <item id="7368" article="an" name="assassin star">
        <attribute key="weight" value="200" />
        <attribute key="attack" value="65" />
        <attribute key="maxHitChance" value="96" />
        <attribute key="weaponType" value="distance" />
        <attribute key="shootType" value="redstar" />
        <attribute key="range" value="5" />
        <attribute key="breakChance" value="1" />
        <attribute key="ammoAction" value="moveback" />
    </item>

So basically if you change "breakChance" to 100, it will disappear every single shot.
 
So I should remove the script from the weapons map?

In weapons map I have assassinstar.lua and
Code:
<distance id="7368" range="5" enabled="1" exhaustion="0" hitchance="90" ammo="removecount" script="assassinstar.lua"></distance>

I have this for every distance weapon in the weapons file :P Remove all and insert everything in items.xml?

What does "maxHitChance" mean?

Hi. This didn't work on my OT. I need to edit it in weapons.xml + assassinstar.lua

So I need to get this explained for me:

Code:
function onUseWeapon(cid, var)
rand = math.random(1,5)
if rand >= 10 and rand < 11 then
doPlayerRemoveItem(cid,7368,1)
else
    return doCombat(cid, combat, var)
end
end
 
Last edited by a moderator:
rand = math.random(1,5)
if rand >= 10 and rand < 11 then

You are randoming a number between 1 and 5
1
2
3
4
5

But the number needs to be 10 to remove the item.
(10 or more, and less than 11)

One of theese should work:
if rand >= 5 and rand < 6 then
if rand == 5 then

Code:
function onUseWeapon(cid, var)
rand = math.random(1,5)
if rand == 5 then
doPlayerRemoveItem(cid,7368,1)
else
    return doCombat(cid, combat, var)
end
end
 
Ok thanks! :)

Now it works. BUT, when he is about to lose a assassin star, instead of shoot it and lose it, it just disappear without being shot (only the one that is gonna end) Solution?
 
Last edited by a moderator:
This is like... the most basic of lua... you really should read around otland and see if you can learn a bit yourself instead of just throwing your hands in the air and asking for the answer.

Code:
local breakChance = 5 -- This is the % chance to break
function onUseWeapon(cid, var)
    if(math.random(100) <= breakChance) then
        doPlayerRemoveItem(cid,7368,1)
    end
    return doCombat(cid, combat, var)
end
 
Back
Top