Raised This Month: $ Target: $400
 0% 

mapchooser_extended_1.4.1


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ferest
New Member
Join Date: Nov 2010
Old 06-08-2011 , 17:20   mapchooser_extended_1.4.1
Reply With Quote #1

Guys here is a question only mapchooser_extended_1.4.1

I want to change the map of votes well it is in the middle says here is an example screen
http://i063.radikal.ru/1106/52/da3bd8b1d13e.png

That is, I wanted to do so))
http://s43.radikal.ru/i101/1106/db/fe7b8380c394.png

But when someone votes obtained here such garbage that's how I fix it?
http://s013.radikal.ru/i325/1106/45/e364fef3af49.png

Ask how I did it?
I went to the folder sourcemod/scripting/mapchooser_extended/DisplayVoteProgress.sp

There found a line

Quote:
PrintHintTextToAll("%s", hintboxText);
and changed here on here is

Quote:
new Handle:hBuffer = StartMessageAll("KeyHintText");
BfWriteByte(hBuffer, 1);
BfWriteString(hBuffer, hintboxText);
EndMessage();
Here is what I got!

Quote:
#include <sourcemod>
#include <sdktools>
#include <sdktools_sound>

#pragma semicolon 1

#define ITEM_MAX_LENGTH 128
#define CLIENT_MAX_LENGTH 32

new g_PlayerVotes[MAXPLAYERS+1];

new Handle:g_Cvar_PrintVotes = INVALID_HANDLE;
new Handle:g_Cvar_ShowVotes = INVALID_HANDLE;
new Handle:g_VoteDuration = INVALID_HANDLE;
new Handle:g_AllowedVoters = INVALID_HANDLE;

new Handle:g_timer_ShowVotes = INVALID_HANDLE;

new g_VoteTimeStart2;

public OnPluginStart_DisplayVote()
{
LoadTranslations("common.phrases");
LoadTranslations("basetriggers.phrases");

g_Cvar_PrintVotes = CreateConVar("sm_mapvote_printvotes", "0", "Should the option that a player vote on get printed (1 - yes print player votes, 0 - don't print).", _, true, 0.0, true, 1.0);
g_Cvar_ShowVotes = CreateConVar("sm_mapvote_showvotes", "3", "How many vote options the hint box should show. 0 will disable it", _, true, 0.0, true, 5.0);

g_VoteDuration = FindConVar("sm_mapvote_voteduration");

g_AllowedVoters = CreateArray(1);
}

public OnMapEnd_DisplayVote()
{
g_timer_ShowVotes = INVALID_HANDLE; // Being closed on mapchange: TIMER_FLAG_NO_MAPCHANGE
}

public OnClientDisconnect_DisplayVote(client)
{
// reset the clients vote
g_PlayerVotes[client] = -1;

// if client is allowed to vote then remove him (to fix max number of voters)
new index = FindValueInArray(g_AllowedVoters, client);
if (index > -1)
{
RemoveFromArray(g_AllowedVoters, index);
}

// if we display vote then update it
if (GetConVarBool(g_Cvar_ShowVotes) && g_timer_ShowVotes != INVALID_HANDLE)
{
TriggerTimer(g_timer_ShowVotes);
}
}

public VoteAction(Handle:menu, MenuAction:action, param1, param2)
{
switch(action)
{
case MenuAction_VoteStart:
{
VoteStarted();
if (GetConVarBool(g_Cvar_ShowVotes))
{
if (g_timer_ShowVotes == INVALID_HANDLE)
{
g_timer_ShowVotes = CreateTimer(0.95, ShowVoteProgress, menu, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
}
TriggerTimer(g_timer_ShowVotes);
}
}

case MenuAction_Select:
{
if (GetConVarBool(g_Cvar_PrintVotes))
{
decl String:name[CLIENT_MAX_LENGTH], Stringption[ITEM_MAX_LENGTH];
GetClientName(param1, name, sizeof(name));
GetMenuItem(menu, param2, option, 0, _, option, sizeof(option));

PrintToChatAll("[SM] %t", "Vote Select", name, option);
}
if (GetConVarBool(g_Cvar_ShowVotes))
{
g_PlayerVotes[param1] = param2;
TriggerTimer(g_timer_ShowVotes);
}
}
}
}

VoteStarted()
{
// reset all votes
for (new i = 0; i <= MAXPLAYERS ; i++)
{
g_PlayerVotes[i] = -1;
}

// set clients allowed to vote
ClearArray(g_AllowedVoters);
for (new i = GetMaxClients(); i > 0; i--)
if (IsClientInGame(i) && !IsFakeClient(i))
PushArrayCell(g_AllowedVoters, i);

g_VoteTimeStart2 = GetTime();
}

public VoteEnded(const String:voteEndInfo[])
{
if (g_timer_ShowVotes != INVALID_HANDLE)
{
KillTimer(g_timer_ShowVotes);
g_timer_ShowVotes = INVALID_HANDLE;
}
PrintHintTextToAll(voteEndInfo);
}

/**
* Show/updates the hintbox with current vote status
* ex.
*
Next map: (3/7) - 17 s
1. de_dust2 - 2
2. de_nuke -1
*/
public Action:ShowVoteProgress(Handle:timer, Handle:menu)
{
if (menu == INVALID_HANDLE) return Plugin_Continue;

decl String:hintboxText[1024];
decl Stringption[ITEM_MAX_LENGTH];
decl String:formatBuffer[256];
decl String:translation_buffer[256];

// <title> - <timeleft>
//GetMenuTitle(menu, hintboxText, sizeof(hintboxText));
Format(translation_buffer, sizeof(translation_buffer),"%T", "Number Of Votes", LANG_SERVER);
Format(hintboxText, sizeof(hintboxText), "%s (%i/%i) - %iсек", translation_buffer, GetNrReceivedVotes(), GetArraySize(g_AllowedVoters), VoteTimeRemaining());

// <X>. <option>
new nrItems = GetMenuItemCount(menu);
new itemIndex[nrItems];
new itemVotes[nrItems];
GetItemsSortedByVotes(itemIndex, itemVotes, nrItems);

new displayNrOptions = GetConVarInt(g_Cvar_ShowVotes) >= nrItems ? nrItems : GetConVarInt(g_Cvar_ShowVotes);
for (new i = 1; i <= displayNrOptions; i++)
{
if (itemVotes[i-1] > 0)
{
GetMenuItem(menu, itemIndex[i-1], option, 0, _, option, sizeof(option));

new percent = ((itemVotes[i-1] * 100) / GetNrReceivedVotes());

Format(formatBuffer, sizeof(formatBuffer), "%T", "Vote Progress", LANG_SERVER, i, option, itemVotes[i-1], percent);
StrCat(hintboxText, sizeof(hintboxText), formatBuffer);
}
else
break;
}
new Handle:hBuffer = StartMessageAll("KeyHintText");
BfWriteByte(hBuffer, 1);
BfWriteString(hBuffer, hintboxText);
EndMessage();

return Plugin_Continue;
}

/**
* @return timeleft (remaining) of vote.
*/
VoteTimeRemaining()
{
new remainingTime = g_VoteTimeStart2 + GetConVarInt(g_VoteDuration) - GetTime();
if (remainingTime < 0)
{
return 0;
}
else
{
return remainingTime;
}
}

/**
* Returns a list of all items (their index) and number of votes on each, ordered by nr of received votes in descending order
*/
GetItemsSortedByVotes(itemIndex[], itemVotes[], nrOfItems)
{
// Get nr of votes on each item
new votesOnItem[nrOfItems+1]; // simplify by increasing by one and having index 0 being "not voted"
for (new i = 0; i <= MAXPLAYERS; i++)
{
votesOnItem[g_PlayerVotes[i]+1]++;
}

// simple insertion sort
new mostVotes, index;
for (new i = 0; i < nrOfItems; i++)
{
mostVotes = -1;
for (new j = 1; j <= nrOfItems; j++)
{
if (votesOnItem[j] > mostVotes)
{
mostVotes = votesOnItem[j];
index = j;
}
}

itemIndex[i] = index-1;
itemVotes[i] = mostVotes;

// make sure it will not be selected again
votesOnItem[index] = -1;
}
}

/**
* @return return the total nr of votes received
*/
GetNrReceivedVotes()
{
new nrVotes = 0;
for (new i = GetMaxClients(); i > 0; i--)
{
if(g_PlayerVotes[i] > -1)
nrVotes++;
}
return nrVotes;
}


where is the jamb? please help me make the right!


Guys and you can clean it up a string of css well, when you're in a shoot pishit type
Bro attacked a teammate

You can remove it as something ?????

Last edited by ferest; 06-09-2011 at 06:39.
ferest is offline
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 02-15-2013 , 17:29   Re: mapchooser_extended_1.4.1
Reply With Quote #2

I confrim this error if you try to put a single % in your string :/ and only with KeyHintText
zipcore is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 02-16-2013 , 01:05   Re: mapchooser_extended_1.4.1
Reply With Quote #3

Quote:
Originally Posted by zipcore View Post
I confrim this error if you try to put a single % in your string :/ and only with KeyHintText
You... know this thread was from 2 years ago?
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 02-21-2013 , 18:08   Re: mapchooser_extended_1.4.1
Reply With Quote #4

better than creating new thread

Last edited by zipcore; 02-21-2013 at 18:10.
zipcore is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:24.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode