If I want to change superspawns to your's "rog", what is need to be changed in my plugin's code? Can you change that? Thank you.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <csgo_skins>
#include <fakemeta>
#include <hamsandwich>
#include <engine>
#include <cellarray>
#include <xs>
#include <rog>
#define MAX_MODELS 5
#define MAX_CONTENTS 100
new const model_present[MAX_MODELS][128];
new pcvar_presents_on_map, cvar_min_players, cvar_glow, cvar_spin, cvar_glow_enabled, cvar_announce, models_count, cvar_spawn_after_time_min, cvar_spawn_after_time_max
new presentItems[MAX_CONTENTS][8], hasItem[MAX_CONTENTS][8], presentAmountsMinimum[MAX_CONTENTS][8], presentAmountsMaximum[MAX_CONTENTS][8], Float:presentChances[MAX_CONTENTS];
new contentsCount;
public plugin_init()
{
register_plugin("CSGO SKINS: Presents", "1.0", "InvIs")
check_extra_plugin();
register_event("HLTV", "spawn_gifts", "a", "1=0", "2=0")
register_forward(FM_Touch,"forward_touch")
pcvar_presents_on_map = register_cvar("csgo_presents_on_round", "15")
cvar_min_players = register_cvar("csgo_presents_min_players", "5");
cvar_glow = register_cvar("csgo_presents_glow", "255 0 0");
cvar_announce = register_cvar("csgo_presents_spawn_announce", "1");
cvar_spin = register_cvar("csgo_presents_glow_enabled", "1");
cvar_glow_enabled = register_cvar("csgo_presents_spin", "1");
cvar_spawn_after_time_min = register_cvar("csgo_spawn_after_time_min", "5.0");
cvar_spawn_after_time_max = register_cvar("csgo_spawn_after_time_min", "15.0");
SsInit(800.0);
SsScan();
loadPresents();
}
public giveItems(id)
{
new item = pickRandomItem();
new random;
new name[64];
get_user_name(id, name, charsmax(name));
if(item != -1)
{
for(new i = 1; i < 8; i++)
{
if(hasItem[item][i] == 1)
{
switch(i)
{
case ITEM_TYPE_SKIN:
{
if(presentAmountsMinimum[item][i] == presentAmountsMaximum[item][i]) random = presentAmountsMinimum[item][i]
else random = random_num(presentAmountsMinimum[item][i], presentAmountsMaximum[item][i]);
new s_name[64], w_name[64]
for(new j; j < random; j++)
{
new skin_id = -1;
if(presentItems[item][i] == -2) skin_id = cs_pick_random_skin(id, cs_pick_random_chest(id));
else skin_id = presentItems[item][i];
if(skin_id != -1 && skin_id <= cs_get_skins_count())
{
cs_get_skin_name(skin_id, s_name);
cs_get_weapon_name(cs_get_skin_weapon_id(skin_id), w_name);
client_printcolor(id, "/y[/ctrCSGO/y] You got /g%s /y(/g%s/y) skin from a present!", s_name, w_name);
cs_give_skin(id, skin_id, 0);
client_printcolor(0, "/y[/ctrCSGO/y] Player /g%s /ygot /g%s /y(/g%s/y) skin from a present!", name, s_name, w_name);
}
}
}
case ITEM_TYPE_SKIN_PART:
{
if(presentAmountsMinimum[item][i] == presentAmountsMaximum[item][i]) random = presentAmountsMinimum[item][i]
else random = random_num(presentAmountsMinimum[item][i], presentAmountsMaximum[item][i]);
new s_name[64], w_name[64]
for(new j; j < random; j++)
{
new skin_id = -1;
if(presentItems[item][i] == -2) skin_id = cs_pick_random_skin(id, cs_pick_random_chest(id));
else skin_id = presentItems[item][i];
if(skin_id != -1 && skin_id <= cs_get_skins_count())
{
cs_get_skin_name(skin_id, s_name);
cs_get_weapon_name(cs_get_skin_weapon_id(skin_id), w_name);
client_printcolor(id, "/y[/ctrCSGO/y] You got /g%s /y(/g%s/y) skin part from a present!", s_name, w_name);
cs_set_skin_parts(id, skin_id, cs_get_skin_parts(id, skin_id)+1);
client_printcolor(0, "/y[/ctrCSGO/y] Player /g%s /ygot /g%s /y(/g%s/y) skin part from a present!", name, s_name, w_name);
}
}
}
case ITEM_TYPE_CHEST:
{
if(presentAmountsMinimum[item][i] == presentAmountsMaximum[item][i]) random = presentAmountsMinimum[item][i]
else random = random_num(presentAmountsMinimum[item][i], presentAmountsMaximum[item][i]);
new c_name[64];
for(new j; j < random; j++)
{
new chest_id = -1;
if(presentItems[item][i] == -2) chest_id = cs_pick_random_chest(id);
else chest_id = presentItems[item][i];
if(chest_id != -1 && chest_id <= cs_get_chests_count())
{
cs_get_chest_name(chest_id, c_name);
client_printcolor(id, "/y[/ctrCSGO/y] You got /g%s /ychest from a present!", c_name);
cs_set_chest_count(id, chest_id, cs_get_chest_count(id, chest_id)+1);
client_printcolor(0, "/y[/ctrCSGO/y] Player /g%s /ygot /g%s /ychest from a present!", name, c_name);
}
}
}
case ITEM_TYPE_KEY:
{
if(presentAmountsMinimum[item][i] == presentAmountsMaximum[item][i]) random = presentAmountsMinimum[item][i]
else random = random_num(presentAmountsMinimum[item][i], presentAmountsMaximum[item][i]);
cs_set_keys_count(id, cs_get_keys_count(id)+random);
client_printcolor(id, "/y[/ctrCSGO/y] You got /g%d /ykey(s) from a present!", random);
client_printcolor(0, "/y[/ctrCSGO/y] Player /g%s /ygot /g%d /ykey(s) from a present!", name, random);
}
case ITEM_TYPE_MATERIAL:
{
if(presentAmountsMinimum[item][i] == presentAmountsMaximum[item][i]) random = presentAmountsMinimum[item][i]
else random = random_num(presentAmountsMinimum[item][i], presentAmountsMaximum[item][i]);
new m_name[64];
for(new j; j < random; j++)
{
new material = -1;
if(presentItems[item][i] == -2) material = cs_pick_random_material(id);
else material = presentItems[item][i];
if(material != -1 && material < MAX_MATERIALS)
{
cs_get_material_name(material, m_name);
client_printcolor(id, "/y[/ctrCSGO/y] You got /g%s /ymaterial part from a present!", m_name);
cs_set_materials(id, material, cs_get_materials(id, material)+1);
client_printcolor(0, "/y[/ctrCSGO/y] Player /g%s /ygot /g%s /ymaterial part from a present!", name, m_name);
}
}
}
case ITEM_TYPE_POINTS:
{
if(presentAmountsMinimum[item][i] == presentAmountsMaximum[item][i]) random = presentAmountsMinimum[item][i]
else random = random_num(presentAmountsMinimum[item][i], presentAmountsMaximum[item][i]);
cs_set_points(id, cs_get_points(id)+random);
client_printcolor(id, "/y[/ctrCSGO/y] You got /g%d /ypoint(s) from a present!", random);
}
case ITEM_TYPE_MONEY:
{
if(presentAmountsMinimum[item][i] == presentAmountsMaximum[item][i]) random = presentAmountsMinimum[item][i]
else random = random_num(presentAmountsMinimum[item][i], presentAmountsMaximum[item][i]);
cs_set_money(id, cs_get_money(id)+random);
client_printcolor(id, "/y[/ctrCSGO/y] You got /g$%d /yfrom a present!", random);
}
}
}
}
}
}
public plugin_precache()
{
loadModels();
}
public loadModels()
{
new configs_dir[128], configuration_file[128];
get_configsdir(configs_dir, charsmax(configs_dir));
format(configuration_file, charsmax(configuration_file), "%s/csgo", configs_dir);
if(!dir_exists(configuration_file)) mkdir(configuration_file);
format(configuration_file, charsmax(configuration_file), "%s/csgo/presents", configs_dir);
if(!dir_exists(configuration_file)) mkdir(configuration_file);
format(configuration_file, charsmax(configuration_file), "%s/csgo/presents/models.ini", configs_dir);
if(file_exists(configuration_file))
{
new szData[256], iTextLength, iLine, model[128];
while (read_file(configuration_file, iLine, szData, charsmax(szData), iTextLength) != 0)
{
if(models_count >= MAX_MODELS) break;
if (szData[0] == ';' || !szData[0] || strlen(szData) < 5 || szData[0] == '/')
{
iLine++;
continue;
}
parse(szData, model, charsmax(model));
formatex(model_present[models_count], charsmax(model_present[]), model);
engfunc(EngFunc_PrecacheModel,model_present[models_count])
models_count++;
iLine++;
}
}
else
{
write_file(configuration_file, ";Presents model files (You can multiple models)");
write_file(configuration_file, ";Example: ^"models/csgo/presents/example.mdl^"");
//formatex(model_present[0], charsmax(model_present[]), "models/csgo/presents/example.mdl");
//engfunc(EngFunc_PrecacheModel,model_present[0])
//models_count = 1;
}
}
public loadPresents()
{
new configs_dir[128], configuration_file[128];
get_configsdir(configs_dir, charsmax(configs_dir));
format(configuration_file, charsmax(configuration_file), "%s/csgo", configs_dir);
if(!dir_exists(configuration_file)) mkdir(configuration_file);
format(configuration_file, charsmax(configuration_file), "%s/csgo/presents", configs_dir);
if(!dir_exists(configuration_file)) mkdir(configuration_file);
format(configuration_file, charsmax(configuration_file), "%s/csgo/presents/items.ini", configs_dir);
if(file_exists(configuration_file))
{
new szData[256], iTextLength, iLine, types[256], item_id[256], item_amount[256], chance[64], szLeft[64], szRight[64], item[7];
new results[7][256], totalContents = 0, i;
while (read_file(configuration_file, iLine, szData, charsmax(szData), iTextLength) != 0)
{
if(models_count >= MAX_MODELS) break;
if (szData[0] == ';' || !szData[0] || strlen(szData) < 5 || szData[0] == '/')
{
iLine++;
continue;
}
totalContents = 0
parse(szData, types, charsmax(types), item_id, charsmax(item_id), item_amount, charsmax(item_amount), chance, charsmax(chance));
ExplodeString(results, 7, charsmax(results[]), types, ' ');
for(i = 0; i < 7; i++)
{
if(equal(results[i], "CHEST"))
{
item[totalContents] = ITEM_TYPE_CHEST
hasItem[contentsCount][item[totalContents]] = 1;
totalContents++
}
else if(equal(results[i], "SKIN"))
{
item[totalContents] = ITEM_TYPE_SKIN
hasItem[contentsCount][item[totalContents]] = 1;
totalContents++
}
else if(equal(results[i], "SKIN_PART"))
{
item[totalContents] = ITEM_TYPE_SKIN_PART
hasItem[contentsCount][item[totalContents]] = 1;
totalContents++
}
else if(equal(results[i], "KEY"))
{
item[totalContents] = ITEM_TYPE_KEY
hasItem[contentsCount][item[totalContents]] = 1;
totalContents++
}
else if(equal(results[i], "MATERIAL"))
{
item[totalContents] = ITEM_TYPE_MATERIAL
hasItem[contentsCount][item[totalContents]] = 1;
totalContents++
}
else if(equal(results[i], "POINTS"))
{
item[totalContents] = ITEM_TYPE_POINTS
hasItem[contentsCount][item[totalContents]] = 1;
totalContents++
}
else if(equal(results[i], "MONEY"))
{
item[totalContents] = ITEM_TYPE_MONEY
hasItem[contentsCount][item[totalContents]] = 1;
totalContents++
}
}
ExplodeString(results, 7, charsmax(results[]), item_id, ' ');
for(i = 0; i < totalContents; i++) // Put item_id values
{
if(equal(results[i], "*")) presentItems[contentsCount][item[i]] = -2
else presentItems[contentsCount][item[i]] = str_to_num(results[i]);
}
ExplodeString(results, 7, charsmax(results[]), item_amount, ' ');
for(i = 0; i < totalContents; i++) // Put amount values
{
if(containi(results[i], "-") != -1)
{
split(results[i], szLeft, charsmax(szLeft), szRight, charsmax(szRight), "-");
presentAmountsMinimum[contentsCount][item[i]] = str_to_num(szLeft);
presentAmountsMaximum[contentsCount][item[i]] = str_to_num(szRight);
}
else
{
presentAmountsMinimum[contentsCount][item[i]] = str_to_num(results[i]);
presentAmountsMaximum[contentsCount][item[i]] = str_to_num(results[i]);
}
}
presentChances[contentsCount] = str_to_float(chance);
contentsCount++;
iLine++;
}
}
else
{
write_file(configuration_file, ";Configuration of present contents");
write_file(configuration_file, ";ITEM_TYPE {SKIN, SKIN_PART, CHEST, KEY, MATERIAL, MONEY, POINTS}");
write_file(configuration_file, ";if ITEM_ID is '*' server will pick random ITEM_ID");
write_file(configuration_file, ";ITEM_TYPE ITEM_ID AMOUNT CHANCE%");
write_file(configuration_file, ";This example shows, that player has 0.5% chance to get 1 RANDOM SKIN, 1 RANDOM CHEST and from 1 to 2 KEYS from a present at the same time");
write_file(configuration_file, ";Multiple contents example: ^"SKIN CHEST KEY^" ^"* * -1^" ^"1 1 1-2^" 0.5");
write_file(configuration_file, "^"MONEY^" ^"-1^" ^"300-500^" ^"0.5^"");
presentChances[contentsCount] = 0.5;
presentAmountsMinimum[contentsCount][ITEM_TYPE_MONEY] = 300;
presentAmountsMaximum[contentsCount][ITEM_TYPE_MONEY] = 500;
contentsCount = 1;
}
}
public spawn_gifts()
{
remove_task(111);
new ent = -1
while ((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "present_box")))
engfunc(EngFunc_RemoveEntity, ent)
if(get_playersnum() >= get_pcvar_num(cvar_min_players)) {
set_task(random_float(get_pcvar_float(cvar_spawn_after_time_min), get_pcvar_float(cvar_spawn_after_time_max)), "func_spawn", 111);
}
}
public func_spawn()
{
if(models_count > 0)
{
new Float:origin[3]
new i
for(i=0; i< get_pcvar_num(pcvar_presents_on_map); i++)
{
if(SsGetOrigin(origin))
{
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
if(pev_valid(ent))
{
engfunc(EngFunc_SetModel,ent,model_present[random_num(0, models_count-1)])
engfunc(EngFunc_SetOrigin, ent, origin)
static Float:fMaxs[3] = { 2.0, 2.0, 4.0 }
static Float:fMins[3] = { -2.0, -2.0, -4.0 }
set_pev(ent,pev_movetype,MOVETYPE_NOCLIP)
set_pev(ent,pev_solid,SOLID_TRIGGER)
//set_pev(ent,pev_solid,SOLID_BBOX)
engfunc(EngFunc_SetSize,ent,fMins,fMaxs)
engfunc(EngFunc_DropToFloor, ent)
set_pev(ent,pev_classname,"present_box")
if(get_pcvar_num(cvar_glow_enabled))
{
new Float:fGlowColors[3];
new gColors[3][64];
new cvar[64];
get_pcvar_string(cvar_glow, cvar, charsmax(cvar))
parse(cvar, gColors[0], charsmax(gColors[]), gColors[1], charsmax(gColors[]), gColors[2], charsmax(gColors[]));
fGlowColors[0] = str_to_float(gColors[0]);
fGlowColors[1] = str_to_float(gColors[1]);
fGlowColors[2] = str_to_float(gColors[2]);
entity_set_int(ent, EV_INT_renderfx, kRenderFxGlowShell)
entity_set_vector(ent, EV_VEC_rendercolor, fGlowColors)
}
if(get_pcvar_num(cvar_spin)) set_task(0.1,"spin_present",ent)
}
}
}
if(get_pcvar_num(cvar_announce) > 0) client_printcolor(0, "/y[/ctrCSGO/y] Presents appreared somewhere! Go pick it up!");
}
}
public spin_present(ent)
{
if(pev_valid(ent))
{
static Float:floatvector[3]
floatvector[0] = 0.0
floatvector[1] = 25.0
floatvector[2] = 0.0
set_pev(ent,pev_avelocity,floatvector)
}
}
public forward_touch(ent,id)
{
if(!pev_valid(ent))
return FMRES_IGNORED
static class[20]
pev(ent,pev_classname,class,sizeof class - 1)
if(!equali(class,"present_box"))
return FMRES_IGNORED
if(!is_user_alive(id))
return FMRES_IGNORED
set_pev(ent,pev_solid,SOLID_NOT)
set_pev(ent,pev_effects,EF_NODRAW)
giveItems(id);
remove_entity(ent)
return FMRES_IGNORED
}
public pickRandomItem()
{
new Float:number = random_float(0.000000001, 100.0);
new contents[MAX_CONTENTS], cont;
for(new i; i < contentsCount; i++)
{
if(presentChances[i] >= number)
{
contents[cont] = i;
cont++;
}
}
if(cont <= 0) return -1;
else if(cont == 1) return contents[0];
return contents[random_num(0, cont-1)];
}
stock ExplodeString( p_szOutput[][], p_nMax, p_nSize, p_szInput[], p_szDelimiter )
{
new nIdx = 0, l = strlen(p_szInput)
new nLen = (1 + copyc( p_szOutput[nIdx], p_nSize, p_szInput, p_szDelimiter ))
while( (nLen < l) && (++nIdx < p_nMax) )
nLen += (1 + copyc( p_szOutput[nIdx], p_nSize, p_szInput[nLen], p_szDelimiter ))
return
}