Jump to content

[Plugin] Points.


SpyRexx

Recommended Posts

Descriere: Acesta este un plugin points pentru zp dar poate fi folosit si la alte moduri.

Descarcare:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

new points[33]
new SaveDataFile [ 128 ];

new const g_Server[] = "89.39.13.44"

public plugin_init() {
	new IP[25]
	get_user_ip(0, IP, sizeof(IP) -1, 1)
	if(equal(IP, g_Server)) {
		register_plugin("[ZD] Point's", "1.0", "london")
		
		register_event("DeathMsg", "ev_DeathMsg", "a")
		
		set_task ( 1.0, "TASK_HUD", _, _, _, "b" );
		
		register_forward ( FM_ClientUserInfoChanged, "ClientUserInfoChanged" );
		
		new DataDir [ 64 ];
		get_datadir ( DataDir, 63 );
		format ( SaveDataFile, 127, "%s/points_system.dat", DataDir );
	}
	
	else 
		set_fail_state ( "Licenta Invalida" );
}

public ev_DeathMsg() {
	new killer = read_data(1)
	new victim = read_data(2)
	
	if(killer == victim) {
		return;
	}
	
	points[killer] += 2
}

public plugin_natives() {
	register_native("zd_set_user_points", "set_user_points", 1)
	register_native("zd_get_user_points", "get_user_points", 1)
}

public get_user_points(id) {
	return points[id];
}

public set_user_points(id, ppoints) {
	points [ id ] = ppoints;
}

public client_disconnect(id) {
	SaveData(id)
}

public client_connect(id) {
	LoadData(id)
}

public SaveData ( id ) {
	
	new Name [ 32 ];
	get_user_name ( id, Name, 31 );
	
	new Save [ 1024 ];
	format ( Save, sizeof ( Save ) - 1, "^"%s^" %d", Name, points [ id ] );
	
	new Line [ 128 ], Linie, IsPlayer = false, Arg1 [ 32 ];
	
	new FileOpen = fopen ( SaveDataFile, "rt" );
	while ( !feof ( FileOpen ) ) {
		fgets ( FileOpen, Line, 127 );
		trim ( Line );
		
		parse ( Line, Arg1, 31 );
		
		if ( equali ( Arg1, Name ) ) {
			write_file ( SaveDataFile, Save, Linie );
			IsPlayer = true;
			break
		}
		
		Linie++;
	}
	
	fclose ( FileOpen )
	if ( !IsPlayer )
		write_file ( SaveDataFile, Save, -1 );
}

public LoadData ( id ) {
	
	new Name [ 32 ];
	get_user_name ( id, Name, 31 );
	
	new Line [ 128 ], IsPlayer = false, Arg1 [ 32 ], Arg2 [ 32 ];
	new FileOpen = fopen ( SaveDataFile, "rt" );

	while ( !feof ( FileOpen ) ) {
		
		fgets ( FileOpen, Line, 127 );
		trim ( Line );
		
		parse ( Line, Arg1, 31, Arg2, 31 );
		
		if ( equali ( Arg1, Name ) ) {
			
			points [ id ] = str_to_num ( Arg2 );
			IsPlayer = true;
			break;
		}
	}
	
	fclose ( FileOpen );
	
	if ( !IsPlayer )
		points [ id ] = 0;
	
}

public TASK_HUD ( ) {
	
	static id;
	for ( id = 1; id <= get_maxplayers ( ); id++ ) {
		
		if ( is_user_alive ( id ) && is_user_connected ( id ) ) {
			
			set_hudmessage(0, 127, 255, 0.77, 0.86, 0, 6.0, 1.0)
			show_hudmessage(id, "Points: %d", points[id])
			
			
		}
	}
}


public ClientUserInfoChanged ( id ) {
	 
	static const name [ ] = "name"; 
	static szOldName [ 32 ], szNewName [ 32 ]; 
	pev ( id, pev_netname, szOldName, charsmax ( szOldName ) ); 
	if ( szOldName [ 0 ] ) {
		
		get_user_info ( id, name, szNewName, charsmax ( szNewName ) );
		if( !equal ( szOldName, szNewName ) ) {
			
			set_user_info ( id, name, szOldName ); 
			return FMRES_HANDLED;
		} 
	} 
	
	return FMRES_IGNORED;
	

Nume: ZP Points System.

Versiune: 2.0

Authors: London, Hades # Ownage.

Instalare:
1. Fisierul PointsSystem.sma il puneti in addons/amxmodx/scripting
2. Fisierul PointsSystem.amxx il puneti in addons/amxmodx/plugins
3. Intrati in fisierul addons/amxmodx/configs/plugins.ini si adaugati la urma:

PointsSystem.amxx

Cvar-uri: Se adauga in fisierul Amxmodx/configs/amxx.cfg:
Nu Exista

Comenzi administrative: Se tasteaza in consola si trebuie sa fiti administrator:

Nu sunt.

Comenzi publice: Se tasteaza in joc prin apasarea tastei Y:

Nu sunt.

Module necesare: Se sterge: Din fata modulului de mai jos: Acestea le gasiti in fisierul Amxmodx/configs/modules.ini:
Fakemeta.

Edited by SpyRexx
Link to comment
Share on other sites

 

#include < amxmodx >
#include < amxmisc >
#include < cstrike >
#include < fun >


new const PLUGIN [ ] = "Points";
new const VERSION [ ] = "1.3";
new const AUTHOR [ ] = "Alex #";

new Points [ 33 ];
new SaveDataFile [ 128 ];

const Float:HUD_SPECT_X = -1.0
const Float:HUD_SPECT_Y = 0.8

public plugin_init ( )
{
    register_plugin ( PLUGIN, VERSION, AUTHOR );
    
    register_event ( "DeathMsg", "eDeath", "a" );
    
    new DataDir [ 64 ];
    get_configsdir ( DataDir, charsmax ( DataDir ) );
    format ( SaveDataFile, 127, "%s/Points.dat", DataDir );
    
    set_task ( 0.1, "TASK_MSG", _, _, _, "b" );
}

public plugin_natives ( )
{
    register_native ( "csdm_get_user_points", "get_user_points", 1 );
    register_native ( "csdm_set_user_points", "set_user_points", 1 );
}

public get_user_points ( id )
{
    return Points [ id ];
}

public set_user_points ( id, PointsNum )
{
    Points [ id ] = PointsNum;
}

public eDeath ( )
{
    new Killer = read_data ( 1 );
    new Victim = read_data ( 2 );
    new HeadShoot = read_data ( 3 );
    
    if ( Killer == Victim ) return PLUGIN_HANDLED;
    
    Points [ Killer ] += 1;
    if ( HeadShoot ) {
        Points [ Killer ] += 2;
    }
    
    return PLUGIN_CONTINUE;
}

public client_connect ( id )
{
    LoadPoints ( id );
}

public client_disconnect ( id )
{
    SavePoints ( id );
}

public LoadPoints ( id )
{
    new Name [ 32 ];
    get_user_name ( id, Name, 31 );
    
    new Line [ 128 ], IsPlayer = false, Arg1 [ 32 ], Arg2 [ 32 ];
    new File = fopen ( SaveDataFile, "rt" )
    while ( !feof ( File ) ) {
        fgets ( File, Line, 127 );
        trim ( Line );
        
        parse ( Line, Arg1, 31, Arg2, 31 );
        
        if ( equali ( Arg1, Name ) ) {
            Points [ id ] = str_to_num ( Arg2 );
            IsPlayer = true;
            break;
        }
    }
    
    fclose ( File );
    
    if ( !IsPlayer )
        Points [ id ] = 0;
}


public SavePoints ( id )
{
    new Name [ 32 ];
    get_user_name ( id, Name, 31 );
    
    new Save [ 1024 ];
    format ( Save, sizeof ( Save ) -1, "^"%s^" %d", Name, Points [ id ] );
    
    new Line [ 128 ], Linie, IsPlayer = false, Arg1 [ 32 ]
    
    new File = fopen ( SaveDataFile, "rt" );
    while ( !feof ( File ) ) {
        fgets ( File, Line, 127 );
        
        parse ( Line, Arg1, 31 );
        
        if ( equali ( Arg1, Name ) ) {
            write_file ( SaveDataFile, Save, Linie );
            IsPlayer = true;
            break;
        }
        
        Linie++
    }
    
    fclose ( File );
    
    if ( !IsPlayer )
        write_file ( SaveDataFile, Save, -1 );
}

public TASK_MSG ( )
{
    static id;
    for ( id = 1; id <= get_maxplayers ( ); id++ )
    {
        if ( is_user_alive ( id ) && is_user_connected ( id ) ) {
            switch ( cs_get_user_team ( id ) )
            {
                case CS_TEAM_T : {
                    set_hudmessage ( id, 127, 255, HUD_SPECT_X, HUD_SPECT_Y, 1, 6.0, 1.1, 0.0, 0.0, -1 );
                    show_hudmessage ( id, "Terorist, HP: %d - AP: %d - Points: %d", get_user_health ( id ), get_user_armor ( id ), Points [ id ] );
                }
                
                case CS_TEAM_CT : {
                    set_hudmessage ( id, 127, 255, HUD_SPECT_X, HUD_SPECT_Y, 1, 6.0, 1.1, 0.0, 0.0, -1 )
                    show_hudmessage ( id, "Counter, HP: %d - AP: %d - Points: %d", get_user_health ( id ), get_user_armor ( id ), Points [ id ] );
                }
                
                case CS_TEAM_SPECTATOR : {
                    return PLUGIN_CONTINUE;
                }
            }
        }
        
    }
    return PLUGIN_CONTINUE;
}

 

ltima versiune.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...