Modificare plugin - LifeShop

Modificari necesare ale pluginurilor

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

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:

13 Dec 2013, 18:46

Salut !
Modificati-mi va rog urmatorul plugin astfel incat playeri sa poata folosii doar 1 viata pe runda .
| Afiseaza codul
/*
*   Plugin facut la cerere , Forum : http://www.extreamcs.com/forum/cereri-c ... 4-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               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();
      }
   }
}
}
RoyalServer 2
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:

13 Dec 2013, 18:49

Cum adica , da-mi mai multe informatii despre plugin ;))
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:

13 Dec 2013, 19:20

Adica playeri sa foloseasca doar o viata pe runda (din cele 50)
sa apara un mesaj : "Doar 1 viata poti folosii pe runda !"
User avatar
Laurentiu P.
Fost moderator
Fost moderator
Posts: 2548
Joined: 10 Jul 2013, 21:26
Detinator Steam: Da
Reputatie: Fost super moderator
Fond eXtream: 100
Has thanked: 26 times
Been thanked: 61 times
Contact:

13 Dec 2013, 20:09

#define LIFE_LIMIT 50


Modifici aici pui 1 in loc de 50
no...
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:

13 Dec 2013, 21:15

Aia e Limita Vietilor (cate vieti poti cumpara) .
Daca pun pe 1 , Playeri isi cumpara iar si o folosesc .
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

13 Dec 2013, 22:09

Netestat | 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

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")
   
   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[id] >= LIFE_LIMIT )
         {
            Color_Print(id,  "!g[Life-Menu] !yAi ajuns la limita !gmaxima." )
            return PLUGIN_HANDLED
         }

      	 g_Life[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 !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();
			}
		}
	}
}


Incearca-l . Daca nu functioneaza ceva corect sau mai vrei ceva la el dai un reply .
Last edited by Andrei1255 on 14 Dec 2013, 10:40, edited 1 time in total.
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:

14 Dec 2013, 09:34

Andrei1255 wrote:
Netestat | 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

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")
   
   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:
      {
      	 g_Life[id] += 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")
         
         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();
			}
		}
	}
}


Incearca-l . Daca nu functioneaza ceva corect sau mai vrei ceva la el dai un reply .


Ai modificat sa fie max life 1 dar el vrea sa fie 50 [limita] si sa nu poata folosi decat una pe runda 8->
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, 09:45

GhosT *** wrote:
Andrei1255 wrote:
Netestat | 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

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")
   
   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:
      {
      	 g_Life[id] += 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")
         
         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();
			}
		}
	}
}


Incearca-l . Daca nu functioneaza ceva corect sau mai vrei ceva la el dai un reply .


Ai modificat sa fie max life 1 dar el vrea sa fie 50 [limita] si sa nu poata folosi decat una pe runda 8->


Exact !
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, 10:06

Te-ai uitat mai bine peste sursa ? Am modificat mult mai mult de atat.

Am adaugat:

Code: Select all

1. RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn) + definirea acestuia.
2. Am pus g_Life[id] la acel  "case 1"  mai sus .
Incearca-l :) .
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:

14 Dec 2013, 10:07

s0uNNNdx wrote:
GhosT *** wrote:
Andrei1255 wrote:
Netestat | 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

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")
   
   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:
      {
      	 g_Life[id] += 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")
         
         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();
			}
		}
	}
}


Incearca-l . Daca nu functioneaza ceva corect sau mai vrei ceva la el dai un reply .


Ai modificat sa fie max life 1 dar el vrea sa fie 50 [limita] si sa nu poata folosi decat una pe runda 8->


Exact !


l-am modificat eu .. Vad ca nimeni nu vrea :-<

| 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 >
#include < colorchat >



#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               50

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

new gVault
new limita[33];

public plugin_init ( )
{
	register_plugin ( PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR )
	
	register_logevent("inceput_runda", 2, "1=Round_Start");
	register_event( "DeathMsg", "EV_DeathMsg", "a" )
	register_forward(FM_ClientUserInfoChanged, "fwClientUserInfoChanged");
	register_clcmd("say /vieti", "Life")
	register_clcmd("say /life", "Life")
}
public inceput_runda(id)
{
	new iPlayers[32];
	new iNum;
	
	get_players(iPlayers, iNum);
	for(new i = 0; i < iNum; i++)
	{
		limita[iPlayers] = 0;
	}
}
public Life(id)
{
	if(limita[id] == 0)
	{
		Life_Shop(id)
	}
	else if(limita[id] == 1)
	{
		Life_Shop_2(id)
	}
}
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 );
	menu_additem(menu, "Cumpara 1 viata \r10000$", "1", 0)
	menu_additem(menu, "Vinde 1 viata \r5000$", "2", 0)
	menu_additem(menu, "Foloseste \r1 Viata", "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)
			{
				ColorChat(id, GREEN, "[Life-Menu]^x01 Nu ai destui bani pentru a cumpara^x04 viata." )            
				return PLUGIN_HANDLED
			}
			
			if ( g_Life[id] >= LIFE_LIMIT )
			{
				ColorChat(id, GREEN, "[Life-Menu]^x01 Ai ajuns la limita^x04 maxima." )
				return PLUGIN_HANDLED
			}
			
			ColorChat(id, GREEN, "[Life-Menu]^x01 Ai cumparat^x04 1 Viata")
			
			g_Life[id] += 1
			
			fm_cs_set_user_money(id, bani - LIFE_COST)
			Life_Shop( id ) 
		}
		case 2:
		{
			if ( g_Life[id] == 0 )
			{
				ColorChat(id, GREEN, "[Life-Menu]^x01 Nu ai nici o^x04 viata.")
				return PLUGIN_HANDLED
			}
			
			ColorChat(id, GREEN, "[Life-Menu]^x01 Ai vandut^x04 1 Viata.")
			
			g_Life[id] -= 1
			
			fm_cs_set_user_money(id, bani + LIFE_SELL)
			Life_Shop( id ) 
		}
		case 3:
		{
			if ( is_user_alive( id ) )
			{
				ColorChat(id, GREEN, "[Life-Menu]^x01 Trebuie sa fii^x04 mort^x01 , pentru a folosit viata.")
				return PLUGIN_HANDLED
			}
			
			if ( g_Life[id] == 0 )
			{
				ColorChat(id, GREEN, "[Life-Menu]^x01 Nu ai nici o^x04 viata.")
				return PLUGIN_HANDLED
			}
			
			g_Life[id] -= 1
			
			ColorChat(id, GREEN, "[Life-Menu]^x01 Ai folosit^x04 1 viata^x01 si ai primit^x04 respawn.")
			
			ExecuteHam(Ham_CS_RoundRespawn, id)
			limita[id] += 1
		}
	}
	menu_destroy(menu)
	return PLUGIN_HANDLED
}
public Life_Shop_2( 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_2" );
	
	formatex( szText, charsmax( szText ), "Cumpara 1 viata \y-  \w%d\y $" ,LIFE_COST);
	menu_additem( menu, szText, "1", 0 );
	menu_additem(menu, "Cumpara 1 viata \r10000$", "1", 0)
	menu_additem(menu, "Vinde 1 viata \r5000$", "2", 0)
	
	menu_setprop(menu, MPROP_EXITNAME, "Iesire")
}
public Life_handler_2 (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)
			{
				ColorChat(id, GREEN, "[Life-Menu]^x01 Nu ai destui bani pentru a cumpara^x04 viata." )            
				return PLUGIN_HANDLED
			}
			
			if ( g_Life[id] >= LIFE_LIMIT )
			{
				ColorChat(id, GREEN, "[Life-Menu]^x01 Ai ajuns la limita^x04 maxima." )
				return PLUGIN_HANDLED
			}
			
			ColorChat(id, GREEN, "[Life-Menu]^x01 Ai cumparat^x04 1 Viata")
			
			g_Life[id] += 1
			
			fm_cs_set_user_money(id, bani - LIFE_COST)
			Life_Shop( id ) 
		}
		case 2:
		{
			if ( g_Life[id] == 0 )
			{
				ColorChat(id, GREEN, "[Life-Menu]^x01 Nu ai nici o^x04 viata.")
				return PLUGIN_HANDLED
			}
			
			ColorChat(id, GREEN, "[Life-Menu]^x01 Ai vandut^x04 1 Viata.")
			
			g_Life[id] -= 1
			
			fm_cs_set_user_money(id, bani + LIFE_SELL)
			Life_Shop( 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);
	ColorChat(id, GREEN, "[Life-Menu]^x03 NU 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)


Click aici pentru colorchat.inc

Sau compileaza-l online aici
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, 10:43

GhosT *** wrote:
s0uNNNdx wrote:
GhosT *** wrote:
Ai modificat sa fie max life 1 dar el vrea sa fie 50 [limita] si sa nu poata folosi decat una pe runda 8->
Exact !
l-am modificat eu .. Vad ca nimeni nu vrea :-<
| 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 >
#include < colorchat >



#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               50

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

new gVault
new limita[33];

public plugin_init ( )
{
	register_plugin ( PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR )
	
	register_logevent("inceput_runda", 2, "1=Round_Start");
	register_event( "DeathMsg", "EV_DeathMsg", "a" )
	register_forward(FM_ClientUserInfoChanged, "fwClientUserInfoChanged");
	register_clcmd("say /vieti", "Life")
	register_clcmd("say /life", "Life")
}
public inceput_runda(id)
{
	new iPlayers[32];
	new iNum;
	
	get_players(iPlayers, iNum);
	for(new i = 0; i < iNum; i++)
	{
		limita[iPlayers] = 0;
	}
}
public Life(id)
{
	if(limita[id] == 0)
	{
		Life_Shop(id)
	}
	else if(limita[id] == 1)
	{
		Life_Shop_2(id)
	}
}
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 );
	menu_additem(menu, "Cumpara 1 viata \r10000$", "1", 0)
	menu_additem(menu, "Vinde 1 viata \r5000$", "2", 0)
	menu_additem(menu, "Foloseste \r1 Viata", "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)
			{
				ColorChat(id, GREEN, "[Life-Menu]^x01 Nu ai destui bani pentru a cumpara^x04 viata." )            
				return PLUGIN_HANDLED
			}
			
			if ( g_Life[id] >= LIFE_LIMIT )
			{
				ColorChat(id, GREEN, "[Life-Menu]^x01 Ai ajuns la limita^x04 maxima." )
				return PLUGIN_HANDLED
			}
			
			ColorChat(id, GREEN, "[Life-Menu]^x01 Ai cumparat^x04 1 Viata")
			
			g_Life[id] += 1
			
			fm_cs_set_user_money(id, bani - LIFE_COST)
			Life_Shop( id ) 
		}
		case 2:
		{
			if ( g_Life[id] == 0 )
			{
				ColorChat(id, GREEN, "[Life-Menu]^x01 Nu ai nici o^x04 viata.")
				return PLUGIN_HANDLED
			}
			
			ColorChat(id, GREEN, "[Life-Menu]^x01 Ai vandut^x04 1 Viata.")
			
			g_Life[id] -= 1
			
			fm_cs_set_user_money(id, bani + LIFE_SELL)
			Life_Shop( id ) 
		}
		case 3:
		{
			if ( is_user_alive( id ) )
			{
				ColorChat(id, GREEN, "[Life-Menu]^x01 Trebuie sa fii^x04 mort^x01 , pentru a folosit viata.")
				return PLUGIN_HANDLED
			}
			
			if ( g_Life[id] == 0 )
			{
				ColorChat(id, GREEN, "[Life-Menu]^x01 Nu ai nici o^x04 viata.")
				return PLUGIN_HANDLED
			}
			
			g_Life[id] -= 1
			
			ColorChat(id, GREEN, "[Life-Menu]^x01 Ai folosit^x04 1 viata^x01 si ai primit^x04 respawn.")
			
			ExecuteHam(Ham_CS_RoundRespawn, id)
			limita[id] += 1
		}
	}
	menu_destroy(menu)
	return PLUGIN_HANDLED
}
public Life_Shop_2( 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_2" );
	
	formatex( szText, charsmax( szText ), "Cumpara 1 viata \y-  \w%d\y $" ,LIFE_COST);
	menu_additem( menu, szText, "1", 0 );
	menu_additem(menu, "Cumpara 1 viata \r10000$", "1", 0)
	menu_additem(menu, "Vinde 1 viata \r5000$", "2", 0)
	
	menu_setprop(menu, MPROP_EXITNAME, "Iesire")
}
public Life_handler_2 (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)
			{
				ColorChat(id, GREEN, "[Life-Menu]^x01 Nu ai destui bani pentru a cumpara^x04 viata." )            
				return PLUGIN_HANDLED
			}
			
			if ( g_Life[id] >= LIFE_LIMIT )
			{
				ColorChat(id, GREEN, "[Life-Menu]^x01 Ai ajuns la limita^x04 maxima." )
				return PLUGIN_HANDLED
			}
			
			ColorChat(id, GREEN, "[Life-Menu]^x01 Ai cumparat^x04 1 Viata")
			
			g_Life[id] += 1
			
			fm_cs_set_user_money(id, bani - LIFE_COST)
			Life_Shop( id ) 
		}
		case 2:
		{
			if ( g_Life[id] == 0 )
			{
				ColorChat(id, GREEN, "[Life-Menu]^x01 Nu ai nici o^x04 viata.")
				return PLUGIN_HANDLED
			}
			
			ColorChat(id, GREEN, "[Life-Menu]^x01 Ai vandut^x04 1 Viata.")
			
			g_Life[id] -= 1
			
			fm_cs_set_user_money(id, bani + LIFE_SELL)
			Life_Shop( 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);
	ColorChat(id, GREEN, "[Life-Menu]^x03 NU 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)


Click aici pentru colorchat.inc

Sau compileaza-l online aici


O doamne , romanii cat de ofticati si fara rabdare pot sa fie ... "Nimeni nu vrea" ? Te-ai uitat macar inainte ca i-am explicat ca am facut mai mult decat sa modific "#define FRAG_LIMIT" ? Toti umblati dupa posturi , dar TOTI !
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:

14 Dec 2013, 10:54

Andrei1255 wrote:
GhosT *** wrote:
s0uNNNdx wrote:
Exact !
l-am modificat eu .. Vad ca nimeni nu vrea :-<
| 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 >
#include < colorchat >



#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               50

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

new gVault
new limita[33];

public plugin_init ( )
{
	register_plugin ( PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR )
	
	register_logevent("inceput_runda", 2, "1=Round_Start");
	register_event( "DeathMsg", "EV_DeathMsg", "a" )
	register_forward(FM_ClientUserInfoChanged, "fwClientUserInfoChanged");
	register_clcmd("say /vieti", "Life")
	register_clcmd("say /life", "Life")
}
public inceput_runda(id)
{
	new iPlayers[32];
	new iNum;
	
	get_players(iPlayers, iNum);
	for(new i = 0; i < iNum; i++)
	{
		limita[iPlayers] = 0;
	}
}
public Life(id)
{
	if(limita[id] == 0)
	{
		Life_Shop(id)
	}
	else if(limita[id] == 1)
	{
		Life_Shop_2(id)
	}
}
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 );
	menu_additem(menu, "Cumpara 1 viata \r10000$", "1", 0)
	menu_additem(menu, "Vinde 1 viata \r5000$", "2", 0)
	menu_additem(menu, "Foloseste \r1 Viata", "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)
			{
				ColorChat(id, GREEN, "[Life-Menu]^x01 Nu ai destui bani pentru a cumpara^x04 viata." )            
				return PLUGIN_HANDLED
			}
			
			if ( g_Life[id] >= LIFE_LIMIT )
			{
				ColorChat(id, GREEN, "[Life-Menu]^x01 Ai ajuns la limita^x04 maxima." )
				return PLUGIN_HANDLED
			}
			
			ColorChat(id, GREEN, "[Life-Menu]^x01 Ai cumparat^x04 1 Viata")
			
			g_Life[id] += 1
			
			fm_cs_set_user_money(id, bani - LIFE_COST)
			Life_Shop( id ) 
		}
		case 2:
		{
			if ( g_Life[id] == 0 )
			{
				ColorChat(id, GREEN, "[Life-Menu]^x01 Nu ai nici o^x04 viata.")
				return PLUGIN_HANDLED
			}
			
			ColorChat(id, GREEN, "[Life-Menu]^x01 Ai vandut^x04 1 Viata.")
			
			g_Life[id] -= 1
			
			fm_cs_set_user_money(id, bani + LIFE_SELL)
			Life_Shop( id ) 
		}
		case 3:
		{
			if ( is_user_alive( id ) )
			{
				ColorChat(id, GREEN, "[Life-Menu]^x01 Trebuie sa fii^x04 mort^x01 , pentru a folosit viata.")
				return PLUGIN_HANDLED
			}
			
			if ( g_Life[id] == 0 )
			{
				ColorChat(id, GREEN, "[Life-Menu]^x01 Nu ai nici o^x04 viata.")
				return PLUGIN_HANDLED
			}
			
			g_Life[id] -= 1
			
			ColorChat(id, GREEN, "[Life-Menu]^x01 Ai folosit^x04 1 viata^x01 si ai primit^x04 respawn.")
			
			ExecuteHam(Ham_CS_RoundRespawn, id)
			limita[id] += 1
		}
	}
	menu_destroy(menu)
	return PLUGIN_HANDLED
}
public Life_Shop_2( 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_2" );
	
	formatex( szText, charsmax( szText ), "Cumpara 1 viata \y-  \w%d\y $" ,LIFE_COST);
	menu_additem( menu, szText, "1", 0 );
	menu_additem(menu, "Cumpara 1 viata \r10000$", "1", 0)
	menu_additem(menu, "Vinde 1 viata \r5000$", "2", 0)
	
	menu_setprop(menu, MPROP_EXITNAME, "Iesire")
}
public Life_handler_2 (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)
			{
				ColorChat(id, GREEN, "[Life-Menu]^x01 Nu ai destui bani pentru a cumpara^x04 viata." )            
				return PLUGIN_HANDLED
			}
			
			if ( g_Life[id] >= LIFE_LIMIT )
			{
				ColorChat(id, GREEN, "[Life-Menu]^x01 Ai ajuns la limita^x04 maxima." )
				return PLUGIN_HANDLED
			}
			
			ColorChat(id, GREEN, "[Life-Menu]^x01 Ai cumparat^x04 1 Viata")
			
			g_Life[id] += 1
			
			fm_cs_set_user_money(id, bani - LIFE_COST)
			Life_Shop( id ) 
		}
		case 2:
		{
			if ( g_Life[id] == 0 )
			{
				ColorChat(id, GREEN, "[Life-Menu]^x01 Nu ai nici o^x04 viata.")
				return PLUGIN_HANDLED
			}
			
			ColorChat(id, GREEN, "[Life-Menu]^x01 Ai vandut^x04 1 Viata.")
			
			g_Life[id] -= 1
			
			fm_cs_set_user_money(id, bani + LIFE_SELL)
			Life_Shop( 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);
	ColorChat(id, GREEN, "[Life-Menu]^x03 NU 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)


Click aici pentru colorchat.inc

Sau compileaza-l online aici


O doamne , romanii cat de ofticati si fara rabdare pot sa fie ... "Nimeni nu vrea" ? Te-ai uitat macar inainte ca i-am explicat ca am facut mai mult decat sa modific "#define FRAG_LIMIT" ? Toti umblati dupa posturi , dar TOTI !


Bine ca tu nu umbli :))
Post Reply

Return to “Modificari pluginuri”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 12 guests