16/11/2020, 02:44 AM
(Última modificación: 16/11/2020, 02:45 AM por wicho. Edited 1 time in total.)
hola todos, encontre este codigo de manu que hace que cuando un jugador escriba /votekill le sale un menu con todos los jugadores y cuando selecciona un nombre a todos los jugadores les sale que si quieren matar a ese jugador si la mayoria vota que si lo mata y si es lo contrario no lo mata, lo que quiero hacer es que cuando uno escriba /votekill les salga a todos los jugadores vivos un menu con todos los nombres de los jugadores vivos del servidor y que voten a quien quiere matar el jugador que reciba mas votos lo mata, esto es porque quiero hacer un modo de among us, alguien me podria ayudar porfavor? ... gracias antemano
este es el codigo:
este es el codigo:
Código PHP:
#include <amxmodx>
#define SetPlayerBit(%1,%2) ( %1 |= ( 1 << ( %2 & 31 ) ) )
#define ClearPlayerBit(%1,%2) ( %1 &= ~( 1 << ( %2 & 31 ) ) )
#define GetPlayerBit(%1,%2) ( ( 1 <= %2 <= 32 ) && ( %1 & ( 1 << ( %2 & 31 ) ) ) )
enum _:Vote_Type {
VT_Accept,
VT_Reject
}
const MENU_KEYS = MENU_KEY_1|MENU_KEY_2;
new const g_szCountdown[ ][ ] = { "one","two","three","four","five","six","seven","eight","nine","ten" };
new g_iVoted,
g_iJudged,
g_iSayText,
g_iConnected,
g_iCountDown,
g_iSyncObject,
g_iMaxPlayers,
g_szVoted[ 32 ],
Float:g_fLastKill,
g_iPlayerVotes[ Vote_Type ];
public plugin_init( )
{
register_plugin( "Votekill", "1.0", "Manu" );
register_clcmd( "say /votekill", "CommandVotekill" );
register_menucmd( register_menuid( "Votekill Menu" ), MENU_KEYS, "VoteHandler" );
g_iSyncObject = CreateHudSyncObj( );
g_iMaxPlayers = get_maxplayers( );
g_iSayText = get_user_msgid( "SayText" );
}
/* ===================================================
* [ Tasks ]
* ==================================================== */
public DoCountdown( )
{
set_hudmessage( 85, 212, 255, -1.0, 0.8, 1, 2.0, 1.0 );
ShowSyncHudMsg( 0, g_iSyncObject, "[ Votekill ] La votacion finalizara en %d segundo(s)", g_iCountDown );
ShowVotekillMenu( 0 );
client_cmd( 0, "spk %s", g_szCountdown[ --g_iCountDown ] );
}
public EndVotekill( )
{
set_hudmessage( 85, 212, 255, -1.0, 0.8, 1, 2.0, 3.0 );
if( g_iPlayerVotes[ VT_Reject ] < g_iPlayerVotes[ VT_Accept ] )
{
new iId = GetUserIndex( g_iJudged );
if( GetPlayerBit( g_iConnected, iId ) )
{
user_kill( iId );
ShowSyncHudMsg( 0, g_iSyncObject, "Se obtuvieron votos suficientes^nEl jugador %s ha sido asesinado!", g_szVoted );
}
else
ShowSyncHudMsg( 0, g_iSyncObject, "El jugador %s se desconecto antes del castigo", g_szVoted );
}
else
ShowSyncHudMsg( 0, g_iSyncObject, "No se obtuvieron votos suficientes" );
}
/* ===================================================
* [ Client-related ]
* ==================================================== */
public client_putinserver( iId ) SetPlayerBit( g_iConnected, iId );
public client_disconnect( iId ) ClearPlayerBit( g_iConnected, iId );
public CommandVotekill( iId )
{
if( g_fLastKill < get_gametime( ) )
{
if( get_playersnum( ) >= 3 )
{
static iMenu, iPlayer, szData[ 8 ], szName[ 16 ]; iMenu = menu_create( "\wLista de jugadores", "VotekillHandler" );
for( iPlayer = 1; iPlayer <= g_iMaxPlayers; iPlayer++ )
{
if( !GetPlayerBit( g_iConnected, iPlayer ) || ( get_user_flags( iPlayer ) & ADMIN_IMMUNITY ) )
continue;
get_user_name( iPlayer, szName, charsmax( szName ) );
formatex( szData, charsmax( szData ), "%d %d", iPlayer, get_user_userid( iPlayer ) );
menu_additem( iMenu, szName, szData );
}
menu_setprop( iMenu, MPROP_NEXTNAME, "Siguiente" );
menu_setprop( iMenu, MPROP_BACKNAME, "Anterior" );
menu_setprop( iMenu, MPROP_EXITNAME, "Cancelar" );
menu_display( iId, iMenu );
}
else
PrintColor( iId,"^x04[Votekill]^x01 Debe haber al menos tres jugadores para iniciar una votacion." );
}
else
PrintColor( iId,"^x04[Votekill]^x01 Quedan^x04 %d^x01 segundos restantes antes de poder iniciar otro votekill.",floatround( g_fLastKill - get_gametime( ) ) );
return PLUGIN_HANDLED;
}
public VotekillHandler( iId, iMenu, iItem )
{
if( iItem != MENU_EXIT )
{
static szData[ 8 ], szPlayer[ 4 ], iNum, iPlayer, szName[ 32 ];
menu_item_getinfo( iMenu, iItem, iNum, szData, charsmax( szData ), _, _, iNum );
strtok( szData, szPlayer, charsmax( szPlayer ), szData, charsmax( szData ), ' ', true );
if( GetPlayerBit( g_iConnected, ( iPlayer = str_to_num( szPlayer ) ) ) && ( get_user_userid( iPlayer ) == str_to_num( szData ) ) )
{
g_iJudged = get_user_userid( iPlayer );
get_user_name( iId, szName, charsmax( szName ) );
get_user_name( iPlayer, g_szVoted, charsmax( g_szVoted ) );
PrintColor( 0, "^x04[Votekill]^x01 El jugador^x04 %s^x01 ha iniciado un^x04 votekill^x01 contra^x04 %s^x01.", szName, g_szVoted );
StartVotekill( );
}
}
}
public VoteHandler( iId, iKey )
{
if( !GetPlayerBit( g_iConnected, iId ) || GetPlayerBit( g_iVoted, iId ) )
return PLUGIN_HANDLED;
g_iPlayerVotes[ iKey ]++;
SetPlayerBit( g_iVoted, iId );
client_cmd( iId,"spk buttons/lightswitch2.wav" );
ShowVotekillMenu( iId );
return PLUGIN_HANDLED;
}
/* ===================================================
* [ Other functions ]
* ==================================================== */
GetUserIndex( const iUserId )
{
for( new iPlayer = 1; iPlayer <= g_iMaxPlayers; iPlayer++ )
{
if( !GetPlayerBit( g_iConnected, iPlayer ) || ( get_user_userid( iPlayer ) != iUserId ) )
continue;
return iPlayer;
}
return 0;
}
StartVotekill( )
{
g_iCountDown = 10;
g_iPlayerVotes[ VT_Accept ] = 0;
g_iPlayerVotes[ VT_Reject ] = 0;
g_fLastKill = get_gametime( ) + 120.0;
for( new iPlayer = 1; iPlayer <= g_iMaxPlayers; iPlayer++ )
ClearPlayerBit( g_iVoted, iPlayer );
set_task( 1.0, "DoCountdown", .flags = "a", .repeat = 10 );
set_task( 12.0, "EndVotekill" );
}
ShowVotekillMenu( iId )
{
static szBuffer[ 256 ], iLen;
iLen = formatex( szBuffer, charsmax( szBuffer ), "Votar para asesinar a \y%s\w^n^n", g_szVoted );
iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "\r[1] \yAceptar \w[ Votos: \y%d \w]^n", g_iPlayerVotes[ VT_Accept ] );
iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "\r[2] \yRechazar \w[ Votos: \y%d \w]^n^n", g_iPlayerVotes[ VT_Reject ] );
iLen += formatex( szBuffer[ iLen ], charsmax( szBuffer ) - iLen, "\r[!] \wLa votacion termina en \y%d segundo(s)", g_iCountDown );
show_menu( iId, MENU_KEYS, szBuffer, 1, "Votekill Menu" );
return PLUGIN_HANDLED;
}
PrintColor( iId, szText[ ], any:... )
{
static szBuffer[ 192 ]; vformat( szBuffer, charsmax( szBuffer ), szText, 3 );
if( !iId )
{
message_begin( MSG_ALL, g_iSayText, _, iId );
write_byte( 1 );
write_string( szBuffer );
message_end( );
}
else
{
message_begin( MSG_ONE, g_iSayText, _, iId );
write_byte( iId );
write_string( szBuffer );
message_end( );
}
}