Cerere editare /vieti

Modificari necesare ale pluginurilor

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

Post Reply
User avatar
EleCtr0zZz
Membru, skill +1
Membru, skill +1
Posts: 428
Joined: 25 May 2015, 07:27
Detinator Steam: Da
SteamID: =
Fond eXtream: 0
Has thanked: 3 times
Contact:

21 Mar 2018, 15:54

Salut poate face cineva ca in loc sa cumperi vietile cu bani sa le cumperi cu credite?
SMA plugin vieti :
| Afiseaza codul
/*
*   Plugin facut la cerere , Forum : cereri-cs/idei-pluginuri-t24614-900.html
*    Plugin: Life-Shop
*    Versiunea: 1.0
*    Author: ExoTiQ
*
*    Multumesc lui Bos93 pentru o metoda noua.
*    Functia cu Anti-Change Nick am folosit de la spuf.
*    Am folosit alt Stock de culori pentru ca vechi facea probleme.
*/

#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >
#include < nvault >



#define PLUGIN_NAME      "Life-Shop"
#define PLUGIN_VERSION   "1.0"
#define PLUGIN_AUTHOR   "ExoTiQ"

#define MAXPLAYERS             32
#define MAX_STATS_SAVED         64

#if cellbits ==                   32 
#define OFFSET_CSMONEY       115 
#else 
#define OFFSET_CSMONEY       140 
#endif 

#define OFFSET_LINUX             5

#define LIFE_COST               8000
#define LIFE_SELL               5000
#define LIFE_LIMIT               50

new g_Life[ MAXPLAYERS + 1 ]
new gName[ MAXPLAYERS ]
new vKey[ MAX_STATS_SAVED ]
new vData[ MAX_STATS_SAVED ]

new gVault

public plugin_init ( )
{
   register_plugin ( PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR )
   
   register_event( "DeathMsg", "EV_DeathMsg", "a" )
   register_forward(FM_ClientUserInfoChanged, "fwClientUserInfoChanged");
   register_clcmd("say /vieti", "Life_Shop")
   register_clcmd("say /life", "Life_Shop")
}

public client_connect( id )
   load_client_Life( id )

public client_disconnect( id )
   save_client_Life( id )

   
public EV_DeathMsg() {
   new iVictim = read_data( 2 );
   new iTeam = get_user_team( iVictim );
   new iKiller = read_data( 1 );
   
   if( iKiller != iVictim && get_user_team(iKiller) != iTeam ) {
      Life_Shop( iVictim )
   }
   
}
public Life_Shop( id ) 
{
   new szText[ 1024 char ];
   
   formatex( szText, charsmax( szText ), "\yAveti\w: \r%d\y $^nAveti\w: \r%d\y vieti" ,fm_cs_get_user_money(id) , g_Life[id] );
   
   new menu = menu_create( szText, "Life_handler" );
   
   formatex( szText, charsmax( szText ), "Cumpara 1 viata \y-  \w%d\y $" ,LIFE_COST);
   menu_additem( menu, szText, "1", 0 );
   
   
   formatex( szText, charsmax( szText ), "Vinde 1 viata \y+ \w%d\y $" ,LIFE_SELL);
   menu_additem( menu, szText, "2", 0 );
   
   formatex( szText, charsmax( szText ), "Foloseste \y- \r1\w Viata" );
   menu_additem( menu, szText, "3", 0 );
   
   menu_setprop(menu, MPROP_EXITNAME, "Iesire")
   
   menu_display(id, menu, 0)
}

public Life_handler (id , menu , item ) {
   
   if (item == MENU_EXIT)
   {
      menu_destroy(menu)
      return PLUGIN_HANDLED
   }
   
   new s_Data[6], s_Name[64], i_Access, i_Callback
   
   menu_item_getinfo(menu, item, i_Access, s_Data, charsmax(s_Data), s_Name, charsmax(s_Name), i_Callback)
   
   new i_Key = str_to_num(s_Data)
   
   
   new bani = fm_cs_get_user_money(id)
   
   switch(i_Key)
   {
      case 1:
      {
         if (bani < LIFE_COST)
         {
            Color_Print(id,  "!g[Life-Menu] !yNu ai destui bani pentru a cumpara !gviata." )            
            return PLUGIN_HANDLED
         }
         
         if ( g_Life[id] >= LIFE_LIMIT )
         {
            Color_Print(id,  "!g[Life-Menu] !yAi ajuns la limita !gmaxima." )
            return PLUGIN_HANDLED
         }
         
         Color_Print(id,  "!g[Life-Menu] !yAi cumparat !g1 Viata")
         
         g_Life[id] += 1
         
         fm_cs_set_user_money(id, bani - LIFE_COST)
         Life_Shop( id ) 
      }
      case 2:
      {
         if ( g_Life[id] == 0 )
         {
            Color_Print(id,  "!g[Life-Menu] !yNu ai nici o !gviata.")
            return PLUGIN_HANDLED
         }
         
         Color_Print(id,  "!g[Life-Menu] !yAi vandut !g1 Viata.")
         
         g_Life[id] -= 1
         
         fm_cs_set_user_money(id, bani + LIFE_SELL)
         Life_Shop( id ) 
      }
      case 3:
      {
         if ( is_user_alive( id ) )
         {
            Color_Print(id,  "!g[Life-Menu] !yTrebuie sa fii !gmort !y, pentru a folosit viata.")
            return PLUGIN_HANDLED
         }
         
         if ( g_Life[id] == 0 )
         {
            Color_Print(id,  "!g[Life-Menu] !yNu ai nici o !gviata.")
            return PLUGIN_HANDLED
         }
         
         g_Life[id] -= 1
         
         Color_Print(id,  "!g[Life-Menu] !yAi folosit !g1 viata si ai primit !grespawn.")
         
         ExecuteHam(Ham_CS_RoundRespawn, id)
      }
   }
   menu_destroy(menu)
   return PLUGIN_HANDLED
}
stock save_client_Life( index )
{
   gVault = nvault_open( "Life_Save" )
   
   if( gVault == INVALID_HANDLE )
   {
      set_fail_state( "[Life-Shop] nValut ERROR: =-> Invalid-Handle" )
   }
   
   get_user_name( index, gName, charsmax( gName ) )
   //get_user_name(index,gName,32);
   
   formatex( vKey, charsmax( vKey ), "%sLife",gName )
   formatex( vData, charsmax( vData ), "%d", g_Life[ index ] )
   nvault_set( gVault, vKey, vData )
   nvault_close( gVault )
}

stock load_client_Life( index )
{
   gVault = nvault_open( "Life_Save" )
   
   if( gVault == INVALID_HANDLE )
   {
      set_fail_state( "[Life-Shop] nValut ERROR: =-> Invalid-Handle" )
   }
   
   get_user_name( index, gName, charsmax( gName ) )
   //get_user_name(index,gName,32);
   
   formatex( vKey, charsmax( vKey ), "%sLife",gName )
   g_Life[ index ] = nvault_get( gVault, vKey )
   nvault_close( gVault )
}

 public fwClientUserInfoChanged(id, buffer) {
   if (!is_user_connected(id)) {
      return FMRES_IGNORED;
   }
   static val[32];
   static name[32];
   get_user_name(id, name, 31);
   engfunc(EngFunc_InfoKeyValue, buffer, "name", val, sizeof val- 1);
   if (equal(val, name)) {
      return FMRES_IGNORED;
   }
   engfunc(EngFunc_SetClientKeyValue, id, buffer, "name", name);
   Color_Print(id,  "!g[Life-Menu] !teamNU este permisa schimbarea nick-ului pe server !")
   console_print(id,"NU este permisa schimbarea nick-ului pe server !");
   return PLUGIN_HANDLED;
}


stock fm_cs_set_user_money(id, money, flash = 1) 
{ 
   set_pdata_int(id, OFFSET_CSMONEY, money, OFFSET_LINUX)
   
   message_begin(MSG_ONE, get_user_msgid("Money"), {0,0,0}, id)
   write_long(money)
   write_byte(flash)
   message_end()
}

stock fm_cs_get_user_money(id) 
   return get_pdata_int(id, OFFSET_CSMONEY, OFFSET_LINUX)


stock Color_Print(const id, const input[], any:...)
{
   new count = 1, players[32]
   static msg[191]
   vformat(msg, 190, input, 3)
   
   replace_all(msg, 190, "!g", "^4") // Green Color
   replace_all(msg, 190, "!y", "^1") // Default Color
   replace_all(msg, 190, "!team", "^3") // Team Color
   
   if (id) players[0] = id; else get_players(players, count, "ch")
        {    
   for (new i = 0; i < count; i++)
   {
      if (is_user_connected(players))
      {
         message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players)
         write_byte(players);
         write_string(msg);
         message_end();
      }
   }
}
}

Vreau sa fie pe sistemul de credite: amxmodx/furien-credits-system-t204666.html
Si sa poti folosi o viata doar odata pe runda
RoyalServer 2
User avatar
LOLpgl
Membru, skill +3
Membru, skill +3
Posts: 1127
Joined: 16 Dec 2013, 21:01
Detinator Steam: Da
SteamID: ionutcruso
Location: Rm.Valcea
Has thanked: 19 times
Been thanked: 15 times

22 Mar 2018, 01:01

| Afiseaza codul
#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >
#include < nvault >

#pragma tabsize 0

native fcs_get_user_credits(client);
native fcs_set_user_credits(client, credits);

#define PLUGIN_NAME      "Life-Shop"
#define PLUGIN_VERSION   "1.0"
#define PLUGIN_AUTHOR   "ExoTiQ"

#define MAXPLAYERS             32
#define MAX_STATS_SAVED         64

#define LIFE_COST               80
#define LIFE_SELL               50
#define LIFE_LIMIT               50

new g_Life[ MAXPLAYERS + 1 ]
new gName[ MAXPLAYERS ]
new vKey[ MAX_STATS_SAVED ]
new vData[ MAX_STATS_SAVED ]

new bool: Used[33];

new gVault

public plugin_init ( )
{
	register_plugin ( PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR )
	
	register_event( "DeathMsg", "EV_DeathMsg", "a" )
	register_forward(FM_ClientUserInfoChanged, "fwClientUserInfoChanged");
	register_clcmd("say /vieti", "Life_Shop")
	register_clcmd("say /life", "Life_Shop")
}

public client_connect( id ){
	load_client_Life( id )
	Used[id] = false;
}

public client_disconnect( id ){
	save_client_Life( id )
	Used[id] = false;
}


public EV_DeathMsg() {
	new iVictim = read_data( 2 );
	new iTeam = get_user_team( iVictim );
	new iKiller = read_data( 1 );
	
	if( iKiller != iVictim && get_user_team(iKiller) != iTeam && !Used[iKiller] ) {
		Life_Shop( iVictim )
	}
	
}
public Life_Shop( id ) 
{
	new szText[ 1024 char ];
	
	formatex( szText, charsmax( szText ), "\yAveti\w: \r%d \yCredite^nAveti\w: \r%d\y vieti" ,fcs_get_user_credits(id) , g_Life[id] );
	
	new menu = menu_create( szText, "Life_handler" );
	
	formatex( szText, charsmax( szText ), "Cumpara 1 viata \y-  \w%d\y Credite" ,LIFE_COST);
	menu_additem( menu, szText, "1", 0 );
	
	
	formatex( szText, charsmax( szText ), "Vinde 1 viata \y+ \w%d\y Credite" ,LIFE_SELL);
	menu_additem( menu, szText, "2", 0 );
	
	formatex( szText, charsmax( szText ), "Foloseste \y- \r1\w Viata" );
	menu_additem( menu, szText, "3", 0 );
	
	menu_setprop(menu, MPROP_EXITNAME, "Iesire")
	
	menu_display(id, menu, 0)
}

public Life_handler (id , menu , item ) {
	
	if (item == MENU_EXIT)
	{
		menu_destroy(menu)
		return PLUGIN_HANDLED
	}
	
	new s_Data[6], s_Name[64], i_Access, i_Callback
	
	menu_item_getinfo(menu, item, i_Access, s_Data, charsmax(s_Data), s_Name, charsmax(s_Name), i_Callback)
	
	new i_Key = str_to_num(s_Data)
	
	
	new bani = fcs_get_user_credits(id)
	
	switch(i_Key)
	{
		case 1:
		{
			if (bani < LIFE_COST)
			{
				Color_Print(id,  "!g[Life-Menu] !yNu ai destule credite pentru a cumpara !gviata." )            
				return PLUGIN_HANDLED
			}
			
			if ( g_Life[id] >= LIFE_LIMIT )
			{
				Color_Print(id,  "!g[Life-Menu] !yAi ajuns la limita !gmaxima." )
				return PLUGIN_HANDLED
			}
			
			Color_Print(id,  "!g[Life-Menu] !yAi cumparat !g1 Viata")
			
			g_Life[id] += 1
			
			fcs_set_user_credits(id, bani - LIFE_COST)
			Life_Shop( id ) 
		}
		case 2:
		{
			if ( g_Life[id] == 0 )
			{
				Color_Print(id,  "!g[Life-Menu] !yNu ai nici o !gviata.")
				return PLUGIN_HANDLED
			}
			
			Color_Print(id,  "!g[Life-Menu] !yAi vandut !g1 Viata.")
			
			g_Life[id] -= 1
			
			fcs_set_user_credits(id, bani + LIFE_SELL)
			Life_Shop( id ) 
		}
		case 3:
		{
			if ( is_user_alive( id ) )
			{
				Color_Print(id,  "!g[Life-Menu] !yTrebuie sa fii !gmort !y, pentru a folosit viata.")
				return PLUGIN_HANDLED
			}
			
			if ( g_Life[id] == 0 )
			{
				Color_Print(id,  "!g[Life-Menu] !yNu ai nici o !gviata.")
				return PLUGIN_HANDLED
			}
			
			g_Life[id] -= 1
			
			Color_Print(id,  "!g[Life-Menu] !yAi folosit !g1 viata si ai primit !grespawn.")
			
			ExecuteHam(Ham_CS_RoundRespawn, id)
			Used[id] = true;
		}
	}
	menu_destroy(menu)
	return PLUGIN_HANDLED
}
stock save_client_Life( index )
{
	gVault = nvault_open( "Life_Save" )
	
	if( gVault == INVALID_HANDLE )
	{
		set_fail_state( "[Life-Shop] nValut ERROR: =-> Invalid-Handle" )
	}
	
	get_user_name( index, gName, charsmax( gName ) )
	//get_user_name(index,gName,32);
	
	formatex( vKey, charsmax( vKey ), "%sLife",gName )
	formatex( vData, charsmax( vData ), "%d", g_Life[ index ] )
	nvault_set( gVault, vKey, vData )
	nvault_close( gVault )
}

stock load_client_Life( index )
{
	gVault = nvault_open( "Life_Save" )
	
	if( gVault == INVALID_HANDLE )
	{
		set_fail_state( "[Life-Shop] nValut ERROR: =-> Invalid-Handle" )
	}
	
	get_user_name( index, gName, charsmax( gName ) )
	//get_user_name(index,gName,32);
	
	formatex( vKey, charsmax( vKey ), "%sLife",gName )
	g_Life[ index ] = nvault_get( gVault, vKey )
	nvault_close( gVault )
}

public fwClientUserInfoChanged(id, buffer) {
	if (!is_user_connected(id)) {
		return FMRES_IGNORED;
	}
	static val[32];
	static name[32];
	get_user_name(id, name, 31);
	engfunc(EngFunc_InfoKeyValue, buffer, "name", val, sizeof val- 1);
	if (equal(val, name)) {
		return FMRES_IGNORED;
	}
	engfunc(EngFunc_SetClientKeyValue, id, buffer, "name", name);
	Color_Print(id,  "!g[Life-Menu] !teamNU este permisa schimbarea nick-ului pe server !")
	console_print(id,"NU este permisa schimbarea nick-ului pe server !");
	return PLUGIN_HANDLED;
}


stock Color_Print(const id, const input[], any:...)
{
	new count = 1, players[32]
	static msg[191]
	vformat(msg, 190, input, 3)
	
	replace_all(msg, 190, "!g", "^4") // Green Color
	replace_all(msg, 190, "!y", "^1") // Default Color
	replace_all(msg, 190, "!team", "^3") // Team Color
	
	if (id) players[0] = id; else get_players(players, count, "ch")
{    
	for (new i = 0; i < count; i++)
	{
		if (is_user_connected(players))
		{
			message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players)
			write_byte(players);
			write_string(msg);
			message_end();
		}
	}
}
}
Post Reply

Return to “Modificari pluginuri”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 9 guests