Login
Sign Up


You are using the mobile version of the forum, some features have been disabled to have it responsive.
Limelight CityRP - v4b1Limelight CityRP - EU Build
Ares Defence Services DiscordAres Defence Services
Limelight Discord
Limelight CityRP - v4b1Limelight CityRP - EU BuildAres Defence Services DiscordAres Defence ServicesLimelight Discord

receiptDevelopment Blog:

Development Contributor Workflow

receiptHR Blog:

What *are* they doing over there?

receiptTeacher Blog:

Insight into the Teacher Team

receiptDevelopment Blog:

Infrastructure Upgrade 11/2019

receiptDevelopment Blog:

how suggestions???

receiptDevelopment Blog:

Planning for the future.


This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Closed 
Adding /roll
BlackDog radio_button_checked
Veteran
Veteran Member
Posts: 2,727
Threads: 49
Likes Given: 0
Likes Recieved: 1303 in 662 posts
Joined: Aug 2015
Reputation: 20
#1
Aug 19, 2015, 06:44 AM
Suggestion for <in-game.>

In detail, explain your suggestion:

Simply put, just a /roll command from 1-100 for those who wish to add a bit of flavor to their RPs.

Why should this be implemented?

For those wanting to add more detail to their RPs its often times not exactly easy to decide who does what in say a fist fight.


If i attempt to grab ones arm to gain the upperhand, how do we decide who actualy pulls it off?

Often times both want theirs to succeed but choseing isnt exactly easy, with this just /roll and essentialy have it decided for you, depending on how much higher the roll decides just how successfull the action was.

This would be optional and meerly there for those who want to make use of it.

Me being talked to by an officer about my improperly parked car, that is also a getaway vehicle, i ask the officer if hes willing to go along with a more detailed Roll RP, he agrees.

[me=BlackDog]attempts to kick the officer in the balls[/me]
/roll (86)
Officer rolls to avoid /roll (15)

In this case he just got sacked and has no ground to attempt a counter as his roll was so much lower and since he agreed to go along with it, would RP accordingly, adding a bit of flavor to the situation for those involved.

Of course if the roll's were reversed, good chance he could now counter the attack and the RP would move in an entirely different direction where neither party is sure how it will end, but that in the end the results we're unexpected, but fair
[Image: 48d63884162a5acbea739f54e3909f3c.jpg]
(This post was last modified: Aug 19, 2015, 06:48 AM by BlackDog.)
Joey Skylynx radio_button_checked
Member
Membership
Posts: 137
Threads: 24
Likes Given: 0
Likes Recieved: 5 in 2 posts
Joined: Aug 2015
Reputation: 0
#2
Aug 19, 2015, 06:45 AM
Do it, and do it now.
+support
Laizel radio_button_checked
User
Registered User
Posts: 5
Threads: 2
Likes Given: 0
Likes Recieved: 0 in 0 posts
Joined: Aug 2015
Reputation: 0
#3
Aug 19, 2015, 07:03 AM
+1
[Image: 76561198045052544.png]
Doodleh radio_button_checked
Member
Membership
Posts: 435
Threads: 28
Likes Given: 17
Likes Recieved: 206 in 93 posts
Joined: Aug 2015
Reputation: 9
#4
Aug 19, 2015, 12:13 PM
This would be a great addition.
[Image: U0M0AXF.png]
Lord Octagon radio_button_checked
"Octagon letting out his inner priest" ~ Monty
Membership
Posts: 2,120
Threads: 165
Likes Given: 1158
Likes Recieved: 2050 in 818 posts
Joined: Aug 2015
Reputation: 29
#5
Aug 19, 2015, 12:19 PM
[move]
[Image: sgk3r5.png]
[/move]
+Support
[Image: 2AYSd5b.png]

“I expect to die in bed, my successor will die in prison and his successor will die a martyr in the public square. His successor will pick up the shards of a ruined society and slowly help rebuild civilisation, as the Church has done so often in human history”  ~ His Eminence, Cardinal Francis George
Faustie radio_button_checked
Veteran
Veteran Member
Posts: 3,038
Threads: 305
Likes Given: 1050
Likes Recieved: 2419 in 844 posts
Joined: Aug 2015
Reputation: 25
#6
Aug 19, 2015, 02:30 PM
Approved.
<p><br></p>
GRiiM radio_button_checked
Member
Membership
Posts: 521
Threads: 37
Likes Given: 281
Likes Recieved: 439 in 216 posts
Joined: Aug 2015
Reputation: 5
#7
Aug 19, 2015, 02:44 PM
It would be a nice addition to be able to specify the range of your rolls for some casino/gambling RP (eg. Blackjack)
[Image: qqGXQQw.gif]
Jono radio_button_checked
something something i suppose
Veteran Member
Posts: 1,710
Threads: 98
Likes Given: 678
Likes Recieved: 1484 in 660 posts
Joined: Aug 2015
Reputation: 34
#8
Aug 19, 2015, 02:51 PM
Following the WoW system would be nice.

You'd also have to distinguish the color from that of /its etc, as scripts could be set up easily enough.

Rule Britannia and that.

[Image: Fyew3LC.png]
[Image: avatar1524603_20.gif]
Vedette radio_button_checked
Member
Membership
Posts: 369
Threads: 8
Likes Given: 0
Likes Recieved: 6 in 6 posts
Joined: Aug 2015
Reputation: 0
#9
Aug 20, 2015, 03:05 PM
+Support
Loaf radio_button_checked
Princeps Lenonum
Membership
Posts: 97
Threads: 18
Likes Given: 31
Likes Recieved: 120 in 50 posts
Joined: Aug 2015
Reputation: 4
#10
Aug 20, 2015, 08:34 PM
Why not make it so you can change the number that it is out of, and the multiple it could be of? For example, roll a d20, /roll 1d20.

+support

[Image: 1401cc1c09278a4f45fe8ad8a397a2e6.png]
i'm a rep whore, give it to me
Spai radio_button_checked
Veteran
Veteran Member
Posts: 75
Threads: 6
Likes Given: 2
Likes Recieved: 44 in 26 posts
Joined: Aug 2015
Reputation: 9
#11
Aug 24, 2015, 01:04 AM
Got bored while sitting around on holiday, so here is a dice system for you guys.

Features two console commands "rtd" and "rtd_last" where the "_last" variant shows your previous roll exactly as last ( there is a clear warning stating it was last roll so ya know can't be used later on by others to cheat and such). Uses the Player Metatable so looks pretty clean when used in other scripts simple "PlayerObject:RollDice(Min, Max, #Dice)".

You are also able to specify the minimum, maximum and no. Of dice to be used on the roll ( all results are printed out, will probably expand when I get back to have multiple different sized "dice" used for different roles e.g. 2 d20 1 d23 3 d100 or something similar)

Cool down is also implemented to prevent spamming but there is no visual indicator that you're on cool down, though it's only 1 second so it's not a huge problem. Anyways onto code etc.

https://hastebin.com/epewudileg.lua link to the syntax highlighted version

Code:
-- Created by Spy (steamcommuntiy.com/id/Snappey)

if SERVER then

    util.AddNetworkString("PlayerRolled")
    util.AddNetworkString("GetLastRoll")
    
    local function PackageResult(tbl)
    local str = "" -- so we cant add other strings to it
        for k,v in pairs(tbl) do
            str = str .. "[ Dice #"..k.."] Rolled " .. v.res .. " (min: " .. v.min ..", max: " .. v.max..") /n" -- newline maybe idk
        end
        return str
    end
    
    local function GetNearbyPlayers(pos)
        local tbl = {}
        for k,v in pairs(ents.FindInSphere(pos, 240)) do -- Think 240 is distance of talking
            if !v:IsPlayer() then return end
            table.insert(tbl, v)
        end
        return tbl
    end
    
    
    local meta = FindMetaTable("Player")
    
    function meta:RollDice(min,max,l)
    self.LastRoll = {} -- reset last roll
        if l == nil then l = 1 end -- incase they dont give a third arg
        for i=1, l do
            self.LastRoll[i] = {res = math.random(min, max), min = min, max = max}
        end
        return self.LastRoll
    end

    concommand.Add("rtd", function(ply,cmd,args)
        if ply.DiceCooldown == nil then ply.DiceCooldown = 0 end -- that should prevent a nil index i believe
        if CurTime() > ply.DiceCooldown + 1 then -- Cooldown to stop people spamming it just change the number
            local str = PackageTable(ply:RollDice(args[1], args[2], args[3]))
            net.Start("PlayerRolled")
                net.WriteString(str)
            net.Send(GetNearbyPlayers(ply:GetPos()))
            ply.DiceCooldown = CurTime()
        else
            -- tell them there is a cooldown
        end
    end)
    
    concommand.Add("rtd_last", function(ply,cmd,args)
        if ply.DiceCooldown == nil then ply.DiceCooldown = 0 end -- same as above
        if CurTime() > ply.DiceCooldown + 1 then -- probably an easy way to simplify this to ome command but whatever
            local str = PackageTable(ply.LastRoll)
            net.Start("GetLastRoll")
                net.WriteString(str)
            net.Send(GetNearbyPlayers(ply:GetPos()))
            ply.DiceCooldown = CurTime()
        else
            -- tell them there is a cooldown
        end
    end)

else

    net.Receive("PlayerRolled", function()
        chat.AddText(net.ReadString()) -- idk how you want it prefixed etc.
        -- iirc last time i used chat.AddText colours just defaulted to bland yellow probs a gamemkde thimg
    end)
    
    net.Receive("GetLastRoll", function()
        chat.AddText("[LAST ROLL] " .. net.ReadString())
    end)
    
end

There is all the code that's used.

Now how to use in its current state, afaik you guys use the inbuilt plugin system I can't remember all the needed functions for that shit so you know here it is in normal form shove it into lua/autorun for the curious who'd like to try it.

How the player can use it is through the console as idk how your chat command system works and there is no need for me to add another not needed hook to your guys GM.

Input: rtd 1 100 5
Rolls 5 dies with the range of 1-100
Arg 1: minimum range
Arg 2: maximum range
Arg 3: amount of times to roll

Output: [Dice #1] Rolled 45 (min: 1, max: 100) and so on for each dice roll thereafter, repeated 5 times in our case

In hind sight there should be a check to ensure that arg1 is smaller than arg2 or some system that switches them around if need be, but cbf to do that now idk if it'll error or not it might be clever itself.

Improvements / changes will no doubt be needed as I have wrote this completely on my phone with no testing or documentation available. Should be fun though might be a small error here and there whatever nothing impossible to fix. Point is general logic and system has been implemented.

One major thing required can't remember if I mentioned it or not you guys probably want to make your own chat commands for it.

Pretty sure that's everything, sorry if  the post is reaaaallly long here is a TLDR

I created a basic roll system on my phone tis completely untested however should work fine after reading over a couple of times. You guys want to make your own chat commands as well.

Thanks, Spy  Smile

Joey Skylynx radio_button_checked
Member
Membership
Posts: 137
Threads: 24
Likes Given: 0
Likes Recieved: 5 in 2 posts
Joined: Aug 2015
Reputation: 0
#12
Aug 24, 2015, 11:52 PM
Welp, seems like we have an RTD system now.
Spai radio_button_checked
Veteran
Veteran Member
Posts: 75
Threads: 6
Likes Given: 2
Likes Recieved: 44 in 26 posts
Joined: Aug 2015
Reputation: 9
#13
Aug 25, 2015, 12:28 AM
Alright two things I'd just remembered that literally anyone with a shred of experience in Lua can fix:

1. You can currently go rtd 1 2 100000

You now have chat spammed and or server frozen and or net library refusing to send a string that large

Just limit to 5 I think Joey suggested that was a fine amount

2. You can't actually see who rolled he dice, oversight by me thought I designed it with that in mind turns out I didn't.

In the net.WriteString section add the players name to the start.

Ez fixes sorry for the bugs Big Grin
(This post was last modified: Aug 25, 2015, 12:33 AM by Spai.)
Rayts5 radio_button_checked
User
Registered User
Posts: 40
Threads: 1
Likes Given: 0
Likes Recieved: 4 in 4 posts
Joined: Aug 2015
Reputation: 0
#14
Aug 26, 2015, 03:30 PM
... What? Why are you utilizing two network variables for this? It does not give sense any sense, you are making the server handle both net.Receive and net.Start lol.

Simply make 1 (or 2 if you want to) concommands on the server-side and handle the rolling and such from there. There is absolutley no need to store a network variable on the player, just store a variable on the player instead.

Note, careful on your variables.
local str = PackageTable(ply:RollDice(args[1], args[2], args[3]))
net.WriteString(str)

Is the same as

net.WriteString(PackageTable(ply:RollDice(args[1], args[2], args[3])))

I know that the above looks better since you store a string, but you are performing 1 extra unnecessary operation.

Also, in your GetNearbyPlayers function, just store 1 table instead before the function, otherwise you will keep adding tables in the stack which is generally a bad idea (unless you want it to overflow lol, I do not believe Lua had a garbage collector). At start, clear the table and then add the players to the table.
(This post was last modified: Aug 26, 2015, 03:37 PM by Rayts5.)
Voluptious radio_button_checked
Veteran
Veteran Member
Posts: 1,122
Threads: 50
Likes Given: 301
Likes Recieved: 462 in 215 posts
Joined: Aug 2015
Reputation: 10
#15
Aug 26, 2015, 03:36 PM
(Aug 26, 2015, 03:30 PM)Rayts5 link Wrote: Note, careful on your variables.
local str = PackageTable(ply:RollDice(args[1], args[2], args[3]))
net.WriteString(str)

Is the same as

net.WriteString(PackageTable(ply:RollDice(args[1], args[2], args[3])))

I know that the above looks better since you store a string, but you are performing 1 extra unnecessary operation.

Its easier to read and debug if you do it this way, I do things like this aswell
[Image: nrNF2MT.png]

[Image: khZmsDz.png]
Closed 




Users browsing this thread: 1 Guest(s)