-
Notifications
You must be signed in to change notification settings - Fork 9
Claude slop votetimedcivilize #192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
StrawWagen
wants to merge
7
commits into
master
Choose a base branch
from
votetimedcivilize
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
551b6db
Claude slop timedcivilize
StrawWagen 7904a82
Funnier
StrawWagen 211eeef
Fix stupid
StrawWagen fc36c65
Apply suggestions from code review
StrawWagen 333cfc8
Fix logic
StrawWagen 5c8cf3c
get rid of IF CLIENT IF SERVER stuff
StrawWagen e567d57
Cleanup + apply suggestions
StrawWagen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| -- Vote to civilize using ULX vote system | ||
| local PUNISHMENT = "timedcivilize" | ||
| local CATEGORY = "Fun" | ||
| local PERMANENT_EXPIRATION = -1 | ||
|
|
||
| if SERVER then | ||
| local function voteCivilizeDone( t, targetNick, targetSteamID, minutes, callingPly ) | ||
| local voteYesCount = t.results[1] or 0 | ||
| local voteNoCount = t.results[2] or 0 | ||
| local shouldCivilize = voteYesCount > 0 | ||
|
|
||
| if not shouldCivilize then | ||
| ulx.fancyLogAdmin( callingPly, "The populace has deemed the refinement of #s unworthy. Motion dismissed: #i in favor, #i opposed", targetNick, voteYesCount, voteNoCount ) | ||
| return | ||
| end | ||
|
StrawWagen marked this conversation as resolved.
Outdated
|
||
|
|
||
| -- Check if player is still on server | ||
| local targetPly = player.GetBySteamID64( targetSteamID ) | ||
| local targetStillOnServer = IsValid( targetPly ) | ||
| if not targetStillOnServer then | ||
| ulx.fancyLogAdmin( callingPly, "Though the populace voted to refine #s, the target has departed before civility could be imposed", targetNick ) | ||
| return | ||
| end | ||
|
|
||
| -- Get calling player's steam ID (or console if they disconnected) | ||
| local callerStillOnServer = IsValid( callingPly ) | ||
| local issuerSteamID = callerStillOnServer and callingPly:SteamID64() or "Console" | ||
|
|
||
| -- Calculate expiration time | ||
| local isPermanent = minutes == 0 | ||
| local expirationTime = isPermanent and PERMANENT_EXPIRATION or os.time() + ( minutes * 60 ) | ||
|
|
||
| -- Apply the punishment | ||
| TimedPunishments.Punish( targetSteamID, PUNISHMENT, expirationTime, issuerSteamID, "Voted civilized by players" ) | ||
|
|
||
| -- Log the result | ||
| local durationStr = isPermanent and "permanently" or ULib.secondsToStringTime( minutes * 60 ) | ||
| ulx.fancyLogAdmin( callingPly, "#s has been refined by democratic decree! Civility shall be enforced for #s. Vote: #i in favor, #i opposed", targetNick, durationStr, voteYesCount, voteNoCount ) | ||
|
StrawWagen marked this conversation as resolved.
Outdated
|
||
| end | ||
|
|
||
| function ulx.votetimedcivilize( callingPly, targetPly, minutes ) | ||
|
|
||
| -- Check if another vote is already in progress | ||
| local anotherVoteInProgress = ulx.voteInProgress | ||
| if anotherVoteInProgress then | ||
| ULib.tsayError( callingPly, "There is already a vote in progress. Please wait for the current one to end.", true ) | ||
| return | ||
| end | ||
|
|
||
| -- Format the duration for display | ||
| local isPermanent = minutes == 0 | ||
| local durationStr = isPermanent and "permanently" or ULib.secondsToStringTime( minutes * 60 ) | ||
|
|
||
| -- Build the vote title | ||
| local targetName = targetPly:Nick() | ||
| local voteTitle = "Civilize " .. targetName .. " for " .. durationStr .. "?" | ||
|
|
||
| -- Start the vote | ||
| local targetSteamID = targetPly:SteamID64() | ||
| ulx.doVote( voteTitle, { "Yes", "No" }, voteCivilizeDone, _, _, _, targetName, targetSteamID, minutes, callingPly ) | ||
|
StrawWagen marked this conversation as resolved.
Outdated
|
||
|
|
||
| -- Log the vote initiation | ||
| ulx.fancyLogAdmin( callingPly, "#A started a vote to civilize #T for #s", targetPly, durationStr ) | ||
| end | ||
|
StrawWagen marked this conversation as resolved.
Outdated
|
||
| end | ||
|
|
||
| -- Create the ULX command | ||
| local voteCmd = ulx.command( CATEGORY, "ulx votetimedcivilize", ulx.votetimedcivilize, "!votetimedcivilize" ) | ||
|
StrawWagen marked this conversation as resolved.
Outdated
|
||
|
|
||
| -- Add parameters | ||
| voteCmd:addParam{ type = ULib.cmds.PlayerArg } | ||
| voteCmd:addParam{ type = ULib.cmds.NumArg, hint = "minutes, 0 for perma", ULib.cmds.allowTimeString, ULib.cmds.optional, min = 0, default = 15 } | ||
|
|
||
| -- Configure access and help | ||
| voteCmd:defaultAccess( ULib.ACCESS_ADMIN ) | ||
| voteCmd:help( "Start a public vote to civilize a player" ) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.