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

Auto Hunter Top Player Online

Streks

New Member
Joined
Feb 27, 2016
Messages
62
Reaction score
2
Hi
Code:
I would like a script that pay a Certain amount of money to whoever kills the TOP level online in the game.

Example: The Most wanted of the world is /playername/ if you kill him, the king pay 75k......etc etc

or THE FBI is offering a reward of up to $50k for information... hahaha kiding :p
Thank You
 
Hi
Code:
I would like a script that pay a Certain amount of money to whoever kills the TOP level online in the game.

Example: The Most wanted of the world is /playername/ if you kill him, the king pay 75k......etc etc

or THE FBI is offering a reward of up to $50k for information... hahaha kiding :p
Thank You
Hi I would like you to post requested scripts in request section of this forum, thanks.
 
Hi
Code:
I would like a script that pay a Certain amount of money to whoever kills the TOP level online in the game.

Example: The Most wanted of the world is /playername/ if you kill him, the king pay 75k......etc etc

or THE FBI is offering a reward of up to $50k for information... hahaha kiding :p
Thank You

If you want people to take time out of their day to help you out and save you the effort of learning how to script, you can at least take your request a little bit more seriously by:
* Not posting in the wrong board
* Structuring your post to have a clear question and clear instructions for implementation
* Saying which version of TFS you are using

I hope this these tips will help with your future posts.

Now that that's out of the way, here's something you could clarify:

Once again, which TFS would this script be for, and "Top level online in the game" - Does this mean the guy who is the highest level currently on the entire server (1st place on highscores) or the guy that is the highest level out of all people who are online in this moment?

If it's the 2nd case, when would you determine which player is the highest level? Because if playerX is currently the highest level online, and while you are on a hunt for him, playerY logs in (and playerY is even higher level than playerX), then is playerX still the hunted guy or does it immediately switch to playerY?)
 
If you want people to take time out of their day to help you out and save you the effort of learning how to script, you can at least take your request a little bit more seriously by:
* Not posting in the wrong board
* Structuring your post to have a clear question and clear instructions for implementation
* Saying which version of TFS you are using

I hope this these tips will help with your future posts.

Now that that's out of the way, here's something you could clarify:

Once again, which TFS would this script be for, and "Top level online in the game" - Does this mean the guy who is the highest level currently on the entire server (1st place on highscores) or the guy that is the highest level out of all people who are online in this moment?

If it's the 2nd case, when would you determine which player is the highest level? Because if playerX is currently the highest level online, and while you are on a hunt for him, playerY logs in (and playerY is even higher level than playerX), then is playerX still the hunted guy or does it immediately switch to playerY?)

thanks for your education and be telling me about the process. // *sorry for wrong board.


Ok, let's go..
I would like that the top level (online) is sought , Appear to broadcast saying that x Player is being hunted. However , if the player Y Become the top level , he automatically passe the hunted player and X will no longer be.
tfs: o.3.7 modified otx.
 
Okay, I'll post the code with comments so hopefully you will learn how to do something similar (or modificiations to it) by yourself:

Make sure that global storage values 31313 and 31314 are not used anywhere else on the server already, or after this.
If you don't know what i'm talking about, there's a high chance that it's not used then, so we're good to go.
If they are used, then alter my code and change occurrences of 31313 and 31314 to some numbers that are not used.



In lib/050-functions.lua, a library for functions, we will create 2 new functions:

Code:
    --- FUNCTIONS LIB:
 
    function triggerHuntFor(cid)
        if getGlobalStorageValue(31314) ~= cid then -- Read the comment below first -> We won't do that if the highest level is already this same person.
            setGlobalStorageValue(31314, cid)    -- We set a global storage value to be equal to the input userdata. This will give us a global variable that we can quickly access and/or change to indicate which player is the highest level atm online.
            setGlobalStorageValue(31313, getPlayerLevel(cid))    -- We set a global storage value to be equal to the input userdata. This will give us a global variable that we can quickly access and/or change to indicate which player is the highest level atm online.
            doBroadcastMessage("[The Hunt is On!]\nPlayer " ..getCreatureName(cid).. " is the highest level online and thus hunted.\nKilling him/her will reward a bounty!") -- Broadcast message
        end
    end
 
        -- A function that will return the user data of the highest level player currently online in the game
    function getHighestOnlineLevel(self,skipself)
        local highest = {id = 0, level = 0} -- We set an array that will hold some data for us. By default, this data is equal to 0.
        for _, name in ipairs(getOnlinePlayers()) do -- We initiate a loop that will go through every online player (Warning: This can be resource intensive, especially if repeated at a frequent interval. Do not make the interval too low.
                local cid = getPlayerByName(name) -- We get the userdata of the player that's currently being checked
                if cid == self and skipself == true then
                -- Nothing goes on this line. We skip doing anything here, because we deliberately set the parameters to skip this player in the search
                else
                    if getPlayerLevel(cid) > highest.level then -- If the level of the player that's currently being checked is higher than the highest level we detected so far, we set the highest.level value to be his level, and store his id in highest.id
                        highest.level = getPlayerLevel(cid)
                        highest.id = cid
                    end
                end
        end 
     
        return highest.id -- The function returns us the user data of the player with the highest level, then we can do something with it later
    end

In creaturescripts.xml, we'll add these new scripts:

logoutbh.lua

Code:
    function onLogout(cid) 
        -- When you log out, if you were the highest level, then we search for another player who is the highest level after you log out
        if getGlobalStorageValue(31314) == cid then
            local person = getHighestOnlineLevel(cid, true) -- Get the highest online level (excluding yourself, since you're about to log out) and store that player's userdata in variable 'person'
            doBroadcastMessage("[The Hunt is On!]\nPlayer " ..getPlayerName(cid).. " has logged out as the highest level on the server.\nA new player has been marked for the bounty: " ..getCreatureName(person).. "!\nGet him/her!") -- Broadcast message
            triggerHuntFor(cid)
        end
 
    return true
    end

killbh.lua

Code:
function onKill(cid, target)

    if isPlayer(cid) and isPlayer(target) then
        if getGlobalStorageValue(31314) == target then
            doBroadcastMessage("[The Hunt is On!]\nPlayer " ..getCreatureName(cid).. " killed the hunter player " ..getCreatureName(target).. " and claimed the bounty!") -- Broadcast message
            doPlayerAddItem(cid, rewardID, stacks) -- EDIT rewardID and stacks to your liking. Copy/paste this line if you want to give more than just 1 item.
        end
    end
 
    return true
end

Now, open creaturescripts/scripts/ login.lua and add this to it in an appropriate place:

Code:
    registerCreatureEvent(cid, "LogoutBH") -- Registers a custom creature event that we made to the player (so that the script may be loaded for that player)
    registerCreatureEvent(cid, "KillBH") -- Registers a custom creature event that we made to the player (so that the script may be loaded for that player)
 
    if getPlayerLevel(cid) > getGlobalStorageValue(31313) then -- When you log in, if your level is higher than the currently highest level, you become the new hunted target
        triggerHuntFor(cid)
        doBroadcastMessage("[The Hunt is On!]\nPlayer " ..getPlayerName(cid).. " has logged in as the highest level on the server.\nThe bounty is on his/her head!") -- Broadcast message
    end

And finally, open creaturescripts.xml and add this:


Code:
  <event type="kill" name="KillBH" event="script" value="killbh.lua"/>
    <event type="logout" name="LogoutBH" event="script" value="logoutbh.lua"/>

Make sure to alter the doPlayerAddItem function in killbh.lua to give the reward you want it to give.

You will find that such a system in its current state is faulty, by the way (but this is exactly what you requested, so I'm giving you what you requested. You might need to think about more details next time you request a script).

Reasons:
It may spam the broadcast messages whenever someone logs in/logs out if they happen to be the highest level.
It may lag the server, depending on the PC's performance, if the getHighestOnlineLevel(self,skipself) function is called too frequently or a lot at a very small time period. (Which would happen if a ton of players that are hunted repeatedly log out)

Hope it helps out.

EDIT: Btw, I didn't test this, just wrote it, so you might wanna test it out first and post if there are some issues. I may have made some mistake, idk, too lazy to re-check everything again :p
EDIT 2: You may also want to rename the thread (if that's possible, i think it should be) to something more indicative of its content, so that the people using the Search function on OTLand can find proper results easier.
 
Okay, I'll post the code with comments so hopefully you will learn how to do something similar (or modificiations to it) by yourself:

Make sure that global storage values 31313 and 31314 are not used anywhere else on the server already, or after this.
If you don't know what i'm talking about, there's a high chance that it's not used then, so we're good to go.
If they are used, then alter my code and change occurrences of 31313 and 31314 to some numbers that are not used.

.

thank you very much for your generosity, and thanks also for his understanding and kindness.
I 'll be testing and bring you a feedback soon. ok ???

thank you.
 
thank you very much for your generosity, and thanks also for his understanding and kindness.
I 'll be testing and bring you a feedback soon. ok ???

thank you.

You're welcome. Sounds good. Just try to learn from the comments and start modifying scripts and learning lua yourself slowly if you can.
Cheers
 
Back
Top