[原創教學] 教你如何設定機率

Home Home
<< 1 2 3 >>
跳頁: (共 3 頁)
引用 | 編輯 tony987852
2010-01-20 22:19
樓主
推文 x9
今天就教你如何設定機率(新手寫法...)。
前提你要對sma有少少基礎...不然你看了=沒看,只是在浪費你寶貴的時間..

//首先,我們需要
#include <amxmodx>
#include <cstrike>
#include <fun>

#define PLUGIN "插件的大名"
#define VERSION "版本"
#define AUTHOR "作者名"

//再註冊插件...
public plugin_init()
{
     register_plugin( PLUGIN, VERSION, AUTHOR ) //註冊..不用多說...
     register_clcmd("say /demo","demo") // 這個是抽的命令,到遊戲按y輸入/demo就能開了
}

//開始囉
public demo(id)
{
     new random = random_num(0,9) //這個代表有多少個機會(從0至9抽一個數字) 這個代表有10次機會
     if(!is_user_alive(id))     return PLUGIN_HANDLED // 當他不是在生存時, 不讓他抽
     switch (random)
     {
           case 0: // 如果抽中的數字為0
           {
                 cs_set_user_money(id,16000) // 玩家金錢變16000美元
                 client_print(id,print_chat,"你獲得了16000美元。")
           }
           case 1: // 如果抽中的數字為1
           {
                 set_user_health(id,30000) // 玩家的血變成30000
                 client_print(id,print_chat,"你變成了血牛...")
           }
           default: //沒有抽中
           {
                 client_print(id,print_chat,"下次再抽吧...")
           }
     }
     return PLUGIN_HANDLED
}

大至上完成了...只要說/demo就行了...
可別忘記儲存成UTF-8 不含BOM喔~

獻花 x4
引用 | 編輯 waihong1994
2010-01-20 22:20
1樓
  
wow!教學bu...原創bu...

獻花 x0
引用 | 編輯 chapecs
2010-01-21 06:41
2樓
  
不知道有沒有BUG呢?

幫你推推囉 表情

獻花 x0
引用 | 編輯 HsK
2010-01-21 07:36
3樓
  
呵呵   先按按推薦^^

獻花 x0
引用 | 編輯 BONE32121
2010-01-21 07:48
4樓
  
雖然我不怎麼懂插件

不過還是幫你推一推 表情

獻花 x0
引用 | 編輯 tony987852
2010-01-21 16:07
5樓
  
下面是引用 chapecs 於 2010-01-21 06:41 發表的 : 到引言文
不知道有沒有BUG呢?

 

應該是沒bug的...本人測試過...
就是不懂寫那個更高級的機率...

獻花 x0
引用 | 編輯 apple20612
2010-01-21 16:55
6樓
  
不錯哦 雖然我沒寫過

不過我都看的懂! 改天來試試看寫插件吧

獻花 x0
引用 | 編輯 我係光
2010-01-21 16:58
7樓
  
推推喔~
有天我一定看你的教學

獻花 x0
引用 | 編輯 HsK
2010-01-21 19:07
8樓
  
return PLUGIN_HANDLED 這應要的

否則死後也可抽了 表情

獻花 x0
引用 | 編輯 a7811311622
2010-01-22 00:41
9樓
  
因為你上面有一行用了"return PLUGIN_HANDLED",所以最後一定要加"return PLUGIN_HANDLED",
不然轉檔一定會出錯~ 表情

獻花 x0
引用 | 編輯 a9872310
2010-01-22 11:47
10樓
  
那請問如果要寫成喪屍模式
用子彈包購買的話
該怎麼寫...

獻花 x0
引用 | 編輯 wong19960928
2010-01-22 11:49
11樓
  
这个是什么啊

獻花 x0
引用 | 編輯 tony987852
2010-01-22 16:55
12樓
  
下面是引用 a7811311622 於 2010-01-22 00:41 發表的 : 到引言文
因為你上面有一行用了"return PLUGIN_HANDLED",所以最後一定要加"return PLUGIN_HANDLED",
不然轉檔一定會出錯~ 表情  

不會出錯...只是會有warning...

下面是引用 a9872310 於 2010-01-22 11:47 發表的 : 到引言文
那請問如果要寫成喪屍模式
用子彈包購買的話
該怎麼寫...

不懂zp...我想應該是

//首先,我們需要
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <zombieplague>

#define PLUGIN "插件的大名"
#define VERSION "版本"
#define AUTHOR "作者名"

new const g_item_name[] = { "他的名字" }
const g_item_cost = 20 // 多少子彈包

//再註冊插件...
public plugin_init()
{
    register_plugin( PLUGIN, VERSION, AUTHOR )
    zp_register_extra_item(g_item_name, g_item_cost, ZP_TEAM_HUMAN)
}

//開始囉
public demo(id)
{
    new random = random_num(0,9) //這個代表有多少個機會(從0至9抽一個數字) 這個代表有10次機會
    if(!is_user_alive(id))     return PLUGIN_HANDLED // 當他不是在生存時, 不讓他抽
    switch (random)
    {
        case 0: // 如果抽中的數字為0
        {
            cs_set_user_money(id,16000) // 玩家金錢變16000美元
            client_print(id,print_chat,"你獲得了16000美元。")
        }
        case 1: // 如果抽中的數字為1
        {
            set_user_health(id,30000) // 玩家的血變成30000
            client_print(id,print_chat,"你變成了血牛...")
        }
        default: //沒有抽中
        {
            client_print(id,print_chat,"下次再抽吧...")
        }
    }
    return PLUGIN_HANDLED
}

我是新手...別難為我表情

下面是引用 wong19960928 於 2010-01-22 11:49 發表的 : 到引言文
这个是什么啊

已經說了   前提你要對sma有少少基礎...不然你看了=沒看,只是在浪費你寶貴的時間..

獻花 x0
引用 | 編輯 a9872310
2010-01-22 19:07
13樓
  
下面是引用 tony987852 於 2010-01-22 16:55 發表的 : 到引言文

不會出錯...只是會有warning...

不懂zp...我想應該是
//首先,我們需要
.......

謝謝你阿
大大
這樣我又更了解插件了
比對之後
大概都看的懂了
感謝你>  <

獻花 x0
引用 | 編輯 a9872310
2010-01-22 19:33
14樓
  
大大 我還想請問一下
如果要修改成給武器

case 0: // 如果抽中的數字為0
    {
        cs_set_user_money(id,16000) // 玩家金錢變16000美元
        client_print(id,print_chat,"你獲得了16000美元。")
    }
..................
這部份的給武器指令
是什麼呢?

獻花 x0
引用 | 編輯 a9872310
2010-01-22 19:44
15樓
  
還有像是增強跳躍
之類的...
指令部分實在是不懂...

獻花 x0
引用 | 編輯 冷場館女僕長
2010-01-22 20:15
16樓
  
不錯不錯!!!! 表情
現在教編寫AMXX實在太少了!!!!! 表情
希望你繼續努力!!!! 表情

獻花 x0
引用 | 編輯 HsK
2010-01-22 20:17
17樓
  
下面是引用 a9872310 於 2010-01-22 19:33 發表的 : 到引言文
大大 我還想請問一下
如果要修改成給武器

case 0: // 如果抽中的數字為0
    {
        cs_set_user_money(id,16000) // 玩家金錢變16000美元
        client_print(id,print_chat,"你獲得了16000美元。")
    }
..................
這部份的給武器指令
是什麼呢?


case 0: // 如果抽中的數字為0
    {
         fm_give_item(id, "weapon_ak47")
        client_print(id,print_chat,"你獲得了AK47。")
    }

獻花 x0
引用 | 編輯 HsK
2010-01-22 20:18
18樓
  
下面是引用 a9872310 於 2010-01-22 19:44 發表的 : 到引言文
還有像是增強跳躍
之類的...
指令部分實在是不懂...


  fm_set_user_gravity(id, 0.75)  //重力變為 0.75
  fm_set_user_maxspeed(id, 200.0)  //移動速度變為 200.0

獻花 x0
引用 | 編輯 a9872310
2010-01-22 20:21
19樓
  
我剛剛用過
fm_give_item(id, "武器")
這個了
不行...
直接用give_item才可以
怪怪的= =

獻花 x0
引用 | 編輯 a9872310
2010-01-22 20:41
20樓
  
public plugin_init()
{
  register_plugin( PLUGIN, VERSION, AUTHOR )
  zp_register_extra_item(g_item_name, g_item_cost, ZP_TEAM_HUMAN)
}
這部份好像有問題
買了沒反應...

獻花 x0
引用 | 編輯 tony987852
2010-01-22 21:07
21樓
  
下面是引用 sk@.@ 於 2010-01-22 20:17 發表的 : 到引言文


case 0: // 如果抽中的數字為0 
    { 
         fm_give_item(id, "weapon_ak47")
        client_print(id,print_chat,"你獲得了AK47。") 
    }
其實直接用 give_item(id, "weapon_ak47") 就好了...

下面是引用 sk@.@ 於 2010-01-22 20:18 發表的 : 到引言文


  fm_set_user_gravity(id, 0.75)  //重力變為 0.75
  fm_set_user_maxspeed(id, 200.0)  //移動速度變為 200.0
其實不用fm就可以了- -
set_user_gravity(id, x.x)  // 這個就是重力是800x多少,例如你想要重力400的,就把x.x變成0.5 ,因為800x0.5=400
set_user_maxspeed(id, 200) // 正常人的速度是250
下面是引用 a9872310 於 2010-01-22 20:21 發表的 : 到引言文
我剛剛用過
fm_give_item(id, "武器")
這個了
不行...
直接用give_item才可以
怪怪的= =
如果用fm_..........的東西,要在上面加上  #include <fakemeta>
下面是引用 a9872310 於 2010-01-22 20:41 發表的 : 到引言文
public plugin_init()
{
  register_plugin( PLUGIN, VERSION, AUTHOR )
  zp_register_extra_item(g_item_name, g_item_cost, ZP_TEAM_HUMAN)
}
這部份好像有問題
買了沒反應...
這個...我在研究...因為沒碰過zm的東西...
應該是這樣...
//首先,我們需要
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <zombieplague>

#define PLUGIN "插件的大名"
#define VERSION "版本"
#define AUTHOR "作者名"

new const g_item_name[] = { "他的名字" }
const g_item_cost = 20 // 多少子彈包

new item

//再註冊插件...
public plugin_init()
{
  register_plugin( PLUGIN, VERSION, AUTHOR )
  item = zp_register_extra_item(g_item_name, g_item_cost, ZP_TEAM_HUMAN)
}

public zp_extra_item_selected(id, itemid)
{
  if (itemid == item)
  {
      demo(id)
  }
}

//開始囉
public demo(id)
{
  new random = random_num(0,9) //這個代表有多少個機會(從0至9抽一個數字) 這個代表有10次機會
  if(!is_user_alive(id))     return PLUGIN_HANDLED // 當他不是在生存時, 不讓他抽
  switch (random)
  {
      case 0: // 如果抽中的數字為0
      {
        cs_set_user_money(id,16000) // 玩家金錢變16000美元
        client_print(id,print_chat,"你獲得了16000美元。")
      }
      case 1: // 如果抽中的數字為1
      {
        set_user_health(id,30000) // 玩家的血變成30000
        client_print(id,print_chat,"你變成了血牛...")
      }
      default: //沒有抽中
      {
        client_print(id,print_chat,"下次再抽吧...")
      }
  }
  return PLUGIN_HANDLED
}

哪位大大能幫我看哪裡有錯..

獻花 x0
引用 | 編輯 HsK
2010-01-22 21:18
22樓
  
下面是引用 tony987852 於 2010-01-22 21:07 發表的 : 到引言文

其實直接用 give_item(id, "weapon_ak47") 就好了...

其實不用fm就可以了- -
set_user_gravity(id, x.x)  // 這個就是重力是800x多少,例如你想要重力400的,就把x.x變成0.5 ,因為800x0.5=400
.......



#include <amxmodx>
#include <cstrike>
#include <fun>
#include <zombieplague>

#define PLUGIN "插件的大名"
#define VERSION "版本"
#define AUTHOR "作者名"

new const g_item_name[] = { "他的名字" }
const g_item_cost = 20 // 多少子彈包

new g_item
new item[33]

public plugin_init()
{
register_plugin( PLUGIN, VERSION, AUTHOR )
item = zp_register_extra_item(g_item_name, g_item_cost, ZP_TEAM_HUMAN)

register_forward(FM_PlayerPreThink, "fwd_PlayerPreThink")

register_event("DeathMsg", "event_Death", "a")
register_event("HLTV", "event_RoundStart", "a", "1=0", "2=0") 
}

public zp_extra_item_selected(id, itemid)
{
if (itemid == g_item)
{
item[id] = true
}
}


public  fwd_PlayerPreThink(id)
{
if(item[id])
{
new random = random_num(0,9) //這個代表有多少個機會(從0至9抽一個數字) 這個代表有10次機會
if(!is_user_alive(id)) return PLUGIN_HANDLED // 當他不是在生存時, 不讓他抽
switch (random)
{
case 0: // 如果抽中的數字為0
{
cs_set_user_money(id,16000) // 玩家金錢變16000美元
client_print(id,print_chat,"你獲得了16000美元。")
}
case 1: // 如果抽中的數字為1
{
set_user_health(id,30000) // 玩家的血變成30000
client_print(id,print_chat,"你變成了血牛...")
}
default: //沒有抽中
{
client_print(id,print_chat,"下次再抽吧...")
}
}
}
return PLUGIN_HANDLED
}

public zp_user_infected_post(id, infector)
{
 item[id] = false
}

public zp_user_humanized_post(id)
{
item[id] = false
}

public client_connect(id)
{
 item[id] = false
}

public client_disconnect(id)
{
item[id] = false
}

public event_Death()
{
 new id = read_data(2)
 if (!(1 <= id <= 32))
  return;
  
item[id] = false
}

public event_RoundStart(id)
{
 for (new id = 1; id <= 32; id++)
 {
 item[id] = false
 }
}

獻花 x0
引用 | 編輯 HsK
2010-01-22 21:20
23樓
  
應該可以   我也不明行不行 表情

獻花 x0
引用 | 編輯 tony987852
2010-01-22 21:44
24樓
  
原來做一個zm插件要那麼東西...改天要好好研究一下..

獻花 x0
引用 | 編輯 a7811311622
2010-01-22 23:49
25樓
  
下面是引用 tony987852 於 2010-01-22 16:55 發表的 : 到引言文
不會出錯...只是會有warning...

它表面上說是警告,實際上和錯誤沒兩樣吧…
如果沒回傳一個值回去,那前面的return PLUGIN_HANDLED就沒意義了…
下面是引用 tony987852 於 2010-01-22 21:07 發表的 : 到引言文
set_user_gravity(id, x.x)  // 這個就是重力是800x多少,例如你想要重力400的,就把x.x變成0.5 ,因為800x0.5=400

後面的數值不是比例…後面打800就是800,重力本身就是一個數值,你打1.0或0.5根本是無重力狀態…

獻花 x0
引用 | 編輯 tony987852
2010-01-23 07:54
26樓
  
下面是引用 a7811311622 於 2010-01-22 23:49 發表的 : 到引言文

後面的數值不是比例…後面打800就是800,重力本身就是一個數值,你打1.0或0.5根本是無重力狀態…


為什麼我用 set_user_gravity(id,0.5) ,發現我的重力是400 ...... 沒什麼感覺是無重...
1.0是正常...(800)
0.5是一半..(400)
800.0是......(800x800)

獻花 x0
引用 | 編輯 waihong1994
2010-01-23 09:59
27樓
  
可唔可以話我地知多D指令?例如檢查玩家血量之類? - -"

獻花 x0
引用 | 編輯 a7811311622
2010-01-23 10:35
29樓
  
下面是引用 tony987852 於 2010-01-23 07:54 發表的 : 到引言文



為什麼我用 set_user_gravity(id,0.5) ,發現我的重力是400 ...... 沒什麼感覺是無重...
1.0是正常...(800)
0.5是一半..(400)
800.0是......(800x800)


抱歉…後來看了<fun>的內容後才發現set_user_gravity後面的確是用比例…
(AMXX重力的設定方式居然和sv_gravity的設定方式不一樣…表情 )

獻花 x0
<< 1 2 3 >>
跳頁: (共 3 頁)