23/03/2014, 04:47 AM
(Última modificación: 26/03/2014, 05:12 PM por 3mcy daimon't.)
Bueno gente junto con saludarles esta vez quise hacer este thread para compartir stocks, ya que vi que no hay un thread asi.
bueno publicare todos los que tengo si ustedes tienen alguno pasenme para actualzar.
Cantidad de Stocks: 11
=================================================================================================================
stock drop_weapons: bota el arma del cliente
stock count_characters: cuenta la cantidad de caracteres en un string
stock contain_special_characters: revisa si hay algun caracter especial para proceder a ejecutar una accion como restringir, otorgar, etc..
stock get_killer_weapon: obtiene el nombre del arma con la que mato por lo general se usa en eventos donde muere el player para checkear
con que arma mato y asi setear alguna condicion.
stock print_color: muestra mensajes de color tanto al cliente como a todos los clientes.
stock fm_get_speed: obtiene la velocidad de una entidad
stock fm_find_ent_by_owner: Encuentra la entidad del propietario muy util cuando quieres darle cierta cantidad de disparos a
un arma
stock is_player_stuck: checkea si un player esta trabado o "bugeado"
stock ham_give_weapon: da un arma al cliente
stock ham_strip_weapon: // le quita el arma al cliente
stock mdlsize: detecta el tamaño de un model
stock set_screenfade: setea un efecto luz de pantalla
PD: Cualquier stock que tengan si quieren dejenlo y lo agrego para la recopilacion... saludos!
PD2: No se si estoy en la seccion correcta :c
bueno publicare todos los que tengo si ustedes tienen alguno pasenme para actualzar.
Cantidad de Stocks: 11
=================================================================================================================
stock drop_weapons: bota el arma del cliente
Código PHP:
//Ejemplo:
drop_weapons(id, 1) bota el arma primaria del cliente
drop_weapons(id, 2) bota el arma secundaria del cliente
//--------
stock drop_weapons(id, dropwhat)
{
static weapons[32], num, i, weaponid
num = 0
get_user_weapons(id, weapons, num)
const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_MAC10)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_MAC10)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|
(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90)
for (i = 0; i < num; i++)
{
weaponid = weapons[i]
if (dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
{
static wname[32]
get_weaponname(weaponid, wname, sizeof wname - 1)
engclient_cmd(id, "drop", wname)
}
}
}
stock count_characters: cuenta la cantidad de caracteres en un string
Código PHP:
stock count_characters(const szString[], const len = sizeof(szString))
{
new count, i
for (i = 0 ; i < len; i++)
{
if (isalnum(szString[i]))
count++
}
return count;
}
stock contain_special_characters: revisa si hay algun caracter especial para proceder a ejecutar una accion como restringir, otorgar, etc..
Código PHP:
stock contain_special_characters( id, const str[ ], const type[ ] )
{
static iLen;
iLen = strlen( str )
for( new i = 0; i < iLen; i++ )
{
if( !isalpha( str[ i ] ) && !isdigit( str[ i ] ) )
{
client_print( id, print_chat, "%s Caracter especial invalido en %s: ^"%c^"", TAG, type, str[ i ] );
console_print( id, "%s Caracter especial invalido en %s: ^"%c^"", TAG, type, str[ i ] );
return 1;
}
}
return 0;
}
stock get_killer_weapon: obtiene el nombre del arma con la que mato por lo general se usa en eventos donde muere el player para checkear
con que arma mato y asi setear alguna condicion.
Código PHP:
//Ejemplo
static wpn[24]
get_killer_weapon(atacante, pev(victima, pev_dmg_inflictor), wpn, 23)
if(equal(wpn, "ak47")) // si el arma que mato es la ak47 en este caso no va el weapon_
//--------
stock get_killer_weapon(killer, inflictor, retVar[], retLen)
{
static killer_weapon_name[32];
killer_weapon_name = "world";
if (pev_valid(killer) && (pev(killer, pev_flags) & FL_CLIENT))
{
if (pev_valid(inflictor))
{
if (inflictor == killer)
{
new weapon = get_user_weapon(killer);
get_weaponname(weapon, killer_weapon_name, 31);
}
else pev(inflictor, pev_classname, killer_weapon_name, 31);
}
}
else
{
if (pev_valid(killer)) pev(inflictor, pev_classname, killer_weapon_name, 31);
else if (killer == 0) killer_weapon_name = "worldspawn";
}
// Strip the monster_* or weapon_* from the inflictor's classname
if (equal(killer_weapon_name, "weapon_", 7))
format(killer_weapon_name, 31, "%s", killer_weapon_name[7]);
else if (equal(killer_weapon_name, "monster_", 8))
format(killer_weapon_name, 31, "%s", killer_weapon_name[8]);
else if (equal(killer_weapon_name, "func_", 5))
format(killer_weapon_name, 31, "%s", killer_weapon_name[5]);
formatex(retVar, retLen, "%s", killer_weapon_name);
}
stock addpoints: bueno este stock en lo personal me gusta mucho ya que su funcion es agregar un punto al valor con 4 o mas digitos
(1000 -> 1.000)
[php]
//Ejemplo:
addpoints(variable[id]) // si la variable es mas de 999 se mostraria asi 1.000 | 10.000 | 100.000 | 1.000.000, etc...
//-------
stock addpoints(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
}
stock print_color: muestra mensajes de color tanto al cliente como a todos los clientes.
Código PHP:
//Ejemplo
print_color(id, "!gMensaje de color verde para que solo el jugador lo vea")
print_color(0, "!gMensaje de color verde para que todos los jugadores lo vean")
print_color(id, "!yMensaje de color amarillo para que solo el jugador lo vea")
print_color(0, "!yMensaje de color amarillo para que todos los jugadores lo vean")
print_color(id, "!tMensaje del color del team que corresponda ct = azul | tt = rojo")
//------
stock print_color(const id, const input[], any:...)
{
static msg[191]
vformat(msg, 190, input, 3)
replace_all(msg, 190, "!g", "^4")
replace_all(msg, 190, "!y", "^1")
replace_all(msg, 190, "!t", "^3")
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, id)
write_byte(id)
write_string(msg)
message_end()
}
stock fm_get_speed: obtiene la velocidad de una entidad
Código PHP:
stock fm_get_speed(entity)
{
static Float:velocity[3]
pev(entity, pev_velocity, velocity)
return floatround(vector_length(velocity));
}
stock fm_find_ent_by_owner: Encuentra la entidad del propietario muy util cuando quieres darle cierta cantidad de disparos a
un arma
Código PHP:
//ejemplo:
cs_set_weapon_ammo(fm_find_ent_by_owner(-1, "weapon_p228", id), 5); // seteamos a la entidad del arma p228 5 disparos
//--------
stock fm_find_ent_by_owner(entity, const classname[], owner)
{
while ((entity = engfunc(EngFunc_FindEntityByString, entity, "classname", classname)) && pev(entity, pev_owner) != owner) { }
return entity;
}
stock is_player_stuck: checkea si un player esta trabado o "bugeado"
Código PHP:
stock is_player_stuck(id)
{
static Float:originF[3]
pev(id, pev_origin, originF)
engfunc(EngFunc_TraceHull, originF, originF, 0, (pev(id, pev_flags) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN, id, 0)
if (get_tr2(0, TR_StartSolid) || get_tr2(0, TR_AllSolid) || !get_tr2(0, TR_InOpen))
return true;
return false;
}
stock ham_give_weapon: da un arma al cliente
Código PHP:
//Ejemplo
ham_give_weapon(id, "weapon_elite") // le da el arma elite al cliente
//-------
stock ham_give_weapon(id,weapon[])
{
if(!equal(weapon,"weapon_",7)) return 0;
new wEnt = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,weapon));
if(!pev_valid(wEnt)) return 0;
set_pev(wEnt,pev_spawnflags,SF_NORESPAWN);
dllfunc(DLLFunc_Spawn,wEnt);
if(!ExecuteHamB(Ham_AddPlayerItem,id,wEnt))
{
if(pev_valid(wEnt)) set_pev(wEnt,pev_flags,pev(wEnt,pev_flags) | FL_KILLME);
return 0;
}
ExecuteHamB(Ham_Item_AttachToPlayer,wEnt,id)
return 1;
}
stock ham_strip_weapon: // le quita el arma al cliente
Código PHP:
//Ejemplo:
if(user_has_weapon(id, CSW_ELITE)) ham_strip_weapon(id, "weapon_elite") // si el usuario tiene el arma elite se la quita
//--------
stock ham_strip_weapon(id,weapon[])
{
if(!equal(weapon,"weapon_",7)) return 0;
new wId = get_weaponid(weapon);
if(!wId) return 0;
new wEnt;
while((wEnt = engfunc(EngFunc_FindEntityByString,wEnt,"classname",weapon)) && pev(wEnt,pev_owner) != id) {}
if(!wEnt) return 0;
if(get_user_weapon(id) == wId) ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt);
if(!ExecuteHamB(Ham_RemovePlayerItem,id,wEnt)) return 0;
ExecuteHamB(Ham_Item_Kill,wEnt);
set_pev(id,pev_weapons,pev(id,pev_weapons) & ~(1<<wId));
// Esta parte es para la Granada/C4
/*if(wId == CSW_C4)
{
cs_set_user_plant(id,0,0);
cs_set_user_bpammo(id,CSW_C4,0);
}
else if(wId == CSW_SMOKEGRENADE || wId == CSW_FLASHBANG || wId == CSW_HEGRENADE)
cs_set_user_bpammo(id,wId,0);*/
return 1;
}
stock mdlsize: detecta el tamaño de un model
Código PHP:
stock mdlsize(filename[],Float:vec[3]){
new file = fopen(filename,"rb")
fseek(file,160,SEEK_SET)
new bboff
fread(file,bboff,BLOCK_INT)
fseek(file,bboff+8,SEEK_SET)
new Float:size[6]
fread_blocks(file,_:size,6,BLOCK_INT)
fclose(file)
vec[0]=size[3]-size[0]
vec[1]=size[4]-size[1]
vec[2]=size[5]-size[2]
}
stock set_screenfade: setea un efecto luz de pantalla
Código PHP:
stock set_screenfade( id, iDuracion, iAlpha )
{
message_begin( id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, get_user_msgid( "ScreenFade" ), _, id );
write_short( iDuracion * 4096 );
write_short( iDuracion * 4096 );
write_short( 0x0000 );
write_byte( random_num( 0, 255 ) ); // Color 1
write_byte( random_num( 0, 255 ) ); // Color 2
write_byte( random_num( 0, 255 ) ); // Color 3
write_byte( iAlpha );
message_end( );
}
PD: Cualquier stock que tengan si quieren dejenlo y lo agrego para la recopilacion... saludos!
PD2: No se si estoy en la seccion correcta :c
Sistema de Logros v2.0 + Guardado
Clases de humanos con/sin niveles
Evitar que bloqueen salida de zombies (Basebuilder)
Super FYH + Bonus [normal & zp]
Menu de comandos optimizados )?
[polvo]
Casi 8 años retirado... puliendome de apoco denuevo...
[/polvo]
Clases de humanos con/sin niveles
Evitar que bloqueen salida de zombies (Basebuilder)
Super FYH + Bonus [normal & zp]
Menu de comandos optimizados )?
[polvo]
Casi 8 años retirado... puliendome de apoco denuevo...
[/polvo]