3. feladat
Csak a hibákat kell PM-ben elküldeni.
// ########################################################################## //
// //
// * Author: ZeRo //
// * Version: 1.0 //
// * Started: 2010/03/18 //
// * Relased: 2010/03/18 //
// //
// ########################################################################## //
#include < a_samp >
#define COLOR_GREEN 0x00FF00AA
#define COLOR_RED 0xFF0000AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_CRANGE 0xFF9900AA
#define DIALOG_VOTEKICK 5638
#define VOTENUM_TO_KICK 3
static szName[ MAX_PLAYER_NAME ];
static iPlayerVotes[MAX_PLAYERS ];
static iTotalVotes;
static iVoteAbort;
static bool: iVoted[ MAX_PLAYERS ];
public AbortVote( );
public OnFilterScriptInit( ) {
print( \"\\n>> Z - Vote Script by ZeRo <<\" );
print( \">> -- | ON | -- <<\\n\" );
return 1;
}
public OnFilterScriptExit( ) {
print( \"\\n>> Z - Vote Script by ZeRo <<\" );
print( \">> -- | OFF | -- <<\\n\" );
return 1;
}
public OnPlayerCommandText( playerid, cmdtext[ ] ) {
static szStr[ 812 ];
if( strcmp( \"/votekick\", cmdtext, true ) == 0 ) {
if( iVoted[ playerid ] ) {
SendClientMessage( playerid, COLOR_RED, \"Már szavaztál! Várj egy kicsit!\" );
} else {
if( !iTotalVotes ) {
iVoteAbort = SetTimer( \"AbortVote\", 60000 * 2, false );
for( new index = 0; index < MAX_PLAYERS; ++index ) {
if( IsPlayerConnected( index ) && !IsPlayerNPC( index ) ) {
GetPlayerName( index, szName, sizeof szName );
if( !szStr[ 0 ] ) {
format( szStr, sizeof szStr, \"%s\", szName );
} else {
format( szStr, sizeof szStr, \"%s\\n%s\", szStr, szName );
}
}
}
ShowPlayerDialog( playerid, DIALOG_VCTEKICK, DIALOG_STYLE_LIST, \"Kit akarsz kirúgni?\", szStr, \"Igen\", \"Kilép\" );
format( szStr, sizeof szStr, \"%c\", EOS);
}
return 1;
}
return 0;
}
public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) {
static szRes[ 128 ], szNameEx[ MAX_PLAYER_NAME ];
if( dialogid == DIALOG_VOTEKICK ) {
if( !response ) {
SendClientMessage( playerid, COLOR_RED, \">> A szavazat nem lett elküldve! <<\" );
} else {
iTotalVotes;
iPlayerVotes[ listitem ];
iVoted[ playerid ] = true;
GetPlayerName( listitem, szName, sizeof szName );
GetPlayerName( playerid, szNameEx, sizeof szNameEx );
if( iPlayerVotes[ listitem ] < VOTENUM_TO_KICK ) {
format( szRes, sizeof szRes, \"%s szavazott %s kirúgására! Összesen: %i!\", szNameEx, szName, iPlayerVotes[ listitem ] );
} else {
format( szRes, sizeof szRes, \"%s szavazott %s kirúgására! Szavazat elfogadva!\", szNameEx, szName, iPlayerVotes[ listitem ] );
Kick( listitem )
KillTimer( iVoteAbort );
iTotalVotes = 0;
iVoted[ playerid ] = false;
for( new index = 0; index < MAX_PLAYERS; ++index ) {
if( IsPlayerConnected( index ) && !IsPlayerNPC( index ) ) {
iPlayerVotes[ index ] = 0;
}
}
}
SendClientMessageToAl( COLOR_YELLOW, szRes )
}
}
return 1;
}
public AbortVote( ) {
static iHighestVoted;
for( new index = 0; index < MAX_PLAYERS; ++index ) {
if( IsPlayerConnected( index ) && !IsPlayerNPC( index ) ) {
if( iPlayerVotes[ index ] > iPlayerVotes[ iHighestVoted ] ) {
iHighestVoted = index;
}
}
}
if( iPlayerVotes[ iHighestVoted ] >= VOTENUM_TO_KICK ) return;
iTotalVotes = 0;
for( new index = 0; index < MAX_PLAYERS; ++index ) {
if( IsPlayerConnected( index ) && !IsPlayerNPC( index ) ) {
iPlayerVotes[ index ] = 0;
iVoted[ index ] = false;
}
}
SendClientMessageToAll( COLOR_ORANGE \">> A szavazás érvénytelen volt! Próbáld újra! <<\" );
}