清除地上武器写法?

Home Home
引用 | 编辑 n5427114
2014-07-26 22:39
楼主
推文 x0
请问清除地上武器写法怎么写?

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <xs>
#include <fakemeta>


new cvar_removedropped


public plugin_init()
{
    register_plugin("remove_dropper","1.0beta","Anniversary04")
  register_forward(FM_SetModel, "fw_SetModel"
   cvar_removedropped = register_cvar("remove_dropped", "15.0")
}


public fw_SetModel(entity, const model[])
{
  if (strlen(model) < 8)
    return;
 
  if (get_pcvar_float(cvar_removedropped) > 0.0)
  {    
    static classname[10]
    pev(entity, pev_classname, classname, charsmax(classname))
   
    if (equal(classname, "weaponbox"))
    set_pev(entity, pev_nextthink, get_gametime() + get_pcvar_float(cvar_removedropped))
  }
}

冒似写会无法反编, 而且地上C4好像会被清到..

有办法分主武一个时间,小枪一个时间清除吗?

献花 x0
引用 | 编辑 op47
2014-07-27 16:21
1楼
  
下面是引用 n5427114 于 2014-07-26 22:39 发表的 清除地上武器写法?: 到引言文
请问清除地上武器写法怎么写?
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <xs>
.......



FM_SetModel 有带 const model[] 的变量, 自己用模组名判断就行

献花 x0
引用 | 编辑 n5427114
2014-07-27 22:03
2楼
  
上面这段没有办法正编...

献花 x0
引用 | 编辑 op47
2014-07-27 22:55
3楼
  
register_forward(FM_SetModel, "fw_SetModel"
register_forward(FM_SetModel, "fw_SetModel")

献花 x0
引用 | 编辑 n5427114
2014-07-28 13:21
4楼
  
 不是这个问题。

献花 x0
引用 | 编辑 op47
2014-07-28 13:50
5楼
  
下面是引用 n5427114 于 2014-07-28 13:21 发表的 : 到引言文
 不是这个问题。

是你sma格式的问题(SMA 换行问题) , 也许你是C&P, 不过我想你也最好参考这个段落:
Indentation, Tabbing and Spacing

Tabbing should always be done whenever you open a code block (which will be discussed more in detail later). A standard tab is either done using the "Tab" key or using 4 spaces. Less commonly, people use 1, 3 or 8 spaces for their tabs, but this is very rare and generally frowned upon. Almost everyone uses the "Tab" key because then other people can set their tab-size higher or lower in their text editors.

There are also many styles of spacing, but I believe the best (despite my not using it personally) is to add a space whenever you put a parameter in brackets, after a comma, immediately after a condition/loop keyword and before/after any operators which take two parameters on the left and right. For example:



if ( !cmd_accessidlevelcid ) )  
... or...


for ( new i10i++ )  
This allows you to easily distinguish functions from conditions/loops and also allows you to easily pick out parameters, operators, etc.

This is by no means standard and is highly up for debate, but to me this makes the most logical sense and is what I would use if I had the option of immediately wiping my habits and picking a new set of them. I would, however, advise you to always add spaces between operators with two parameters and after commas.

You may also consider adding two carriage returns as opposed to one between functions as it may make them easier to read. This is by no means a convention but I recommend it personally.


ACC. TO: https://forums.alliedmods.net/showthread.php?t=85274

献花 x0
引用 | 编辑 岳岳
2014-07-28 13:50
6楼
  
下面是引用 n5427114 于 2014-07-28 13:21 发表的 : 到引言文
 不是这个问题。



少个夸号就会不能编译了.....少一个差很多


可以的话最好也把编译错误的讯息贴上来

献花 x0
引用 | 编辑 n5427114
2014-07-28 19:39
7楼
  
error 029 invalid expression assumed zero

那个刮号只是没复制上去,插件内没有这个问题

献花 x0
引用 | 编辑 n5427114
2014-07-28 19:45
8楼
  
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <xs>
#include <fakemeta>
#include <fun>
#include <engine>
#include <hamsandwich>

const HideWeapon_Flags = 1
new cvar_removedropped
new g_time[33]

public plugin_init()
{
       register_plugin("amx_respawn","2.0beta","Tonyyoung")
    register_forward(FM_SetModel, "fw_SetModel")
    RegisterHam(Ham_Spawn, "player", "fw_Spawn_Post", 1)
       cvar_removedropped = register_cvar("remove_dropped", "15.0")
}

public fw_Spawn_Post(id)
{
    if (is_user_alive(id) && is_user_connected(id))
    {
        cs_set_user_money(id, cs_get_user_money(id) + 500)
    }
}

public fw_SetModel(entity, const model[])
{
    if (!pev_valid(entity)) return FMRES_IGNORED
    
    if (strlen(model) < 8) return FMRES_IGNORED;
    
    new ent_classname[32]
    pev(entity, pev_classname, ent_classname, charsmax(ent_classname))
    if (equal(ent_classname, "weaponbox"))
    {
        set_pev(entity, pev_nextthink, get_gametime() + g_weapons_stay)
        return FMRES_IGNORED
    }
    return FMRES_IGNORED
}

sma 在下面

献花 x0
引用 | 编辑 n5427114
2014-07-28 19:47
9楼
  
源码在这供各位参考

本帖包含附件
档名: zip respawn_money.rar   (2022-06-09 14:21 / 1 KB)   下载次数:5


献花 x0
引用 | 编辑 op47
2014-07-29 00:09
10楼
  
下面是引用 n5427114 于 2014-07-28 19:47 发表的 : 到引言文
源码在这供各位参考



跟你说了是换行的问题, 也给了篇文章你看, 竟然也察觉不到问题所在? 即使察觉不到, 那你有没有把SMA尝试重新换行? 显然地没有.
我看到的是这样子:
复制程式
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <xs>
#include <fakemeta>
#include <fun>
#include <engine>
#include <hamsandwich>


const HideWeapon_Flags = 1
new cvar_removedropped
new g_time[33]


public plugin_init() 
{ 
    register_plugin("amx_respawn","2.0beta","Tonyyoung") 
�@�@�@�@register_forward(FM_SetModel, "fw_SetModel")
 RegisterHam(Ham_Spawn, "player", "fw_Spawn_Post", 1)
  �@    cvar_removedropped = register_cvar("remove_dropped", "15.0") 
}


public fw_Spawn_Post(id)
{
 if (is_user_alive(id) && is_user_connected(id))
 {
 cs_set_user_money(id, cs_get_user_money(id) + 500)
 }
}


public fw_SetModel(entity, const model[])
{
 if (!pev_valid(entity)) return FMRES_IGNORED
 
 if (strlen(model) < 8) return FMRES_IGNORED;
 
 new ent_classname[32]
 pev(entity, pev_classname, ent_classname, charsmax(ent_classname))
 if (equal(ent_classname, "weaponbox"))
 {
 set_pev(entity, pev_nextthink, get_gametime() + g_weapons_stay)
 return FMRES_IGNORED
 }
 return FMRES_IGNORED
}


献花 x0
引用 | 编辑 n5427114
2014-07-29 10:53
11楼
  
下面是引用 op47 于 2014-07-29 00:09 发表的 : 到引言文

跟你说了是换行的问题, 也给了篇文章你看, 竟然也察觉不到问题所在? 即使察觉不到, 那你有没有把SMA尝试重新换行? 显然地没有.
我看到的是这样子:
[code]#include <amxmodx>
.......

那篇文章我有看,SMA也换行好了,只是那个时候还是无法正编,所以就上传修改前的SMA了。

献花 x0
引用 | 编辑 n5427114
2014-07-29 11:38
12楼
  
清除模组的部分判断是要用 CSW_GLOCK18 还是 weapon_glock18 ?

献花 x0
引用 | 编辑 op47
2014-07-29 13:21
13楼
  
下面是引用 n5427114 于 2014-07-29 11:38 发表的 : 到引言文
清除模组的部分判断是要用 CSW_GLOCK18 还是 weapon_glock18 ?

是w_glock18.mdl


if (equal(model[7], "w_glock18.mdl)) ....

献花 x0
引用 | 编辑 n5427114
2014-07-29 20:20
14楼
  
下面是引用 op47 于 2014-07-29 13:21 发表的 : 到引言文


是w_glock18.mdl


if (equal(model[7], "w_glock18.mdl)) ....

如果数个模型的话呢?

献花 x0