Skocz do zawartości

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.
  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Zdjęcie

Save by nick


  • Nie możesz napisać tematu
  • Zaloguj się, aby dodać odpowiedź
2 odpowiedzi w tym temacie

#1 StrikerRus

    Początkujący

  • Użytkownik

Reputacja: 1
Nowy

  • Postów:14
  • Lokalizacja:Moskow / New York
Offline

Napisano 03.01.2012 03:38

Hey !

Can someone make this plugin to save by nick, not by steamid.


#include < amxmodx >
#include < amxmisc >
#include < csx >
#include < nvault >
#include < cstrike >

new const g_iLevelMinKills[ ] =
{
0,
3,
6,
9
};

const LEVELS = sizeof( g_iLevelMinKills );

new const g_szLevelName[ LEVELS ][ ] =
{
"Newbie",
"Semi-Pro",
"Pro",
"Veteran"
};

#define MAX_PLAYERS 32

new g_iKills[ MAX_PLAYERS + 1 ];
new g_iLevel[ MAX_PLAYERS + 1 ];

new g_hVault;

new g_iMsgID_SayText;

new g_iAdminChatFlag = ADMIN_ALL; // Do not edit this!

public plugin_init( )
{
register_plugin( "Kills Counter", "0.0.1", "Exolent" );

register_clcmd( "say", "CmdSay" );
register_clcmd( "say_team", "CmdSayTeam" );

g_hVault = nvault_open( "KillsCounter" );

g_iMsgID_SayText = get_user_msgid( "SayText" );

new szCommand[ 32 ], iFlags;
for( new i = 0; get_concmd( i, szCommand, charsmax( szCommand ), iFlags, "", 0, 0, -1 ); i++ )
{
if( equal( szCommand, "amx_chat" ) )
{
g_iAdminChatFlag = iFlags;
break;
}
}
}

public plugin_end( )
{
nvault_close( g_hVault );
}

public client_authorized( iPlayer )
{
new szSteamID[ 35 ];
get_user_authid( iPlayer, szSteamID, charsmax( szSteamID ) );

new iKills;
if( ( iKills = nvault_get( g_hVault, szSteamID ) ) )
{
g_iKills[ iPlayer ] = iKills;
g_iLevel[ iPlayer ] = GetLevel( iKills );
}
}

public client_disconnect( iPlayer )
{
new szSteamID[ 35 ];
get_user_authid( iPlayer, szSteamID, charsmax( szSteamID ) );

new szKills[ 16 ];
num_to_str( g_iKills[ iPlayer ], szKills, charsmax( szKills ) );

nvault_set( g_hVault, szSteamID, szKills );

g_iKills[ iPlayer ] = g_iLevel[ iPlayer ] = 0;
}

public client_death( iKiller, iVictim, iWeapon, iHitPlace, bTK )
{
if( !bTK && iKiller != iVictim && iWeapon != CSW_C4 )
{
g_iLevel[ iKiller ] = GetLevel( ++g_iKills[ iKiller ] );
}
}

public CmdSay( iPlayer )
{
if( !is_user_connected( iPlayer ) )
{
return PLUGIN_HANDLED_MAIN;
}

new szArgs[ 194 ];

if( !IsValidMessage( iPlayer, false, szArgs, charsmax( szArgs ) ) )
{
return PLUGIN_HANDLED_MAIN;
}

new iAlive = is_user_alive( iPlayer );
new CsTeams:iTeam = cs_get_user_team( iPlayer );

new iPlayers[ 32 ], iNum;
get_players( iPlayers, iNum );

new szName[ 32 ];
get_user_name( iPlayer, szName, charsmax( szName ) );

new const szPrefixes[ 2 ][ CsTeams ][ ] =
{
{
"^1*DEAD*",
"^1*DEAD*",
"^1*DEAD*",
"^1*SPEC*"
},
{
"",
"",
"",
""
}
};

new szMessage[ 192 ];
formatex( szMessage, charsmax( szMessage ), "%s^4 [%s]^3 %s^1 :  %s", szPrefixes[ iAlive ][ iTeam ], g_szLevelName[ g_iLevel[ iPlayer ] ], szName, szArgs );

new iTarget;
for( new i = 0; i < iNum; i++ )
{
iTarget = iPlayers[ i ];

if( iTarget == iPlayer || ( iAlive || is_user_connected( iTarget ) ) && is_user_alive( iTarget ) == iAlive )
{
message_begin( MSG_ONE_UNRELIABLE, g_iMsgID_SayText, _, iTarget );
write_byte( iPlayer );
write_string( szMessage );
message_end( );
}
}

return PLUGIN_HANDLED_MAIN;
}

public CmdSayTeam( iPlayer )
{
if( !is_user_connected( iPlayer ) )
{
return PLUGIN_HANDLED_MAIN;
}

new szArgs[ 194 ];

if( !IsValidMessage( iPlayer, true, szArgs, charsmax( szArgs ) ) )
{
return PLUGIN_HANDLED_MAIN;
}

new iAlive = is_user_alive( iPlayer );
new CsTeams:iTeam = cs_get_user_team( iPlayer );

new iPlayers[ 32 ], iNum;
get_players( iPlayers, iNum );

new szName[ 32 ];
get_user_name( iPlayer, szName, charsmax( szName ) );

new const szPrefixes[ 2 ][ CsTeams ][ ] =
{
{
"(Spectator)",
"*DEAD*(Terrorist)",
"*DEAD*(Counter-Terrorist)",
"(Spectator)"
},
{
"(Spectator)",
"(Terrorist)",
"(Counter-Terrorist)",
"(Spectator)"
}
};

new szMessage[ 192 ];
formatex( szMessage, charsmax( szMessage ), "^1%s^4 [%s]^3 %s^1 :  %s", szPrefixes[ iAlive ][ iTeam ], g_szLevelName[ g_iLevel[ iPlayer ] ], szName, szArgs );

for( new i = 0, iTeammate; i < iNum; i++ )
{
iTeammate = iPlayers[ i ];

if( iTeammate == iPlayer || ( iAlive || is_user_connected( iTeammate ) ) && is_user_alive( iTeammate ) == iAlive && cs_get_user_team( iTeammate ) == iTeam )
{
message_begin( MSG_ONE_UNRELIABLE, g_iMsgID_SayText, _, iTeammate );
write_byte( iPlayer );
write_string( szMessage );
message_end( );
}
}

return PLUGIN_HANDLED_MAIN;
}

bool:IsValidMessage( iPlayer, bool:bTeamSay, szMessage[ ], iLen )
{
read_args( szMessage, iLen );
remove_quotes( szMessage );

new iPos, cChar, i;
while( ( cChar = szMessage[ iPos++ ] ) == '@' )
{
i++;
}

if( ( bTeamSay ? ( i == 1 ) : ( 1 <= i <= 3 ) ) && !access( iPlayer, g_iAdminChatFlag ) )
{
return false;
}

while( 0 <= ( cChar = szMessage[ iPos++ ] ) <= 255 )
{
if( cChar != ' ' && cChar != '%' )
{
return true;
}
}

return false;
}

GetLevel( iKills )
{
for( new i = LEVELS - 1; i >= 0; i-- )
{
if( iKills >= g_iLevelMinKills[ i ] )
{
return i;
}
}

return 0;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/

Thanks a lot !

Użytkownik StrikerRus edytował ten post 03.01.2012 03:39

  • +
  • -
  • 0

#2 StrikerRus

    Początkujący

  • Autor tematu
  • Użytkownik

Reputacja: 1
Nowy

  • Postów:14
  • Lokalizacja:Moskow / New York
Offline

Napisano 17.02.2012 21:49

Buump.
  • +
  • -
  • 0

#3 speedkill

    Godlike

  • Przyjaciel

Reputacja: 1 592
Godlike

  • Postów:2 733
  • GG:
  • Steam:steam
  • Imię:Michał
  • Lokalizacja:Prudnik
Offline

Napisano 19.02.2012 19:01

Find
get_user_authid( iPlayer, szSteamID, charsmax( szSteamID ));
replace with
get_user_name(iPlayer, szSteamID, charsmax( szSteamID ));
And test ;)

  • +
  • -
  • 0

If you can dream it, you can do it.





Użytkownicy przeglądający ten temat: 0

0 użytkowników, 0 gości, 0 anonimowych