PHP- Kodu:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <hamsandwich>
#include <fakemeta>
#define PLUGIN "Freeze - Unfreeze"
#define VERSION "1.0"
#define AUTHOR "akcaliberkk"
new bool:gFrozen[33];
new pCvarAllowMouse, pCvarOnlyKnife, pCvarAllowJump
new Float: iAngles[ 33 ][ 3 ];
new fwPreThink;
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
pCvarAllowMouse = register_cvar( "af_allow_mouse" , "0" ); // 1 : allow move mouse ; 0 : not allow move mouse
pCvarOnlyKnife = register_cvar( "af_only_knife" , "1" ); // 1 : only allow knife ; 0 : allow all weapons
pCvarAllowJump = register_cvar( "af_allow_jump" , "0" )
register_concmd("amx_freeze","cmdFreeze",ADMIN_BAN)
register_concmd("amx_unfreeze","cmdUnFreeze",ADMIN_BAN)
register_event( "CurWeapon" , "eventCurWeapon" , "be" , "1=1" , "2!29" );
register_event( "DeathMsg" , "eventDeathMsg" , "a" );
register_logevent( "eventRoundEnd" , 2 , "1=Round_End" );
RegisterHam( Ham_Spawn , "player" , "Player_Spawn" , true );
RegisterHam( Ham_Player_Jump , "player" , "Player_Jump" , false );
}
public eventCurWeapon(id) {
if( is_user_alive( id ) ){
if( gFrozen[id] && get_pcvar_num( pCvarOnlyKnife ) ){
engclient_cmd( id , "weapon_knife" );
}
}
}
public eventDeathMsg() {
UnFreeze(read_data(2));
}
public eventRoundEnd() {
new iPlayers[ 32 ] , iNum , i , id;
get_players( iPlayers , iNum , "a" );
for( i = 0; i < iNum; i++ ) {
id = iPlayers[ i ];
if( gFrozen[id] ){
UnFreeze( id );
}
}
}
public Player_Jump( id ) {
if( gFrozen[id] && !get_pcvar_num( pCvarAllowJump ) ) {
return HAM_SUPERCEDE;
}
return HAM_IGNORED;
}
public Player_Spawn( id ){
if( is_user_alive( id ) ) {
if( gFrozen[id] ) {
UnFreeze( id );
}
}
}
public fwPlayerPreThink( id ) {
if( gFrozen[id] && !get_pcvar_num( pCvarAllowMouse ) ){
if( is_user_alive( id ) ) {
set_pev( id , pev_v_angle , iAngles[ id ] );
set_pev( id , pev_fixangle , 1 );
}
}
}
public cmdFreeze(id,level,cid) {
if(!cmd_access(id,level,cid,3)) return PLUGIN_HANDLED
new arg1[32],arg2[6];
new targetname[32], adminname[32];
read_argv(1,arg1,31)
read_argv(2,arg2,31)
get_user_name(id,adminname,31);
new sure = str_to_num(arg2);
if(sure < 0) sure = 0;
if(arg1[0] == '@') {
new players[32],inum;
if(equali(arg1[1],"T")) copy(arg1[1],31,"TERRORIST");
if(equali(arg1[1],"ALL")) get_players(players,inum)
else get_players(players,inum,"ae",arg1[1]);
if(!inum) {
console_print(id,"Girilen takimda oyuncu bulunamadi.");
return PLUGIN_HANDLED
}
new tmp;
for(new i;i<inum;i++) {
tmp = players[i];
if(gFrozen[tmp]) continue;
Freeze(tmp)
client_print(tmp,print_center,"DONDURULDUN");
}
new szSure[16];
if(!sure) copy(szSure,15,"");
else format(szSure,15," %d sn boyunca",sure);
if(equali(arg1[1],"all")) client_print(0,print_chat,"[AMXX] ADMIN %s: Tum oyunculari%s dondurdu.",adminname,szSure);
else client_print(0,print_chat,"[AMXX] ADMIN %s: %s takimindaki oyunculari%s dondurdu.",adminname,arg1[1],szSure);
set_task(float(sure),"TaskUnFreeze");
}
else {
new Uid = find_player("bhl",arg1);
if(!Uid) {
console_print(id,"Oyuncu bulunamadi !")
return PLUGIN_HANDLED
}
if(gFrozen[Uid]) {
console_print(id,"Oyuncu zaten donuk !")
return PLUGIN_HANDLED
}
new szSure[16];
if(!sure) copy(szSure,15,"");
else format(szSure,15," %d sn boyunca",sure);
get_user_name(Uid,targetname,31);
client_print(Uid,print_center,"DONDURULDUN");
client_print(0,print_chat,"[AMXX] ADMIN %s: %s adli oyuncuyu%s dondurdu.",adminname,targetname,szSure)
Freeze(Uid)
set_task(float(sure),"TaskUnFreeze",Uid);
}
return PLUGIN_HANDLED
}
public cmdUnFreeze(id,level,cid) {
if(!cmd_access(id,level,cid,2)) return PLUGIN_HANDLED
new arg1[32]
new targetname[32], adminname[32];
read_argv(1,arg1,31)
get_user_name(id,adminname,31);
if(arg1[0] == '@') {
new players[32],inum;
if(equali(arg1[1],"T")) copy(arg1[1],31,"TERRORIST");
if(equali(arg1[1],"ALL")) get_players(players,inum)
else get_players(players,inum,"ae",arg1[1]);
if(!inum) {
console_print(id,"Girilen takimda oyuncu bulunamadi.");
return PLUGIN_HANDLED
}
new tmp;
for(new i;i<inum;i++) {
tmp = players[i];
if(!gFrozen[tmp]) continue;
UnFreeze(tmp);
client_print(tmp,print_center,"COZULDUN"); // :S
}
if(equali(arg1[1],"all")) client_print(0,print_chat,"[AMXX] ADMIN %s: Tum oyunculari cozdu.",adminname);
else client_print(0,print_chat,"[AMXX] ADMIN %s: %s takimindaki oyunculari cozdu.",adminname,arg1[1]);
if(task_exists(0)) remove_task(0);
}
else {
new Uid = find_player("bhl",arg1);
if(!Uid) {
console_print(id,"Oyuncu bulunamadi !")
return PLUGIN_HANDLED
}
if(!gFrozen[Uid]) {
console_print(id,"Oyuncu zaten donuk degil !")
return PLUGIN_HANDLED
}
get_user_name(Uid,targetname,31);
client_print(Uid,print_center,"COZULDUN"); // :S
client_print(0,print_chat,"[AMXX] ADMIN %s: %s adli oyuncuyu cozdu.",adminname,targetname)
UnFreeze(Uid);
if(task_exists(Uid)) remove_task(Uid);
}
return PLUGIN_HANDLED
}
UnFreeze( id ) {
new frozenCount = 0;
gFrozen[ id ] = false;
new iFlags = pev( id , pev_flags ) ;
if( iFlags & FL_FROZEN ) {
set_pev( id , pev_flags , iFlags & ~FL_FROZEN ) ;
set_user_rendering( id , kRenderFxNone , 0 , 0 , 0 , kRenderNormal , 0 );
new iPlayers[ 32 ] , iNum , i , tid;
get_players( iPlayers , iNum , "a" );
for( i = 0; i < iNum; i++ ){
tid = iPlayers[ i ];
if( gFrozen[ tid ] ) {
frozenCount++;
}
}
if( !frozenCount && fwPreThink ) unregister_forward( FM_PlayerPreThink , fwPreThink );
}
}
Freeze(id) {
new iFlags = pev( id , pev_flags );
if( ~iFlags & FL_FROZEN ) {
set_pev( id , pev_flags , iFlags | FL_FROZEN );
pev( id , pev_v_angle , iAngles[ id ] );
set_user_rendering( id , kRenderFxGlowShell , 0 , 100 , 200 , kRenderNormal , 16 );
if( !fwPreThink && !get_pcvar_num( pCvarAllowMouse ) )
fwPreThink = register_forward( FM_PlayerPreThink , "fwPlayerPreThink" );
}
gFrozen[ id ] = true;
}
public TaskUnFreeze(id) {
if(!id) {
new players[32],inum;
get_players(players,inum)
new tmp;
for(new i;i<inum;i++) {
tmp = players[i]
if(gFrozen[tmp]) {
UnFreeze(tmp)
client_print(tmp,print_center,"COZULDUN") // :S
}
}
}
else {
if(gFrozen[id]) {
UnFreeze(id)
client_print(id,print_center,"COZULDUN") // :S
}
}
}
denemeye zamanım yoktu, bir zahmet test işini sen hallet