Quote:
Originally Posted by Hunter-Digital
I don't know another way than to make a huge array and store last touch gametime and then check if it's touched at least 0.1 seconds ago or something....
Why exacly do you need this ? maybe you can do it in a better way.
|
Here's a short description of a plugin that I want to make

Player can press +use and if he's at enemy spawn ( info_player_start and info_player_deathmatch), he can plant flag and get 3 frags
EDIT: I tryed this, but it isn't working
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <cstrike>
new g_planted, p_map, p_reward
new g_model[] = "models/flag/srb.mdl"
new lasttouch[33]
public plugin_init()
{
register_plugin("Flag Remaked","1.0","Sp@jk")
register_event("HLTV","newRound","a","1=0","2=0")
register_forward(FM_EmitSound, "Sound")
register_forward(FM_Touch,"Touch")
p_map=register_cvar("amx_flag","0")
p_reward=register_cvar("amx_flag_reward","3")
}
public plugin_precache()
precache_model(g_model)
public plugin_cfg()
{
new map[32],file[64],cfgdir[128]
get_mapname(map,31)
get_configsdir(cfgdir,127)
formatex(file,63,"%s/flag/%s.cfg",cfgdir,map)
if(file_exists(file))
{
server_cmd("exec %s",file)
}
if(get_pcvar_num(p_map)==0)
set_fail_state("Flag not allowed on map!")
}
public newRound()
{
g_planted=0
new iEnt = engfunc(EngFunc_FindEntityByString,-1, "classname","flag")
while(iEnt > 0)
{
engfunc(EngFunc_RemoveEntity, iEnt)
iEnt = engfunc(EngFunc_FindEntityByString,iEnt, "classname","flag")
}
}
public Sound(id, iChannel, szSound[], Float:fVol, Float:fAttn, iFlags, iPitch )
{
if(equal(szSound, "common/wpn_denyselect.wav"))
{
if(lasttouch[id] >= (get_gametime() - 0.1) && get_user_weapon(id)==CSW_KNIFE && g_planted==0)
{
new Origin[3]
get_user_origin(id,Origin)
new flag = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
set_pev(flag, pev_classname, "flag")
engfunc(EngFunc_SetModel, flag, g_model)
set_pev(flag,pev_origin,Origin)
new Float:frags
pev(id, pev_frags, frags)
set_pev(id, pev_frags,frags+float(get_pcvar_num(p_reward)))
g_planted=1
}
return FMRES_SUPERCEDE;
}
return FMRES_IGNORED;
}
public Touch(ptr,ptd)
{
if(pev_valid(ptr))
{
static classname[32]
pev(ptr, pev_classname, classname, 31)
if(equal(classname,"player"))
{
static classname2[32]
pev(ptd, pev_classname, classname2, 31)
if((get_user_team(ptr)==1&&equal(classname2,"info_player_start"))||(get_user_team(ptr)==2&&equal(classname2,"info_player_deathmatch")))
lasttouch[ptr]==get_gametime()
}
}
}