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

[Help] Need edit


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
The Professional
Member
Join Date: Nov 2015
Location: İstanbul
Old 02-23-2016 , 09:50   [Help] Need edit
Reply With Quote #1

I have present box plugin. I want to: when new round get spawn all boxes. All round.

I do not know how to use this command

PHP Code:
register_logevent("round_start"2"1=Round_Start"
Plugin;

PHP Code:
/* AMX Mod X
*   Pick up present
*
*  /   \   /   \       ___________________________
* /   / \_/ \   \     /                           \
* \__/\     /\__/    /  GIVE ME A CARROT OR I WILL \
*      \O O/         \      BLOW UP YOUR HOUSE     /
*   ___/ ^ \___      / ___________________________/
*      \___/        /_/
*      _/ \_
*   __//   \\__
*  /___\/_\/___\
*
* (c) Copyright 2008 by FakeNick
*
* This file is provided as is (no warranties)
*
*     DESCRIPTION
*    This plugin allows admin add/remove/rotate/save presents on map ( ADMIN_KICK flag required).
*    When player touches present, it will dissapear and player will (or no) receive some weapons
*    or stuff (soon more than now), then present respawns with nice blast :]. Models for
*    presents are randomly chosen, so user can add as many, as he want.
*
*     VERY IMPORTANT!
*    Create an folder called "presents" in addons/amxmodx/config/ directory, otherwise
*    plugin won't be able to save presents origins!
*
*     COMMANDS
*    !add - adds a present at admin aim origin
*    !remove - removes a present (admin must aim at present)
*    !removeall - removes all presents from map
*    !save - saves all present created on map
*    !rotate - rotates a present (admin must aim at present)
*
*     MODULES
*    fakemeta
*
*     CVARS
*    present_on - turn plugin on/off
*    present_respawn_time - time between present disapear and respawn (must be float!)
*    present_blast - turns blast on/off
*    present_blast_color - color of the blast (default 255 255 255)
*    present_money - amount of received money
*
*    Changelog 
*    Version 2.0
*     - Actuall version is 2.0, because i've totally cleaned up the code
*     - New weapon randomizing system
*
*    Version 2.01
*     - Fixed small bug with backpack ammo    
*     - Added large and medium blast ring (nice effect ;])
*     - Added CVAR for version recognize
*/

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <fakemeta_util>

/*================================================================================
 [Plugin Customization]
=================================================================================*/

//Models and sounds are randomly chosen, add as many, as you want

new const model_present[][] = { "models/present/w_present.mdl","models/present/w_present2.mdl" }

new const 
sound_respawn[][] = { "present/respawn.wav""present/respawn2.wav" }
new const 
sound_pick[][] = { "present/pick.wav" }

//Customization end here!

//Some offsets 
#if cellbits == 32
const OFFSET_CSMONEY 115
const OFFSET_AWM_AMMO  377 
const OFFSET_SCOUT_AMMO 378
const OFFSET_PARA_AMMO 379
const OFFSET_FAMAS_AMMO 380
const OFFSET_M3_AMMO 381
const OFFSET_USP_AMMO 382
const OFFSET_FIVESEVEN_AMMO 383
const OFFSET_DEAGLE_AMMO 384
const OFFSET_P228_AMMO 385
const OFFSET_GLOCK_AMMO 386
const OFFSET_FLASH_AMMO 387
const OFFSET_HE_AMMO 388
const OFFSET_SMOKE_AMMO 389
#else
const OFFSET_CSMONEY 140
const OFFSET_AWM_AMMO  426
const OFFSET_SCOUT_AMMO 427
const OFFSET_PARA_AMMO 428
const OFFSET_FAMAS_AMMO 429
const OFFSET_M3_AMMO 430
const OFFSET_USP_AMMO 431
const OFFSET_FIVESEVEN_AMMO 432
const OFFSET_DEAGLE_AMMO 433
const OFFSET_P228_AMMO 434
const OFFSET_GLOCK_AMMO 435
const OFFSET_FLASH_AMMO 46
const OFFSET_HE_AMMO 437
const OFFSET_SMOKE_AMMO 438
#endif
const OFFSET_LINUX  5

//Primary weapons array (thanks Mercyllez)
new const g_primary_items[][] = { "weapon_galil""weapon_famas""weapon_m4a1""weapon_ak47""weapon_sg552""weapon_aug""weapon_scout",
                
"weapon_m3""weapon_xm1014""weapon_tmp""weapon_mac10""weapon_ump45""weapon_mp5navy""weapon_p90",
                
"weapon_m249""weapon_sg550""weapon_g3sg1"}

//Secondary weapons array (thanks Mercyllez)                
new const g_secondary_items[][] = { "weapon_glock18""weapon_usp""weapon_p228""weapon_deagle""weapon_fiveseven""weapon_elite" }

//Max BackPack ammo array (thanks Mercyllez) 
new const MAXBPAMMO[] = { -152, -1901321100901120100100909090100120,
            
301202003290120902359090, -1100 }
//Amount of gived ammo (thanks Mercyllez)
new const GIVEAMMO[] = { -152, -190, -132, -110090, -1120100100909090100120,
            
30120200329012090, -1359090, -1,100 }
//Ammo ID array (thanks Mercyllez)
new const AMMOID[] = { -19, -121251464131076444610,
            
11035410211842, -1}

//Weapon BitSum (thanks Mercyllez)            
const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(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)
const 
SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)


//Pcvar variables        
new pcvar_on,pcvar_respawn_time,pcvar_blast,pcvar_blast_color,pcvar_money

//Rest of variables
new g_explo,g_money,g_ammo

//Task ID enum
enum (+= 100)
{
    
TASK_PRIMARY 100,
    
TASK_SECONDARY
}


//Version information
new const VERSION[] = "2.01"

public plugin_init()
{
    
register_plugin("Pick up present"VERSION"FakeNick")
    
pcvar_on register_cvar("present_on","1")
    
    
//Make sure that the plugin is on
    
if(!get_pcvar_num(pcvar_on))
        return
    
    
//Register dictionary
    
register_dictionary("present.txt")
    
    
//Register admin commands
    
register_clcmd("say !add","func_add_present")
    
register_clcmd("say !remove","func_remove_present")
    
register_clcmd("say !removeall","func_remove_present_all")
    
register_clcmd("say !save","func_save_origins")
    
register_clcmd("say !rotate","func_rotate_present")
        
    
//Some forwards
    
register_forward(FM_Touch,"forward_touch")
    
register_forward(FM_Think,"forward_think")
        
    
//Cvars register
    
pcvar_respawn_time register_cvar("present_respawn_time","60.0")
    
pcvar_blast register_cvar("present_blast","1")
    
pcvar_blast_color register_cvar("present_blast_color","255 255 255")
    
pcvar_money register_cvar("present_money","300")
    
    
//Only for version recognize
    
register_cvar("present_version"VERSIONFCVAR_SERVER|FCVAR_SPONLY)
    
    
//Other stuff
    
g_money get_user_msgid("Money")
    
g_ammo get_user_msgid("AmmoPickup")
}
public 
plugin_precache()
{
    new 
i
    
    
for(0sizeof model_presenti++)
        
engfunc(EngFunc_PrecacheModel,model_present[i])
    
    for (
0sizeof sound_respawni++)
        
engfunc(EngFunc_PrecacheSoundsound_respawn[i])
    for (
0sizeof sound_picki++)
        
engfunc(EngFunc_PrecacheSoundsound_pick[i])
    
    
g_explo engfunc(EngFunc_PrecacheModel,"sprites/shockwave.spr")
}
public 
plugin_cfg()
{
    
//Create some variables
    
static sConfigsDir[64], sFile[128]
    
    
//Get config folder directory
    
get_configsdir(sConfigsDirsizeof sConfigsDir 1)
    
    
//Get mapname
    
static sMapName[32]
    
get_mapname(sMapNamesizeof sMapName 1)
    
    
//Format .cfg file directory
    
formatex(sFilesizeof sFile 1"%s/presents/%s_presents_origins.cfg"sConfigsDirsMapName)
    
    
//If file doesn't exist return
    
if(!file_exists(sFile))
        return
    
    
//Some variables
    
static sFileOrigin[3][32], sFileAngles[3][32], iLineiLengthsBuffer[256]
    static 
sTemp1[128], sTemp2[128]
    static 
Float:fOrigin[3], Float:fAngles[3]
    
    
//Read file
    
while(read_file(sFileiLine++, sBuffersizeof sBuffer 1iLength))
    {
        if((
sBuffer[0]==';') || !iLength)
            continue
        
        
strtok(sBuffersTemp1sizeof sTemp1 1sTemp2sizeof sTemp2 1'|'0)
        
        
parse(sTemp1sFileOrigin[0], sizeof sFileOrigin[] - 1sFileOrigin[1], sizeof sFileOrigin[] - 1sFileOrigin[2], sizeof sFileOrigin[] - 1)
        
        
fOrigin[0] = str_to_float(sFileOrigin[0])
        
fOrigin[1] = str_to_float(sFileOrigin[1])
        
fOrigin[2] = str_to_float(sFileOrigin[2])
        
        
parse(sTemp2sFileAngles[0], sizeof sFileAngles[] - 1sFileAngles[1], sizeof sFileAngles[] - 1sFileAngles[2], sizeof sFileAngles[] - 1)
        
        
fAngles[0] = str_to_float(sFileAngles[0])
        
fAngles[1] = str_to_float(sFileAngles[1])
        
fAngles[2] = str_to_float(sFileAngles[2])
        
        
//Spawn presents on origins saved in .cfg file
        
func_spawn(fOrigin)
    }
}

/*================================================================================
 [Tasks]
=================================================================================*/

public task_primary(id)
{
    
//Check player id
    
id -= TASK_PRIMARY
    
    
//Make usre that player is alive
    
if(!is_user_alive(id))
        return
    
    
//Give him primary weapon
    
func_give_item_primary(idrandom_num(0sizeof g_primary_items 1))
}
public 
task_secondary(id)
{
    
//Check player id
    
id -= TASK_SECONDARY
    
    
//Make usre that player is alive
    
if(!is_user_alive(id))
        return
        
    
//Give him secondary weapon    
    
func_give_item_secondary(idrandom_num(0sizeof g_secondary_items 1))
}

/*================================================================================
 [Main functions]
=================================================================================*/
public func_add_present(id)
{    
    
//Check command access
    
if(!access(id,ADMIN_KICK))
        return
    
    
//Create some variables
    
new Float:fOrigin[3],origin[3],name[32],map[32]
    
    
//Get player origins
    
get_user_origin(id,origin,3)
    
    
//Make float origins from integer origins
    
IVecFVec(origin,fOrigin)
    
    
//Check the player aiming
    
if((engfunc(EngFunc_PointContentsfOrigin) != CONTENTS_SKY) && (engfunc(EngFunc_PointContentsfOrigin) != CONTENTS_SOLID))
    {
        
//Get his name and map name for log creating
        
get_user_name(id,name,sizeof name 1)
        
        
get_mapname(map,sizeof map 1)
        
        
//Create log file or log admin command
        
log_to_file("presents.log","[%s] has created present on map %s",name,map)
        
        
//Finally spawn present
        
func_spawn(fOrigin)
        
        
//Print success and save info information
        
client_print(id,print_chat,"%L",LANG_PLAYER,"SUCC_ADD",origin[0],origin[1],origin[2])
        
client_print(id,print_chat,"%L",LANG_PLAYER,"SAVE_INFO")
    }else{
        
//That location is unavaiables, so print information
        
client_print(id,print_chat,"%L",LANG_PLAYER,"LOCATION_UN")
    }
    
    
}
public 
func_remove_present(id)
{
    
//Check command access
    
if(!access(id,ADMIN_KICK))
        return
    
    
//Create some variables
    
static entbody,name[32],map[32]
    
    
//Check player aiming
    
get_user_aiming(identbody)
    
    
//Check ent validity
    
if(pev_valid(ent))
    {
        
//Check entity classname
        
static classname[32]
        
pev(entpev_classnameclassnamesizeof classname 1)
        
        
//Player is aiming at present
        
if(!strcmp(classname"present"1))
        {
            
//Get user name and map name for log creating
            
get_user_name(id,name,sizeof name 1)
            
get_mapname(map,sizeof map 1)
            
            
//Create log file or log admin command
            
log_to_file("presents.log","[%s] has removed present from map %s",name,map)
            
            
//Finalyl remove the entity
            
engfunc(EngFunc_RemoveEntityent)
            
            
//Print success inforamtion
            
client_print(idprint_chat"%L",LANG_PLAYER,"SUCC_REMOVE")
        }else
        {
            
//Player must aim at present
            
client_print(idprint_chat"%L",LANG_PLAYER,"PRESENT_AIM")
        }
    }
}
public 
func_remove_present_all(id)
{
    
//Check command access
    
if(!access(idADMIN_KICK))
        return
    
    
//Create some variables
    
new ent = -1,count,name[32],map[32]
    
count 
    
    
//Find presents
    
while((ent fm_find_ent_by_class(ent,"present")))
    {
        
//Increase count
        
count++
        
//Remove presents
        
engfunc(EngFunc_RemoveEntity,ent)
    }
    
//Print information
    
client_print(id,print_chat,"%L",LANG_PLAYER,"REMOVE_ALL",count)
    
    
//Get player name and map name
    
get_user_name(id,name,sizeof name 1)
    
get_mapname(map,sizeof map 1)
    
    
//Log command to file
    
log_to_file("presents.log","[%s] has removed all presents from map %s",name,map)
    
    
//Print save information
    
client_print(id,print_chat,"%L",LANG_PLAYER,"SAVE_INFO")
}
public 
func_save_origins(id)
{
    
//Check command access
    
if(!access(idADMIN_KICK))
        return
    
    
//Create some variables
    
static sConfigsDir[64], sFile[128],name[32],map[32]
    
    
//Get config folder directory
    
get_configsdir(sConfigsDirsizeof sConfigsDir 1)
    
    
//Get map name
    
static sMapName[32]
    
get_mapname(sMapNamesizeof sMapName 1)
    
    
//Format .cfg file directory
    
formatex(sFilesizeof sFile 1"%s/presents/%s_presents_origins.cfg"sConfigsDirsMapName)
    
    
//If file already exist, delete file
    
if(file_exists(sFile))
        
delete_file(sFile)
    
    
//Some variables
    
new iEnt = -1Float:fEntOrigin[3], Float:fEntAngles[3], iCount
    
static sBuffer[256]
    
    
//Find presents on this map
    
while((iEnt engfunc(EngFunc_FindEntityByStringiEnt"classname""present")))
    {
        
//Get origins and angles
        
pev(iEntpev_originfEntOrigin)
        
pev(iEntpev_anglesfEntAngles)
        
        
formatex(sBuffersizeof sBuffer 1"%f %f %f | %f %f %f"fEntOrigin[0], fEntOrigin[1], fEntOrigin[2], fEntAngles[0], fEntAngles[1], fEntAngles[2])
    
        
//Create file
        
write_file(sFilesBuffer, -1)
        
        
//Increase count variable
        
iCount++
    }
    
//Get user name and map name
    
get_user_name(id,name,sizeof name 1)
    
get_mapname(map,sizeof map 1)
    
    
//Log admin command
    
log_to_file("presents.log","[%s] has saved presents on map %s",name,map)
    
    
//Print success information
    
client_print(idprint_chat"%L",LANG_PLAYER,"SUCC_SAVE"iCount,sMapName)
}
public 
func_rotate_present(id)
{
    
//Check command access
    
if(!access(idADMIN_KICK))
        return
        
    
//Some variables
    
static entbody,name[32],map[32]
    
    
//Get user aiming
    
get_user_aiming(identbody)
    
    
//Check entity validity
    
if(pev_valid(ent))
    {
        
//Check classname
        
static sClassname[32]
        
pev(entpev_classnamesClassnamesizeof sClassname 1)
        
        
//Player is aiming at present
        
if(!strcmp(sClassname"present"1))
        {
            
//Get angles
            
static Float:fAngles[3]
            
pev(entpev_anglesfAngles)
            
            
//Rotate present
            
fAngles[1] += 90.0
            set_pev
(entpev_anglesfAngles)
            
            
//Get user name and map name
            
get_user_name(id,name,sizeof name 1)
            
get_mapname(map,sizeof map 1)
            
            
//Log admin command
            
log_to_file("presents.log","[%s] has rotated present on map %s",name,map)
            
            
//Print success information
            
client_print(idprint_chat"%L",LANG_PLAYER,"SUCC_ROTATE")
        }else{
            
//Print failure information
            
client_print(idprint_chat"%L",LANG_PLAYER,"PRESENT_AIM")
        }
    }
}
public 
func_spawn(Float:origin[3])
{
    
//Create new entity    
    
new ent engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
    
    
//Set classname to "present"
    
set_pev(ent,pev_classname,"present")
    
    
//Set entity origins
    
engfunc(EngFunc_SetOrigin,ent,origin)
    
    
//Create blast effect
    
func_make_blast(origin)
    
    
//Emit spawn sound
    
engfunc(EngFunc_EmitSound,ent,CHAN_AUTO,sound_respawn[random_num(0sizeof sound_respawn 1)],1.0,ATTN_NORM,0,PITCH_NORM)
    
    
//size variables
    
static Float:fMaxs[3] = { 2.02.04.0 }
    static 
Float:fMins[3] = { -2.0, -2.0, -4.0 }
        
    
//Set random player model
    
engfunc(EngFunc_SetModel,ent,model_present[random_num(0,sizeof model_present 1)])
    
    
//Spawn entity
    
dllfunc(DLLFunc_Spawn,ent)
    
//Make it solid
    
set_pev(ent,pev_solid,SOLID_BBOX)
    
//Set entity size
    
engfunc(EngFunc_SetSize,ent,fMins,fMaxs)
}
//From forstnades by Avalanche
public func_make_blast(Float:fOrigin[3])
{
    if(!
get_pcvar_num(pcvar_blast))
        return
    
    
//Create origin variable
    
new origin[3]
    
    
//Make float origins from integer origins
    
FVecIVec(fOrigin,origin)
    
    
//Get blast color
    
new Float:rgbF[3], rgb[3]
    
func_get_rgb(rgbF)
    
FVecIVec(rgbF,rgb)
    
    
//Finally create blast
    
    //smallest ring
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
    
write_byte(TE_BEAMCYLINDER)
    
write_coord(origin[0])
    
write_coord(origin[1])
    
write_coord(origin[2])
    
write_coord(origin[0])
    
write_coord(origin[1])
    
write_coord(origin[2] + 385)
    
write_short(g_explo)
    
write_byte(0)
    
write_byte(0)
    
write_byte(4)
    
write_byte(60)
    
write_byte(0)
    
write_byte(rgb[0])
    
write_byte(rgb[1])
    
write_byte(rgb[2])
    
write_byte(100)
    
write_byte(0)
    
message_end()
    
    
// medium ring
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
    
write_byte(TE_BEAMCYLINDER)
    
write_coord(origin[0])
    
write_coord(origin[1])
    
write_coord(origin[2])
    
write_coord(origin[0])
    
write_coord(origin[1])
    
write_coord(origin[2] + 470)
    
write_short(g_explo)
    
write_byte(0)
    
write_byte(0)
    
write_byte(4)
    
write_byte(60)
    
write_byte(0)
    
write_byte(rgb[0])
    
write_byte(rgb[1])
    
write_byte(rgb[2])
    
write_byte(100)
    
write_byte(0)
    
message_end()

    
// largest ring
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
    
write_byte(TE_BEAMCYLINDER)
    
write_coord(origin[0])
    
write_coord(origin[1])
    
write_coord(origin[2])
    
write_coord(origin[0])
    
write_coord(origin[1])
    
write_coord(origin[2] + 555)
    
write_short(g_explo)
    
write_byte(0)
    
write_byte(0)
    
write_byte(4)
    
write_byte(60)
    
write_byte(0)
    
write_byte(rgb[0])
    
write_byte(rgb[1])
    
write_byte(rgb[2])
    
write_byte(100)
    
write_byte(0)
    
message_end()
    
    
//Create nice light effect
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
    
write_byte(TE_DLIGHT)
    
write_coord(origin[0])
    
write_coord(origin[1])
    
write_coord(origin[2])
    
write_byte(floatround(240.0/5.0))
    
write_byte(rgb[0])
    
write_byte(rgb[1])
    
write_byte(rgb[2])
    
write_byte(8)
    
write_byte(60)
    
message_end()
}
//From frostnades by Avalanche
public func_get_rgb(Float:rgb[3])
{
    static 
color[12], parts[3][4]
    
get_pcvar_string(pcvar_blast_color,color,11)
    
    
parse(color,parts[0],3,parts[1],3,parts[2],3)
    
rgb[0] = floatstr(parts[0])
    
rgb[1] = floatstr(parts[1])
    
rgb[2] = floatstr(parts[2])
}
//Check player BackPack ammo (from ZP by Mercyllez)
public func_check_ammo(id)
{
    
//Create some variables
    
static weapons[32],num,weaponid
    num 
0
    
    get_user_weapons
(id,weapons,num)
    
    for (new 
0numi++)
    {
        
weaponid weapons[i]
        
        if ((
1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM// primary
        
{
            if (
fm_get_user_bpammo(idweaponid) < MAXBPAMMO[weaponid]-GIVEAMMO[weaponid])
            {
                
// Flash ammo in hud
                
message_begin(MSG_ONE_UNRELIABLEg_ammo_id)
                
write_byte(AMMOID[weaponid]) // ammo id
                
write_byte(GIVEAMMO[weaponid]) // ammo amount
                
message_end()
                
                
// Increase BP ammo
                
fm_set_user_bpammo(idweaponidfm_get_user_bpammo(idweaponid) + GIVEAMMO[weaponid])
                
            }else if (
fm_get_user_bpammo(idweaponid) < MAXBPAMMO[weaponid])
            {
                
// Flash ammo in hud
                
message_begin(MSG_ONE_UNRELIABLEg_ammo_id)
                
write_byte(AMMOID[weaponid]) // ammo id
                
write_byte(MAXBPAMMO[weaponid] - fm_get_user_bpammo(idweaponid)) // ammo amount
                
message_end()
                
                
// Reached the limit
                
fm_set_user_bpammo(idweaponidMAXBPAMMO[weaponid])
            }
        }else if ((
1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM// secondary
        
{    
            
// Check if we are close to the BP ammo limit
            
if (fm_get_user_bpammo(idweaponid) < MAXBPAMMO[weaponid]-GIVEAMMO[weaponid])
            {
                
// Flash ammo in hud
                
message_begin(MSG_ONE_UNRELIABLEg_ammo_id)
                
write_byte(AMMOID[weaponid]) // ammo id
                
write_byte(GIVEAMMO[weaponid]) // ammo amount
                
message_end()
                
                
// Increase BP ammo
                
fm_set_user_bpammo(idweaponidfm_get_user_bpammo(idweaponid) + GIVEAMMO[weaponid])
                
            }
            else if (
fm_get_user_bpammo(idweaponid) < MAXBPAMMO[weaponid])
            {
                
// Flash ammo in hud
                
message_begin(MSG_ONE_UNRELIABLEg_ammo_id)
                
write_byte(AMMOID[weaponid]) // ammo id
                
write_byte(MAXBPAMMO[weaponid] - fm_get_user_bpammo(idweaponid)) // ammo amount
                
message_end()
                
                
// Reached the limit
                
fm_set_user_bpammo(idweaponidMAXBPAMMO[weaponid])
            }
        }
    }
}
public 
func_give_item_primary(id,weapon)
{
    
//Give player primary weapon
    
fm_give_item(id,g_primary_items[weapon])
    
    
//Check his back pack ammo
    
func_check_ammo(id)
}
public 
func_give_item_secondary(id,weapon)
{
    
//Give player secondary weapon
    
fm_give_item(id,g_secondary_items[weapon])
    
    
//Check his back pack ammo
    
func_check_ammo(id)
}
/*================================================================================
 [Forwards]
=================================================================================*/
public forward_touch(ent,id)
{
    
//Check entity validity
    
if(!pev_valid(ent))
        return 
FMRES_IGNORED
    
    
//Create classname variable
    
static class[20]
    
    
//Get class
    
pev(ent,pev_classname,class,sizeof class - 1)
    
    
//Check classname
    
if(!equali(class,"present"))
        return 
FMRES_IGNORED
    
    
//Make sure that toucher is alive
    
if(!is_user_alive(id))
        return 
FMRES_IGNORED
    
    
//Make present not solid
    
set_pev(ent,pev_solid,SOLID_NOT)
    
//Don't draw that present anymore (thanks connor)
    
set_pev(ent,pev_effects,EF_NODRAW)
    
//Set respawn time
    
set_pev(ent,pev_nextthink,get_gametime() + get_pcvar_float(pcvar_respawn_time))
    
    
//Emit pick sound
    
engfunc(EngFunc_EmitSound,ent,CHAN_ITEM,sound_pick[random_num(0sizeof sound_pick 1)],1.0,ATTN_NORM,0,PITCH_NORM)
    
    
//Randomize player reward
    
switch(random_num(0,2))
    {
        
//Give him primary weapon
        
case 
        {
            
client_cmd(id,"slot1;drop")
            
remove_task(id TASK_PRIMARY)
            
set_task(0.2,"task_primary",id TASK_PRIMARY)
        }
        
//Give him secondary weapon
        
case :
        {
            
client_cmd(id,"slot2;drop")
            
remove_task(id TASK_SECONDARY)
            
set_task(0.2,"task_secondary",id TASK_SECONDARY)
        }
        
//Give him cash
        
case :
        {
            
fm_set_user_money(id,fm_get_user_money(id) + get_pcvar_num(pcvar_money))
        }
        
    }
    
    return 
FMRES_IGNORED
}
public 
forward_think(ent)
{
    
//Create class variable
    
new class[20]
    
    
//Get entity class
    
pev(ent,pev_classname,class,sizeof class - 1)
    
    
//Check entity class
    
if(!equali(class,"present"))
        return 
FMRES_IGNORED
    
    
//If that present isn't drawed, time to respawn it
    
if(pev(ent,pev_effects) & EF_NODRAW)
    {
        
//Create origin variable
        
new Float:origin[3]
        
        
//Get origins
        
pev(ent,pev_origin,origin)
        
        
//Emit random respawn sound
        
engfunc(EngFunc_EmitSound,ent,CHAN_AUTO,sound_respawn[random_num(0sizeof sound_respawn 1)],1.0,ATTN_NORM,0,PITCH_NORM)
        
        
//Make nice blast (from frostnades by Avalanche)
        
func_make_blast(origin)
        
        
//Make present solid
        
set_pev(ent,pev_solid,SOLID_BBOX)
        
        
//Draw present
        
set_pev(ent,pev_effectspev(ent,pev_effects)  & ~EF_NODRAW)
    }
    
    return 
FMRES_IGNORED
}
/*================================================================================
 [Stocks]
=================================================================================*/
//Thanks Avalanche for this stock
stock fm_set_user_money(id,money,flash=1)
{
    
set_pdata_int(id,OFFSET_CSMONEY,money,OFFSET_LINUX)

    
message_begin(MSG_ONE,g_money,{0,0,0},id)
    
write_long(money)
    
write_byte(flash)
    
message_end()
}
//Thanks Avalanche for this stock
stock fm_get_user_money(id)
{
    return 
get_pdata_int(id,OFFSET_CSMONEY,OFFSET_LINUX)
}
//From Zombie Plague by Mercyllez
stock fm_set_user_bpammo(idweaponamount)
{
    static 
offset
    
    
switch(weapon)
    {
        case 
CSW_AWPoffset OFFSET_AWM_AMMO
        
case CSW_SCOUT,CSW_AK47,CSW_G3SG1offset OFFSET_SCOUT_AMMO
        
case CSW_M249offset OFFSET_PARA_AMMO
        
case CSW_M4A1,CSW_FAMAS,CSW_AUG,CSW_SG550,CSW_GALI,CSW_SG552offset OFFSET_FAMAS_AMMO
        
case CSW_M3,CSW_XM1014offset OFFSET_M3_AMMO
        
case CSW_USP,CSW_UMP45,CSW_MAC10offset OFFSET_USP_AMMO
        
case CSW_FIVESEVEN,CSW_P90offset OFFSET_FIVESEVEN_AMMO
        
case CSW_DEAGLEoffset OFFSET_DEAGLE_AMMO
        
case CSW_P228offset OFFSET_P228_AMMO
        
case CSW_GLOCK18,CSW_MP5NAVY,CSW_TMP,CSW_ELITEoffset OFFSET_GLOCK_AMMO
        
case CSW_FLASHBANGoffset OFFSET_FLASH_AMMO
        
case CSW_HEGRENADEoffset OFFSET_HE_AMMO
        
case CSW_SMOKEGRENADEoffset OFFSET_SMOKE_AMMO
        
default: return
    }
    
    
set_pdata_int(idoffsetamountOFFSET_LINUX)
}
//From Zombie Plague by Mercyllez
stock fm_get_user_bpammo(idweapon)
{
    static 
offset
    
    
switch(weapon)
    {
        case 
CSW_AWPoffset OFFSET_AWM_AMMO
        
case CSW_SCOUT,CSW_AK47,CSW_G3SG1offset OFFSET_SCOUT_AMMO
        
case CSW_M249offset OFFSET_PARA_AMMO
        
case CSW_M4A1,CSW_FAMAS,CSW_AUG,CSW_SG550,CSW_GALI,CSW_SG552offset OFFSET_FAMAS_AMMO
        
case CSW_M3,CSW_XM1014offset OFFSET_M3_AMMO
        
case CSW_USP,CSW_UMP45,CSW_MAC10offset OFFSET_USP_AMMO
        
case CSW_FIVESEVEN,CSW_P90offset OFFSET_FIVESEVEN_AMMO
        
case CSW_DEAGLEoffset OFFSET_DEAGLE_AMMO
        
case CSW_P228offset OFFSET_P228_AMMO
        
case CSW_GLOCK18,CSW_MP5NAVY,CSW_TMP,CSW_ELITEoffset OFFSET_GLOCK_AMMO
        
case CSW_FLASHBANGoffset OFFSET_FLASH_AMMO
        
case CSW_HEGRENADEoffset OFFSET_HE_AMMO
        
case CSW_SMOKEGRENADEoffset OFFSET_SMOKE_AMMO
        
default: return -1
    
}
    
    return 
get_pdata_int(idoffsetOFFSET_LINUX)

__________________
The Professional is offline
Artifact
Veteran Member
Join Date: Jul 2010
Old 02-23-2016 , 18:21   Re: [Help] Need edit
Reply With Quote #2

PHP Code:
public plugin_init()
            
register_logevent("round_start"2"1=Round_Start")  

public 
round_start()
            
set_task(0.1"func_spawn"
This is the easiest way
__________________
Artifact is offline
The Professional
Member
Join Date: Nov 2015
Location: İstanbul
Old 02-24-2016 , 07:53   Re: [Help] Need edit
Reply With Quote #3

Quote:
Originally Posted by Artifact View Post
PHP Code:
public plugin_init()
            
register_logevent("round_start"2"1=Round_Start")  

public 
round_start()
            
set_task(0.1"func_spawn"
This is the easiest way
I set up this way.. The second round of worked (Was Spawn all boxes), does not work in the next round

PHP Code:
register_event"HLTV""EventNewRound""a""1=0""2=0" 

PHP Code:
public EventNewRound(id)
{
    
set_task(0.1"func_spawn")
    
//Create some variables
    
static sConfigsDir[64], sFile[128]
    
    
//Get config folder directory
    
get_configsdir(sConfigsDirsizeof sConfigsDir 1)
    
    
//Get mapname
    
static sMapName[32]
    
get_mapname(sMapNamesizeof sMapName 1)
    
    
//Format .cfg file directory
    
formatex(sFilesizeof sFile 1"%s/presents/%s_presents_origins.cfg"sConfigsDirsMapName)
    
    
//If file doesn't exist return
    
if(!file_exists(sFile))
        return
    
    
//Read file
    
while(read_file(sFileiLine++, sBuffersizeof sBuffer 1iLength))
    {
        if((
sBuffer[0]==';') || !iLength)
            continue
        
        
strtok(sBuffersTemp1sizeof sTemp1 1sTemp2sizeof sTemp2 1'|'0)
        
        
parse(sTemp1sFileOrigin[0], sizeof sFileOrigin[] - 1sFileOrigin[1], sizeof sFileOrigin[] - 1sFileOrigin[2], sizeof sFileOrigin[] - 1)
        
        
fOrigin[0] = str_to_float(sFileOrigin[0])
        
fOrigin[1] = str_to_float(sFileOrigin[1])
        
fOrigin[2] = str_to_float(sFileOrigin[2])
        
        
parse(sTemp2sFileAngles[0], sizeof sFileAngles[] - 1sFileAngles[1], sizeof sFileAngles[] - 1sFileAngles[2], sizeof sFileAngles[] - 1)
        
        
fAngles[0] = str_to_float(sFileAngles[0])
        
fAngles[1] = str_to_float(sFileAngles[1])
        
fAngles[2] = str_to_float(sFileAngles[2])
        
        
//Spawn presents on origins saved in .cfg file
        
func_spawn(fOrigin)
    }

__________________
The Professional is offline
Artifact
Veteran Member
Join Date: Jul 2010
Old 02-24-2016 , 17:17   Re: [Help] Need edit
Reply With Quote #4

I don't know what you want to do? To define your origin?

And yes, better to use
PHP Code:
    //Create some variables 
    
static sFile[128
    
    
//Get mapname 
    
static sMapName[32
    
get_mapname(sMapNamesizeof sMapName 1
    
    
get_configsdir(sFilecharsmax(sFile))
    
add(sFilecharsmax(sFile), "/presents/%s_presents_origins.cfg"sMapName
that's easy way
__________________

Last edited by Artifact; 02-24-2016 at 19:54.
Artifact is offline
The Professional
Member
Join Date: Nov 2015
Location: İstanbul
Old 02-24-2016 , 18:50   Re: [Help] Need edit
Reply With Quote #5

Quote:
Originally Posted by Artifact View Post
In this plugin you already defined origins
PHP Code:
public func_spawn(Float:origin[3]) 
I don't know what you want to do? To define your origin?

And yes, better to use
PHP Code:
    //Create some variables 
    
static sFile[128
    
    
//Get mapname 
    
static sMapName[32
    
get_mapname(sMapNamesizeof sMapName 1
    
    
get_configsdir(sFilecharsmax(sFile))
    
add(sFilecharsmax(sFile), "/presents/%s_presents_origins.cfg"sMapName
that's easy way
Please compile sma and give me. I 'm very inexperienced
I just want to get to spawn boxes each round start (Sorry my bad english)
__________________

Last edited by The Professional; 02-24-2016 at 18:54.
The Professional is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 02-24-2016 , 21:20   Re: [Help] Need edit
Reply With Quote #6

use round start logevent instead, not hltv.
siriusmd99 is offline
Reply



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 23:52.


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