Modificare plugin - LifeShop

Modificari necesare ale pluginurilor

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

User avatar
Andrei1255
Membru, skill 0
Membru, skill 0
Posts: 94
Joined: 22 Feb 2013, 17:28
Detinator Steam: Da
CS Status: Citesc forumul eXtreamCS.com...!
Detinator server CS: dr.vitalcs.ro
SteamID: andrei5563
Location: Los Angeles
Has thanked: 13 times
Been thanked: 3 times

14 Dec 2013, 11:11

L-am mai modificat si eu putin ... Poftim:
Plugin | 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               10000
#define LIFE_SELL               5000
#define LIFE_LIMIT              1
#define LIFE_LIMIT_TOTAL	50

new g_Life[ MAXPLAYERS + 1 ]
new g_Life_Used[ 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")
   
   RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn");
}

public client_connect( id )
   load_client_Life( id )

public client_disconnect( id )
   save_client_Life( id )

public fw_PlayerSpawn(id)
   g_Life[id] = 0;
   
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_Used[id] >= LIFE_LIMIT_TOTAL )
      {
          Color_Print(id,  "!g[Life-Menu] !yAi ajuns la limita !gmaxima !" )
          return PLUGIN_HANDLED
      }
	
      if(g_Life[id] >= LIFE_LIMIT)
      {
	 Color_Print(id,  "!g[Life-Menu] !yPoti folosi doar !g1 viata !ype runda !")
	 return PLUGIN_HANDLED; 
      }
	   
      g_Life[id] += 1
      g_Life_Used[id] += 1
         
      Color_Print(id,  "!g[Life-Menu] !yAi cumparat !g1 Viata")
      
      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 !ypentru a folosi 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();
			}
		}
	}
}


Pentru a modifica vietile maxime , modifici numarul de la #define LIFE_LIMIT_TOTAL , iar pentru vietile maxime pe runda modifici numarul de la #define LIFE_LIMIT
RoyalServer
User avatar
s0uNNNdx
Membru, skill +1
Membru, skill +1
Posts: 227
Joined: 28 Jul 2013, 23:30
Detinator Steam: Da
CS Status: Joc pe fun.free-play.ro
Detinator server CS: Fun.Free-Play.Ro
Location: Prahova
Has thanked: 32 times
Contact:

14 Dec 2013, 12:13

Andrei1255 wrote:L-am mai modificat si eu putin ... Poftim:
Plugin | 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               10000
#define LIFE_SELL               5000
#define LIFE_LIMIT              1
#define LIFE_LIMIT_TOTAL	50

new g_Life[ MAXPLAYERS + 1 ]
new g_Life_Used[ 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")
   
   RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn");
}

public client_connect( id )
   load_client_Life( id )

public client_disconnect( id )
   save_client_Life( id )

public fw_PlayerSpawn(id)
   g_Life[id] = 0;
   
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_Used[id] >= LIFE_LIMIT_TOTAL )
      {
          Color_Print(id,  "!g[Life-Menu] !yAi ajuns la limita !gmaxima !" )
          return PLUGIN_HANDLED
      }
	
      if(g_Life[id] >= LIFE_LIMIT)
      {
	 Color_Print(id,  "!g[Life-Menu] !yPoti folosi doar !g1 viata !ype runda !")
	 return PLUGIN_HANDLED; 
      }
	   
      g_Life[id] += 1
      g_Life_Used[id] += 1
         
      Color_Print(id,  "!g[Life-Menu] !yAi cumparat !g1 Viata")
      
      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 !ypentru a folosi 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();
			}
		}
	}
}


Pentru a modifica vietile maxime , modifici numarul de la #define LIFE_LIMIT_TOTAL , iar pentru vietile maxime pe runda modifici numarul de la #define LIFE_LIMIT


Nu merge bine .
Nu pot cumpara decat 1 viata , imi spune "Poti folosii doar o singura viata pe runda" cand cumpar viata !
Si daca trece runda , imi dispar vietile .
User avatar
Andrei1255
Membru, skill 0
Membru, skill 0
Posts: 94
Joined: 22 Feb 2013, 17:28
Detinator Steam: Da
CS Status: Citesc forumul eXtreamCS.com...!
Detinator server CS: dr.vitalcs.ro
SteamID: andrei5563
Location: Los Angeles
Has thanked: 13 times
Been thanked: 3 times

14 Dec 2013, 22:08

1. Deci poti avea 1 viata si sa o folosesti ?
2. Daca da , tu vrei sa poti cumpara mai multe vieti , dar sa poti folosi doar una pe runda ?
User avatar
GhosT ***
Membru, skill +2
Membru, skill +2
Posts: 604
Joined: 04 Dec 2013, 21:52
Detinator Steam: Da
CS Status: Morphin . [ Retras ]
SteamID: Mutulica1428
Reputatie: Fost Moderator ajutator
Location: Dumesti.
Has thanked: 40 times
Been thanked: 99 times
Contact:

15 Dec 2013, 09:39

Andrei1255 wrote:1. Deci poti avea 1 viata si sa o folosesti ?
2. Daca da , tu vrei sa poti cumpara mai multe vieti , dar sa poti folosi doar una pe runda ?
Da ba , el vrea sa poata cumpara cele 50 si sa poata folosi doar una pe runda ...
User avatar
s0uNNNdx
Membru, skill +1
Membru, skill +1
Posts: 227
Joined: 28 Jul 2013, 23:30
Detinator Steam: Da
CS Status: Joc pe fun.free-play.ro
Detinator server CS: Fun.Free-Play.Ro
Location: Prahova
Has thanked: 32 times
Contact:

15 Dec 2013, 13:08

Andrei1255 wrote:1. Deci poti avea 1 viata si sa o folosesti ?
2. Daca da , tu vrei sa poti cumpara mai multe vieti , dar sa poti folosi doar una pe runda ?
DA !
User avatar
Andrei1255
Membru, skill 0
Membru, skill 0
Posts: 94
Joined: 22 Feb 2013, 17:28
Detinator Steam: Da
CS Status: Citesc forumul eXtreamCS.com...!
Detinator server CS: dr.vitalcs.ro
SteamID: andrei5563
Location: Los Angeles
Has thanked: 13 times
Been thanked: 3 times

17 Dec 2013, 17:11

Incearca Asa | 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               10000
#define LIFE_SELL               5000
#define LIFE_LIMIT              1
#define LIFE_LIMIT_TOTAL	50

new g_Life[ MAXPLAYERS + 1 ]
new g_Life_Used[ 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")
   
   RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn");
}

public client_connect( id )
   load_client_Life( id )

public client_disconnect( id )
   save_client_Life( id )

public fw_PlayerSpawn(id)
   g_Life[id] = 0;
   
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_Used[id] >= LIFE_LIMIT_TOTAL )
      {
          Color_Print(id,  "!g[Life-Menu] !yAi ajuns la limita !gmaxima !" )
          return PLUGIN_HANDLED
      }
	   
      g_Life[id] += 1
      g_Life_Used[id] += 1
         
      Color_Print(id,  "!g[Life-Menu] !yAi cumparat !g1 Viata")
      
      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 !ypentru a folosi viata.")
		return PLUGIN_HANDLED
	}
         
	if ( g_Life[id] == 0 )
	{
		Color_Print(id,  "!g[Life-Menu] !yNu ai nici o !gviata.")
		return PLUGIN_HANDLED
	}
         
	if(g_Life[id] >= LIFE_LIMIT)
	{
		Color_Print(id,  "!g[Life-Menu] !yPoti folosi doar !g1 viata !ype runda !")
		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();
			}
		}
	}
}


Ma scuzi ca am raspuns asa tarziu , dar nu prea am mai avut timp..
User avatar
sUperstar
Utilizator neserios (tepar)
Utilizator neserios (tepar)
Posts: 3321
Joined: 01 Mar 2013, 23:08
Detinator Steam: Da
Reputatie: Restrictie moderator [abuz de functie]
Fost eXtream mod
Utilizator neserios (tepar!)
Has thanked: 42 times
Been thanked: 97 times

17 Dec 2013, 18:01

Mutat in sectiunea corespunzatoare!
RIPPLE FAUCET - Castiga pana la 1 Ripple pe zi!
Post Reply

Return to “Modificari pluginuri”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 20 guests