Skip to content
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

Voting improvements (fixing my stuff) #15

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ void function FSV_CommandCallback_NextMap( entity player, array< string > args )
void function FSV_CommandCallback_Skip( entity player, array< string > args ) {
if( FSA_IsAdmin( player ) && args.len() >= 1 ) {
if( args[0].tolower() == "force" ) {
FSU_ChatBroadcast("%AMap skipped by admin!")
FSV_SkipMatch()
} else {
FSU_PrivateChatMessage( player, "You are admin. You can force skip: %H%Pskip force")
Expand Down Expand Up @@ -250,6 +251,7 @@ void function FSV_CommandCallback_Extend( entity player, array< string > args )
if( FSA_IsAdmin( player ) && args.len() >= 1 ) {
FSV_ExtendMatch( float( args[0].tointeger() ) )
FSU_PrivateChatMessage( player, "%SExtended match." )
FSU_ChatBroadcast("%AMap time extended by admin!")
return
}

Expand Down Expand Up @@ -290,7 +292,7 @@ void function FSV_ExtendThread(){
}
wait 1
foreach (entity player in GetPlayerArray()) {
NSCreateStatusMessageOnPlayer( player, FSV_TimerToMinutesAndSeconds(timer), extendVoters.len() + "/" + extendThreshold + "have voted to extend map time", "extend" )
NSCreateStatusMessageOnPlayer( player, FSV_TimerToMinutesAndSeconds(timer), extendVoters.len() + "/" + extendThreshold + " have voted to extend map time", "extend" )
}
}
if(GetConVarBool("FSV_ENABLE_CHATUI")){
Expand Down Expand Up @@ -418,8 +420,13 @@ void function FSV_CommandCallback_Kick( entity player, array<string> args) {
}

FSU_Print( targetName + " kicked by admin:" + player.GetPlayerName())
ServerCommand("kick " + target.GetPlayerName())
FSU_ChatBroadcast("%H"+player.GetPlayerName() + " %Nwas kicked by an admin.")
NSDisconnectPlayer(target, "You got kicked by admin")
FSU_ChatBroadcast("%H"+target.GetPlayerName() + " %Nwas kicked by an admin.")
if (targetUid in kickTable){
if( playersWithActiveVotes.find( kickTable[targetUid].voters[0] ) > -1 )
playersWithActiveVotes.remove( playersWithActiveVotes.find( kickTable[targetUid].voters[0] ) )
delete kickTable[targetUid]
}
return
}

Expand Down Expand Up @@ -477,12 +484,9 @@ void function FSV_CommandCallback_Kick( entity player, array<string> args) {
FSU_SaveArrayArrayToConVar("FSV_KICK_BLOCK", newKickedArray)
}

ServerCommand("kick " + player.GetPlayerName())
NSDisconnectPlayer(target, "You got kicked by vote")
if( playersWithActiveVotes.find( kickInfo.voters[0] ) > -1 )
playersWithActiveVotes.remove( playersWithActiveVotes.find( kickInfo.voters[0] ) )
if (targetUid in kickTable) {
delete kickTable[targetUid]
}
}
return
}
Expand All @@ -504,7 +508,7 @@ void function FSV_KickThread(string targetName, string targetUid){
}
wait 1
foreach (entity player in GetPlayerArray()) {
if( player.GetUID() != targetUid){
if(targetUid in kickTable && player.GetUID() != targetUid){
NSCreateStatusMessageOnPlayer( player, FSV_TimerToMinutesAndSeconds(timer), kickTable[targetUid].voters.len() + "/" + kickTable[targetUid].threshold + " have voted to kick " + targetName, "kick" + targetName )
}
}
Expand All @@ -517,7 +521,7 @@ void function FSV_KickThread(string targetName, string targetUid){
wait 5

// Timer and UI update loop
while(timer > 0 && kickTable[targetUid].voters.len() < kickTable[targetUid].threshold){
while(targetUid in kickTable && timer > 0 && kickTable[targetUid].voters.len() < kickTable[targetUid].threshold){
if(timer == nextUpdate){
if(GetConVarBool("FSV_ENABLE_RUI")){
foreach (entity player in GetPlayerArray()) {
Expand All @@ -537,41 +541,54 @@ void function FSV_KickThread(string targetName, string targetUid){
wait 1
}

// Announce results of vote
KickInfo kickInfo = kickTable[targetUid]
if(GetConVarBool("FSV_ENABLE_RUI")){
if (kickInfo.voters.len() >= kickInfo.threshold){
foreach ( entity player in GetPlayerArray() ){
NSSendAnnouncementMessageToPlayer( player, targetName + " has been kicked", "", <1,0,0>, 0, 1 )
if( targetUid in kickTable ){
// Announce results of vote
KickInfo kickInfo = kickTable[targetUid]
if(GetConVarBool("FSV_ENABLE_RUI")){
if (kickInfo.voters.len() >= kickInfo.threshold){
foreach ( entity player in GetPlayerArray() ){
NSSendAnnouncementMessageToPlayer( player, targetName + " has been kicked", "", <1,0,0>, 0, 1 )
}
wait 1
foreach (entity player in GetPlayerArray()) {
NSEditStatusMessageOnPlayer( player, "PASS", targetName + " has been kicked!", "kick" + targetName )
}
}
wait 1
foreach (entity player in GetPlayerArray()) {
NSEditStatusMessageOnPlayer( player, "PASS", targetName + " has been kicked!", "kick" + targetName )
else{
foreach (entity player in GetPlayerArray()) {
if( player.GetUID() != targetUid ){
NSEditStatusMessageOnPlayer( player, "FAIL", "Not enough votes to kick " + targetName + "!", "kick" + targetName )
}
}
}
}
else{
if (GetConVarBool("FSV_ENABLE_CHATUI") ){
if (kickInfo.voters.len() >= kickInfo.threshold){
FSU_ChatBroadcast("Final vote received! %H"+ targetName + " %Shas been kicked!")
}
else{
FSU_ChatBroadcast("%EThe vote to kick "+ targetName +" has failed! %NNot enough votes to kick.")
}
}
}else{
if(GetConVarBool("FSV_ENABLE_RUI")){
foreach (entity player in GetPlayerArray()) {
if( player.GetUID() != targetUid ){
NSEditStatusMessageOnPlayer( player, "FAIL", "Not enough votes to kick " + targetName + "!", "kick" + targetName )
NSEditStatusMessageOnPlayer( player, "ADMN", "Admin kicked " + targetName + "!", "kick" + targetName )
}
}
}
}
if (GetConVarBool("FSV_ENABLE_CHATUI") ){
if (kickInfo.voters.len() >= kickInfo.threshold){
FSU_ChatBroadcast("Final vote received! %H"+ targetName + " %Shas been kicked!")
}
else{
FSU_ChatBroadcast("%EThe vote to kick "+ targetName +" has failed! %NNot enough votes to kick.")
if (GetConVarBool("FSV_ENABLE_CHATUI") ){
FSU_ChatBroadcast("%SAdmin has kicked %H"+ targetName +"%S!")
}
}

// Reset everything
if (targetUid in kickTable){
if( playersWithActiveVotes.find( kickTable[targetUid].voters[0] ) > -1 )
playersWithActiveVotes.remove( playersWithActiveVotes.find( kickTable[targetUid].voters[0] ) )
delete kickTable[targetUid]
}
if( playersWithActiveVotes.find( kickInfo.voters[0] ) > -1 )
playersWithActiveVotes.remove( playersWithActiveVotes.find( kickInfo.voters[0] ) )
wait 10
if(GetConVarBool("FSV_ENABLE_RUI")){
foreach ( entity player in GetPlayerArray() ){
Expand Down