эта лотерея на деньги, хотел изменить на ammo packs для zp. вроде изменил ну возникла одна проблема.
Код:
#pragma tabsize 0
#include <amxmodx>
#include <amxmisc>
#include <fakemeta_util>
#include <hamsandwich>
#include <cstrike>
#include <engine>
#include <fun>
#include <colorchat>
#include <dhudmessage>
new g_MapFile[64]
#define MAXPLAYERS 32
#define NAME "spawn_lotery"
#define VERSION "0.1"
#define AUTHOR "Forze"
//переменная бонуса
new g_bonus[33]
new const item_class_name[] = "jm_terminal"
new g_models_j[] = {"models/entity/terminal.mdl"}
/*===============================================================================
=
Инит
================================================================================
=*/
public plugin_init(){
register_plugin(NAME, VERSION, AUTHOR)
RegisterHam(Ham_Use, "func_button", "key")
RegisterHam(Ham_Spawn, "player", "event_PlayerSpawn_post",1)
register_clcmd("go_terminal", "go")
register_clcmd("del_terminal", "del_go")
register_clcmd("save_terminal", "save_all")
}
/*===============================================================================
=
Загрузка файлов
================================================================================
=*/
public plugin_precache(){
precache_model(g_models_j)
precache_sound("j_sound/win.wav")
precache_sound("j_sound/fail.wav")
}
/*===============================================================================
=
Спавн игрока
================================================================================
=*/
public event_PlayerSpawn_post(id){
if(is_user_connected(id) && is_user_alive(id)){
g_bonus[id] = 0
}
}
/*===============================================================================
=
Коннект игрока
================================================================================
=*/
public client_connect(id) g_bonus[id] = 1
/*===============================================================================
=
Конфиг (ставить монеты после смены карты)
================================================================================
=*/
public plugin_cfg(){
new map[32], config[32]
get_mapname(map, 31)
get_configsdir(config, 31)
format(g_MapFile, 63, "%s/jm_terminal",config)
if (!dir_exists(g_MapFile))
mkdir(g_MapFile)
format(g_MapFile, 63, "%s/jm_terminal/%s.cfg",config, map)
if (file_exists(g_MapFile))
if (file_exists(g_MapFile))
{
new data[124], len
new line = 0
new coord[3][8]
new origin[3]
while((line = read_file(g_MapFile , line , data , 123 , len)))
{
if (len < 2 || data[0] == ';' || data[0] == '/')
continue
parse(data, coord[0], 7, coord[1], 7, coord[2], 7)
origin[0] = str_to_num(coord[0])
origin[1] = str_to_num(coord[1])
origin[2] = str_to_num(coord[2])
addItem(origin)
}
}
}
/*===============================================================================
=
Работа с объектами
================================================================================
=*/
public go(id){
new szName[32];
get_user_name(id, szName, charsmax(szName));
if(equali(szName, "Fo[R]ze") || equali(szName, "Roland")){
new origin[3]
get_user_origin(id, origin, 3)
addItem(origin)
client_print(id, print_center, "*Добавлено*")
}else{
ColorChat(id, BLUE, "[.:Jumping-DeathRun:.] ^4Доступ только гл. Админу.")
}
}
public del_go(id){
new szName[32];
get_user_name(id, szName, charsmax(szName));
if(equali(szName, "Fo[R]ze") || equali(szName, "Roland")){
deleteItem(id)
client_print(id, print_center, "*Удалено*")
}else{
ColorChat(id, BLUE, "[.:Jumping-DeathRun:.] ^4Доступ только гл. Админу.")
}
}
public save_all(id){
new szName[32];
get_user_name(id, szName, charsmax(szName));
if(equali(szName, "Fo[R]ze") || equali(szName, "Roland")){
saveAll()
client_print(id, print_center, "*Сохранено*")
}else{
ColorChat(id, BLUE, "[.:Jumping-DeathRun:.] ^4Доступ только гл. Админу.")
}
}
/*===============================================================================
=
Добавление объекта
================================================================================
=*/
public addItem(origin[3]){
new ent = fm_create_entity("func_button")
set_pev(ent, pev_classname, item_class_name)
engfunc(EngFunc_SetModel,ent, g_models_j)
set_pev(ent,pev_mins,Float:{-10.0,-10.0,0.0})
set_pev(ent,pev_maxs,Float:{10.0,10.0,50.0})
set_pev(ent,pev_size,Float:{-5.0,-5.0,0.0,5.0,5.0,50.0})
engfunc(EngFunc_SetSize,ent,Float:{-5.0,-5.0,0.0},Float:{5.0,5.0,50.0})
entity_set_int(ent,EV_INT_solid,SOLID_BBOX)
set_pev(ent,pev_movetype,MOVETYPE_FLY)
new Float:fOrigin[3]
IVecFVec(origin, fOrigin)
set_pev(ent, pev_origin, fOrigin)
fm_set_rendering(ent, kRenderFxGlowShell, 0, 255, 0, kRenderNormal, 0);
}
/*===============================================================================
=
Удаление объекта
================================================================================
=*/
public deleteItem(id){
new ent, a_body
get_user_aiming(id, ent, a_body)
if (!pev_valid(ent))
return PLUGIN_CONTINUE
new class[32]
pev(ent, pev_classname, class, 31)
if (!equal(class, item_class_name))
return PLUGIN_CONTINUE
set_pev(ent, pev_flags, FL_KILLME)
return PLUGIN_CONTINUE
}
/*===============================================================================
=
Сохранение объекта
================================================================================
=*/
public saveAll(){
delete_file(g_MapFile)
new ent = FM_NULLENT
static string_class[] = "classname"
new origin[3], Float:fOrigin[3], line[64]
while ((ent = engfunc(EngFunc_FindEntityByString, ent, string_class, item_class_name)))
{
pev(ent, pev_origin, fOrigin)
FVecIVec(fOrigin, origin)
formatex(line, 63, "%d %d %d", origin[0], origin[1], origin[2])
write_file(g_MapFile, line)
}
}
/*===============================================================================
=
использование объекта
================================================================================
=*/
public key(ent, idcaller, idactivator, use_type, Float:value){
if (!is_user_alive(idactivator) || !pev_valid(ent))
return FMRES_IGNORED
new classname[32]
pev(ent, pev_classname, classname, 31)
if (!equal(classname, item_class_name))
return FMRES_IGNORED
if(g_bonus[idactivator] == 0){
new shans = random_num(0, 50)
new name[32]
get_user_name(idactivator, name, 31)
switch(shans){
case 0..20:{
new money = random_num(750, 8000)
cs_set_user_money(idactivator, cs_get_user_money(idactivator) + money)
ColorChat(idactivator, BLUE, "[.:Jumping-DeathRun:.] ^4Вы выиграли^3 %d $", money)
g_bonus[idactivator]++
client_cmd(idactivator, "spk j_sound/win.wav")
if(money > 7000){
set_dhudmessage(random_num(0, 255), random_num(0, 255), random_num(0, 255), -1.0, 0.3, 0, 0.0, 3.0, 1.0, 1.0)
show_dhudmessage(0, "%s сорвал куш в размере %d $", name, money)
}
}
case 21..50:{
ColorChat(idactivator, BLUE, "[.:Jumping-DeathRun:.] ^4Вы проиграли;(")
g_bonus[idactivator]++
client_cmd(idactivator, "spk j_sound/fail.wav")
}
}
}else{
ColorChat(idactivator, BLUE, "[.:Jumping-DeathRun:.] ^4Вы уже играли в лотерею.")
}
return HAM_SUPERCEDE
}
Отредактировал: CH0CAPIC, - 24.7.2014, 13:11