Raised This Month: $51 Target: $400
 12% 

Recopilación de códigos.


  
 
 
Thread Tools Display Modes
StickP0le
Senior Member
Join Date: Jan 2010
Location: cuantocabron.com
Old 01-25-2012 , 21:58   Re: Recopilación de codigos.
#11

agregar puntos a los numeros con mas de 3 decimales
Code:
  stock Puntuacion(number) {     new str[15], strpointed[15], len     num_to_str(number, str, 14)     len= strlen(str)     new c     for (new i=0;i<len;i++)     {         if (i!=0 && ( (len-i)%3==0) )         {             add(strpointed, 14, ".", 1)             c++             add(strpointed[i+c], 1, str[i], 1)         }         else             add(strpointed[i+c], 1, str[i], 1)     }         return strpointed }
Uso:

Code:
client_print(id, print_center, "Gastaste %s balas", Puntuacion(1000))
StickP0le is offline
shinoda
Spanish Moderator
Join Date: Nov 2009
Location: ag_crossfire
Old 01-25-2012 , 22:47   Re: Recopilación de codigos.
#12

Quote:
Originally Posted by StickP0le View Post
agregar puntos a los numeros con mas de 3 decimales
Code:
  stock Puntuacion(number) {     new str[15], strpointed[15], len     num_to_str(number, str, 14)     len= strlen(str)     new c     for (new i=0;i<len;i++)     {         if (i!=0 && ( (len-i)%3==0) )         {             add(strpointed, 14, ".", 1)             c++             add(strpointed[i+c], 1, str[i], 1)         }         else             add(strpointed[i+c], 1, str[i], 1)     }         return strpointed }
Uso:

Code:
client_print(id, print_center, "Gastaste %s balas", Puntuacion(1000))
Devolver cadenas es un mal hábito, además ya existe uno y es mucho mejor.
EDIT: http://forums.alliedmods.net/showpos...45&postcount=5
__________________
Oh hell no this shit is awesome !!!

Last edited by shinoda; 01-25-2012 at 22:52.
shinoda is offline
Send a message via MSN to shinoda Send a message via Skype™ to shinoda
XINLEI
me too
Join Date: Jun 2011
Location: Colombian Coffee storage
Old 01-25-2012 , 22:59   Re: Recopilación de codigos.
#13

Esto tiene mas espectactivas que mi intento fallido.

Por lo que supongo, ¿estas cosas no pertenecen aqui?
XINLEI is offline
shinoda
Spanish Moderator
Join Date: Nov 2009
Location: ag_crossfire
Old 01-25-2012 , 23:14   Re: Recopilación de codigos.
#14

PHP Code:
/*
* Devuelve el número de celda que contiene el mayor valor
*
* @param input  El array de entrada
* @param len    El tamaño del array
* @rand         Si es true y el "mayor valor" se repite,
                devolverá aleatoriamente el número de celda de uno de ellos
*/

stock get_cellnum( const input[], const len, const bool:rand false )
{
    new 
iTemp input[0]
    new 
iCelliiNum
    
    
for( 1<= leni++ )
    {
        if( (
iNum input[i]) >= iTemp )
        {
            
iTemp iNum
            iCell 
i
        
}
    }
    
    if( 
rand )
    {
        new 
_temp[MAX_SIZE]
        
_temp[0]    = iCell
        i        
1
        
        
while( --iCell > -)
        {
            if( 
input[iCell] == iTemp )
            {
                
_temp[i++] = iCell
            
}
        }

        
iCell _temp== random(i) ]
    }
    
    return 
iCell

Ejemplo:
PHP Code:
#include <amxmodx>

#define MAX_SIZE    5

public plugin_init()
{
    
register_srvcmd"test""srvcmd_test" )
}

public 
srvcmd_test()
{
    new 
iNums[MAX_SIZE] = { 5452}
    
    new 
iCell get_cellnumiNumscharsmax(iNums), true )
    
    
// La celda con el mayor valor es ...
    
server_print"iNums[%i] = %i"iCelliNums[iCell] )
}

stock get_cellnum( const input[], const len, const bool:rand false )
{
    new 
iTemp input[0]
    new 
iCelliiNum
    
    
for( 1<= leni++ )
    {
        if( (
iNum input[i]) >= iTemp )
        {
            
iTemp iNum
            iCell 
i
        
}
    }
    
    if( 
rand )
    {
        new 
_temp[MAX_SIZE]
        
_temp[0]    = iCell
        i        
1
        
        
while( --iCell > -)
        {
            if( 
input[iCell] == iTemp )
            {
                
_temp[i++] = iCell
            
}
        }

        
iCell _temp== random(i) ]
    }
    
    return 
iCell

Mostrará aleatoriamente cualquiera de estos tres:
Code:
iNums[0] = 5
iNums[2] = 5
iNums[4] = 5
__________________
Oh hell no this shit is awesome !!!
shinoda is offline
Send a message via MSN to shinoda Send a message via Skype™ to shinoda
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 01-25-2012 , 23:39   Re: Recopilación de codigos.
#15

Stock para hacer doble linea en print_center ( igual que hudmessage ej hola\nchau )

Se requiere fakemeta.

Code:
client_print_center(id, msg[], any:...) {     static szMsg[128]     vformat(szMsg, 127, msg, 3)     engfunc(EngFunc_ClientPrintf, id, 1, szMsg) }

Uso:
Code:
client_print_center( id, "Alliedmods^nLuqqas" );
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
StickP0le
Senior Member
Join Date: Jan 2010
Location: cuantocabron.com
Old 01-26-2012 , 00:57   Re: Recopilación de codigos.
#16

luqqas en vformat que es el 3 al final?
StickP0le is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 01-26-2012 , 03:30   Re: Recopilación de codigos.
#17

Quote:
Originally Posted by StickP0le View Post
luqqas en vformat que es el 3 al final?
Es el numero que argumentos de tu stock.
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
StickP0le
Senior Member
Join Date: Jan 2010
Location: cuantocabron.com
Old 01-26-2012 , 13:37   Re: Recopilación de códigos.
#18

ahh ahora me doy cuenta, gracias lucas
StickP0le is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 01-26-2012 , 15:15   Re: Recopilación de códigos.
#19

Stock para dar BPAMMO y MAXCLIP predeterminado:

Code:
/*  * Gives a weapon and sets ammo  *  * @param      Client - Player Index  * @param      CSWConstant - Constant CSW ID for the weapon (seen in cstrike includes)  * @param      FullAmmo - Boolean whether to set full ammo or use next two parameters (true if full ammo, false if not. default: false)  * @param      ClipAmmo - Ammo to be set in current clip  * @param      BPAmmo - Ammo to be set in backpack  *  * @note        enum ReturnTypes  *        {  *          Return_InvalidClientIndex,  *          Return_InvalidWeapon,  *          Return_Successful  *        };  *  * @return   Returns values from enum above (ReturnTypes)  */ stock ReturnTypes:GiveClientWeapon( const Client, const CSWConstant = 0, const bool:FullAmmo = false, const ClipAmmo = 0, const BPAmmo = 0 ) {     if( !( 1 <= CSWConstant <= 30 ) || CSWConstant == 2 )     {         return Return_InvalidWeapon;     }         if( !( 1 <= Client <= get_maxplayers( ) ) )     {         return Return_InvalidClientIndex;     }         if( CSWConstant == CSW_C4 || CSWConstant ==  CSW_KNIFE )     {         give_item( Client, WeaponClass[ CSWConstant ] );     }     else     {         new WeaponId = give_item( Client, WeaponClass[ CSWConstant ] );                 if( FullAmmo )         {             cs_set_weapon_ammo( WeaponId, AmmoClipSize[ CSWConstant ] );             cs_set_user_bpammo( Client, CSWConstant, AmmoBPSize[ CSWConstant ] );         }         else         {             cs_set_weapon_ammo( WeaponId, ( ClipAmmo < 0 ? 0 : ClipAmmo ) );             cs_set_user_bpammo( Client, CSWConstant, ( BPAmmo < 0 ? 0 : BPAmmo ) );         }     }         return Return_Successful; }

Uso:

Code:
GiveClientWeapon( Client, CSW_AWP, true ); // full ammo GiveClientWeapon( Client, CSW_AWP, false, 1, 10 ); // 1ammo / 10 bp

INCLUDE REQUERIDO
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.

Last edited by lucas_7_94; 01-26-2012 at 15:15.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
Kiske
Veteran Member
Join Date: May 2009
Old 01-26-2012 , 15:49   Re: Recopilación de códigos.
#20

No podes agregar mis stock que puse en la otra recopilación ?
Kiske is offline
Send a message via Skype™ to Kiske
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:59.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode