Spoiler
#include <amxmodx>
#include <colorchat>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <fakemeta_util>
#include <fun>
#include <hamsandwich>
#define IsPlayer(%1) (1<=%1<=maxPlayers)
#define write_coord_f(%1) engfunc(EngFunc_WriteCoord, %1)
forward amxbans_admin_connect(id);
new Array:g_Array, bool:g_Vip[33], bool:hs[33][33], g_Hudmsg, ioid,
m_DeathMsg, m_ScoreAttrib, m_ScoreInfo, m_ScreenFade, maxPlayers,
skoki[33], sprSkull;
new const clips[]={0, 13, -0, 10, 1, 7, 0, 30, 30, 1, 30, 20, 25, 30, 35, 25, 12, 20, 10, 30, 100, 8, 30, 30, 20, 2, 7, 30, 30, 0, 50};
new const g_Langcmd[][]={"say /vips","say_team /vips","say /vipy","say_team /vipy"};
new const spawnEntString[2][]={
"info_player_start",
"info_player_deathmatch"
};
public plugin_init(){
register_plugin("VIP Ultimate", "12.3.0.2", "benio101 & speedkill");
register_forward(FM_CmdStart, "CmdStartPre");
RegisterHam(Ham_Spawn, "player", "SpawnedEventPre", 1);
RegisterHam(Ham_TakeDamage, "player", "takeDamage", 0);
register_event("DeathMsg", "DeathMsg", "a");
register_message(get_user_msgid("ScoreAttrib"), "VipStatus");
g_Array=ArrayCreate(64,32);
for(new i;i<sizeof g_Langcmd;i++){
register_clcmd(g_Langcmd[i], "ShowVips");
}
register_clcmd("say /vip", "ShowMotd");
g_Hudmsg=CreateHudSyncObj();
register_event("Damage", "damage", "b", "2!0", "3=0", "4!0");
register_message(get_user_msgid("SayText"),"handleSayText");
RegisterHam(Ham_Killed, "player", "killedPre", 0);
RegisterHam(Ham_TraceAttack, "player", "traceAttack", 1);
}
public client_authorized(id){
if(get_user_flags(id) & 524288 == 524288){
client_authorized_vip(id);
}
}
public client_authorized_vip(id){
g_Vip[id]=true;
new g_Name[64];
get_user_name(id,g_Name,charsmax(g_Name));
new g_Size = ArraySize(g_Array);
new szName[64];
for(new i = 0; i < g_Size; i++){
ArrayGetString(g_Array, i, szName, charsmax(szName));
if(equal(g_Name, szName)){
return 0;
}
}
ArrayPushString(g_Array,g_Name);
set_hudmessage(24, 190, 220, 0.25, 0.2, 0, 6.0, 6.0);
ShowSyncHudMsg(0, g_Hudmsg, "= VIP = %s wbija na serwer !",g_Name);
return PLUGIN_CONTINUE;
}
public client_disconnect(id){
if(g_Vip[id]){
client_disconnect_vip(id);
}
}
public client_disconnect_vip(id){
g_Vip[id]=false;
new Name[64];
get_user_name(id,Name,charsmax(Name));
new g_Size = ArraySize(g_Array);
new g_Name[64];
for(new i = 0; i < g_Size; i++){
ArrayGetString(g_Array, i, g_Name, charsmax(g_Name));
if(equal(g_Name,Name)){
ArrayDeleteItem(g_Array,i);
break;
}
}
}
public CmdStartPre(id, uc_handle){
if(g_Vip[id]){
if(is_user_alive(id)){
CmdStartPreVip(id, uc_handle);
}
}
}
public CmdStartPreVip(id, uc_handle){
new flags = pev(id, pev_flags);
if((get_uc(uc_handle, UC_Buttons) & IN_JUMP) && !(flags & FL_ONGROUND) && !(pev(id, pev_oldbuttons) & IN_JUMP) && skoki[id]>0){
--skoki[id];
new Float:velocity[3];
pev(id, pev_velocity,velocity);
velocity[2] = random_float(265.0,285.0);
set_pev(id,pev_velocity,velocity);
} else if(flags & FL_ONGROUND && skoki[id]!=-1){
skoki[id] = 2;
}
}
public SpawnedEventPre(id){
if(g_Vip[id]){
if(is_user_alive(id)){
SpawnedEventPreVip(id);
}
}
}
public SpawnedEventPreVip(id){
skoki[id]=2;
set_user_health(id, get_user_health(id)+50);
recharge(id);
new g_Model[64];
formatex(g_Model,charsmax(g_Model),"%s",get_user_team(id) == 1 ? "vipt" : "vipc");
cs_set_user_model(id,g_Model);
}
public recharge(id){
new wid=get_user_weapon(id);
if(wid){
new weaponname[32], weid;
get_weaponname(wid, weaponname, 31);
weid=find_ent_by_owner(-1, weaponname, id);
if(weid){
cs_set_weapon_ammo(weid, clips[wid]);
}
}
}
public plugin_cfg(){
maxPlayers=get_maxplayers();
m_ScreenFade=get_user_msgid("ScreenFade");
m_DeathMsg=get_user_msgid("DeathMsg");
m_ScoreAttrib=get_user_msgid("ScoreAttrib");
m_ScoreInfo=get_user_msgid("ScoreInfo");
}
public takeDamage(this, idinflictor, idattacker, Float:damage, damagebits){
if(((IsPlayer(idattacker) && is_user_connected(idattacker) && g_Vip[idattacker] && (ioid=idattacker)) ||
(ioid=pev(idinflictor, pev_owner) && IsPlayer(ioid) && is_user_connected(ioid) && g_Vip[ioid]))){
damage*=(100+5)/100;
}
}
public DeathMsg(){
new killer=read_data(1);
new victim=read_data(2);
if(is_user_alive(killer) && g_Vip[killer] && get_user_team(killer) != get_user_team(victim)){
DeathMsgVip(killer,victim,read_data(3));
}
}
public DeathMsgVip(kid,vid,hs){
set_user_health(kid, min(get_user_health(kid)+(hs?15:10),130));
cs_set_user_money(kid, cs_get_user_money(kid)+(hs?500:300));
recharge(kid);
}
public VipStatus(){
new id=get_msg_arg_int(1);
if(is_user_alive(id) && g_Vip[id]){
set_msg_arg_int(2, ARG_BYTE, get_msg_arg_int(2)|4);
}
}
public ShowVips(id){
new g_Name[64],g_Message[192];
new g_Size=ArraySize(g_Array);
for(new i = 0; i < g_Size; i++){
ArrayGetString(g_Array, i, g_Name, charsmax(g_Name));
add(g_Message, charsmax(g_Message), g_Name);
if(i == g_Size - 1){
add(g_Message, charsmax(g_Message), ".");
}
else{
add(g_Message, charsmax(g_Message), ", ");
}
}
ColorChat(id,GREEN,"^x03Vipy ^x04na ^x03serwerze: ^x04%s", g_Message);
return PLUGIN_CONTINUE;
}
public client_infochanged(id){
if(g_Vip[id]){
new szName[64];
get_user_info(id,"name",szName,charsmax(szName));
new Name[64];
get_user_name(id,Name,charsmax(Name));
if(!equal(szName,Name)){
ArrayPushString(g_Array,szName);
new g_Size=ArraySize(g_Array);
new g_Name[64];
for(new i = 0; i < g_Size; i++){
ArrayGetString(g_Array, i, g_Name, charsmax(g_Name));
if(equal(g_Name,Name)){
ArrayDeleteItem(g_Array,i);
break;
}
}
}
}
}
public plugin_end(){
ArrayDestroy(g_Array);
}
public ShowMotd(id){
show_motd(id, "vip.txt", "Informacje o vipie");
}
public damage(id){
new attacker=get_user_attacker(id);
new damage=read_data(2);
if(g_Vip[id]){
set_hudmessage(255, 0, 0, 0.45, 0.50, 2, 0.1, 4.0, 0.1, 0.1, -1);
ShowSyncHudMsg(id, g_Hudmsg, "%i^n", damage);
}
if(is_user_connected(attacker) && g_Vip[attacker]){
set_hudmessage(0, 100, 200, -1.0, 0.55, 2, 0.1, 4.0, 0.02, 0.02, -1);
ShowSyncHudMsg(attacker, g_Hudmsg, "%i^n", damage);
}
}
public handleSayText(msgId,msgDest,msgEnt){
new id = get_msg_arg_int(1);
if(is_user_connected(id) && g_Vip[id]){
new szTmp[256],szTmp2[256];
get_msg_arg_string(2,szTmp, charsmax(szTmp))
new szPrefix[64] = "^x04[VIP]";
if(!equal(szTmp,"#Cstrike_Chat_All")){
add(szTmp2,charsmax(szTmp2),szPrefix);
add(szTmp2,charsmax(szTmp2)," ");
add(szTmp2,charsmax(szTmp2),szTmp);
}
else{
add(szTmp2,charsmax(szTmp2),szPrefix);
add(szTmp2,charsmax(szTmp2),"^x03 %s1^x01 : %s2");
}
set_msg_arg_string(2,szTmp2);
}
return PLUGIN_CONTINUE;
}
public plugin_precache(){
precache_model("models/player/vipc/vipc.mdl");
precache_model("models/player/vipt/vipt.mdl");
sprSkull=precache_model("sprites/skull.spr");
}
public traceAttack(vid, aid, Float:dmg, Float:dir[3], ptr, dmgbits){
if(IsPlayer(aid)){
hs[aid][vid]=bool:(get_tr2(ptr, TR_iHitgroup)==1);
}
}
public screen_flash(id, red, green, blue, alpha){
message_begin(MSG_ONE_UNRELIABLE, m_ScreenFade, _, id);
write_short(1<<12);
write_short(1<<12);
write_short(1<<12);
write_byte(red);
write_byte(green);
write_byte(blue);
write_byte(alpha);
message_end();
}
public find_free_spawn(iTeamNumber, Float:spawnOrigin[3], Float:spawnAngle[3]){
new iSpawn;
if(iTeamNumber==2)
iSpawn=0;
else
iSpawn=1;
const maxSpawns=128;
new spawnPoints[maxSpawns], bool:spawnChecked[maxSpawns], spawnpoint, spawnnum;
new ent=-1, spawnsFound=0;
while((ent=fm_find_ent_by_class(ent,spawnEntString[iSpawn])) && spawnsFound<maxSpawns)
spawnPoints[spawnsFound++]=ent;
new Float:vicinity = 100.0; //(32x32x96)
new i, entList[1];
for(i=0; i<maxSpawns; i++)
spawnChecked[i]=false;
// Loop through all the spawn points
i=0;
while(i++<spawnsFound*10){
spawnnum=random(spawnsFound);
spawnpoint=spawnPoints[spawnnum];
if(spawnpoint && !spawnChecked[spawnnum]){
//don't check this spawn point again
spawnChecked[spawnnum]=true;
// Get the origin of the spawn point
pev(spawnpoint, pev_origin, spawnOrigin);
// Determine if something is in this near the spawn point
if(!fm_find_sphere_class(0, "player", vicinity, entList, 1, spawnOrigin)){
// If there is nothing, return the angles and spawnpoint
pev(spawnpoint, pev_angles, spawnAngle);
return spawnpoint;
}
}
}
return 0;
}
stock fm_find_sphere_class(ent, const _classname[], Float:radius, entlist[], maxents, Float:origin[3]={0.0,0.0,0.0}){
if( pev_valid(ent) )
pev( ent, pev_origin, origin );
new tempent, tempclass[32], entsfound;
while( (tempent = fm_find_ent_in_sphere(tempent, origin, radius) ) && entsfound < maxents ){
if( pev_valid(tempent) ){
pev(tempent, pev_classname, tempclass, 31);
if( equal( _classname, tempclass ) )
entlist[entsfound++] = tempent;
}
}
return entsfound;
}
public teleport_to_own_spawn(data[]){
new id=data[0];
new origin[3], Float:fl_origin[3];
new Float:angle[3], Float:fOrigin[3];
pev(id, pev_origin, fOrigin);
fOrigin[2]+=35.0;
message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_SPRITE);
write_coord_f(fOrigin[0]);
write_coord_f(fOrigin[1]);
write_coord_f(fOrigin[2]);
write_short(sprSkull);
write_byte(20);
write_byte(255);
message_end();
find_free_spawn(get_user_team(id), fl_origin, angle);
FVecIVec(fl_origin, origin);
set_user_origin(id, origin);
set_pev(id, pev_angles, angle);
}
public remove_godmode(data[]){
set_user_godmode(data[0]);
}
public recharge0(data[]){
recharge(data[0]);
}
public do_deathmsg(iKiller, iVictim, iHS, const szWeapon[]){
message_begin(MSG_BROADCAST, m_DeathMsg);
write_byte(iKiller);
write_byte(iVictim);
write_byte(iHS);
write_string(szWeapon);
message_end();
}
public killedPre(id, kid){
if(g_Vip[id] && random(100)<2){
ExecuteHam(Ham_AddPoints, kid, 1, true);
screen_flash(id, 255, 0, 0, 100);
set_user_health(id, 100);
set_user_godmode(id, 1);
new data[1];
data[0]=id;
set_task(0.1, "teleport_to_own_spawn", _, data, 1);
set_task(0.55, "recharge0", _, data, 1);
set_task(1.0, "remove_godmode", _, data, 1);
new bool:suicide;
if(IsPlayer(kid)){
if(id==kid){
suicide=true;
do_deathmsg(id, id, 0, "suicide");
} else {
if(get_user_team(kid)!=get_user_team(id)){
ExecuteHam(Ham_AddPoints, kid, 1, true);
}
new szWeapon[24];
get_weaponname(get_user_weapon(kid), szWeapon, 23);
replace(szWeapon, 23, "weapon_", "");
do_deathmsg(kid, id, hs[kid][id], szWeapon);
}
} else {
suicide=true;
do_deathmsg(id, id, 0, "suicide");
}
message_begin(MSG_BROADCAST, m_ScoreAttrib, {0,0,0}, 0);
write_byte(id);
write_byte((user_has_weapon(id, CSW_C4)?2:0)|cs_get_user_vip(id));
message_end();
message_begin(MSG_BROADCAST, m_ScoreInfo);
write_byte(id);
write_short(get_user_frags(id)-_:suicide);
write_short(cs_get_user_deaths(id)+1);
write_short(0);
write_short(get_user_team(id));
message_end();
set_pdata_int(id, 362, 0);
return HAM_SUPERCEDE;
}
return HAM_IGNORED;
}
public amxbans_admin_connect(id){
client_authorized(id);
}
#include <colorchat>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <fakemeta_util>
#include <fun>
#include <hamsandwich>
#define IsPlayer(%1) (1<=%1<=maxPlayers)
#define write_coord_f(%1) engfunc(EngFunc_WriteCoord, %1)
forward amxbans_admin_connect(id);
new Array:g_Array, bool:g_Vip[33], bool:hs[33][33], g_Hudmsg, ioid,
m_DeathMsg, m_ScoreAttrib, m_ScoreInfo, m_ScreenFade, maxPlayers,
skoki[33], sprSkull;
new const clips[]={0, 13, -0, 10, 1, 7, 0, 30, 30, 1, 30, 20, 25, 30, 35, 25, 12, 20, 10, 30, 100, 8, 30, 30, 20, 2, 7, 30, 30, 0, 50};
new const g_Langcmd[][]={"say /vips","say_team /vips","say /vipy","say_team /vipy"};
new const spawnEntString[2][]={
"info_player_start",
"info_player_deathmatch"
};
public plugin_init(){
register_plugin("VIP Ultimate", "12.3.0.2", "benio101 & speedkill");
register_forward(FM_CmdStart, "CmdStartPre");
RegisterHam(Ham_Spawn, "player", "SpawnedEventPre", 1);
RegisterHam(Ham_TakeDamage, "player", "takeDamage", 0);
register_event("DeathMsg", "DeathMsg", "a");
register_message(get_user_msgid("ScoreAttrib"), "VipStatus");
g_Array=ArrayCreate(64,32);
for(new i;i<sizeof g_Langcmd;i++){
register_clcmd(g_Langcmd[i], "ShowVips");
}
register_clcmd("say /vip", "ShowMotd");
g_Hudmsg=CreateHudSyncObj();
register_event("Damage", "damage", "b", "2!0", "3=0", "4!0");
register_message(get_user_msgid("SayText"),"handleSayText");
RegisterHam(Ham_Killed, "player", "killedPre", 0);
RegisterHam(Ham_TraceAttack, "player", "traceAttack", 1);
}
public client_authorized(id){
if(get_user_flags(id) & 524288 == 524288){
client_authorized_vip(id);
}
}
public client_authorized_vip(id){
g_Vip[id]=true;
new g_Name[64];
get_user_name(id,g_Name,charsmax(g_Name));
new g_Size = ArraySize(g_Array);
new szName[64];
for(new i = 0; i < g_Size; i++){
ArrayGetString(g_Array, i, szName, charsmax(szName));
if(equal(g_Name, szName)){
return 0;
}
}
ArrayPushString(g_Array,g_Name);
set_hudmessage(24, 190, 220, 0.25, 0.2, 0, 6.0, 6.0);
ShowSyncHudMsg(0, g_Hudmsg, "= VIP = %s wbija na serwer !",g_Name);
return PLUGIN_CONTINUE;
}
public client_disconnect(id){
if(g_Vip[id]){
client_disconnect_vip(id);
}
}
public client_disconnect_vip(id){
g_Vip[id]=false;
new Name[64];
get_user_name(id,Name,charsmax(Name));
new g_Size = ArraySize(g_Array);
new g_Name[64];
for(new i = 0; i < g_Size; i++){
ArrayGetString(g_Array, i, g_Name, charsmax(g_Name));
if(equal(g_Name,Name)){
ArrayDeleteItem(g_Array,i);
break;
}
}
}
public CmdStartPre(id, uc_handle){
if(g_Vip[id]){
if(is_user_alive(id)){
CmdStartPreVip(id, uc_handle);
}
}
}
public CmdStartPreVip(id, uc_handle){
new flags = pev(id, pev_flags);
if((get_uc(uc_handle, UC_Buttons) & IN_JUMP) && !(flags & FL_ONGROUND) && !(pev(id, pev_oldbuttons) & IN_JUMP) && skoki[id]>0){
--skoki[id];
new Float:velocity[3];
pev(id, pev_velocity,velocity);
velocity[2] = random_float(265.0,285.0);
set_pev(id,pev_velocity,velocity);
} else if(flags & FL_ONGROUND && skoki[id]!=-1){
skoki[id] = 2;
}
}
public SpawnedEventPre(id){
if(g_Vip[id]){
if(is_user_alive(id)){
SpawnedEventPreVip(id);
}
}
}
public SpawnedEventPreVip(id){
skoki[id]=2;
set_user_health(id, get_user_health(id)+50);
recharge(id);
new g_Model[64];
formatex(g_Model,charsmax(g_Model),"%s",get_user_team(id) == 1 ? "vipt" : "vipc");
cs_set_user_model(id,g_Model);
}
public recharge(id){
new wid=get_user_weapon(id);
if(wid){
new weaponname[32], weid;
get_weaponname(wid, weaponname, 31);
weid=find_ent_by_owner(-1, weaponname, id);
if(weid){
cs_set_weapon_ammo(weid, clips[wid]);
}
}
}
public plugin_cfg(){
maxPlayers=get_maxplayers();
m_ScreenFade=get_user_msgid("ScreenFade");
m_DeathMsg=get_user_msgid("DeathMsg");
m_ScoreAttrib=get_user_msgid("ScoreAttrib");
m_ScoreInfo=get_user_msgid("ScoreInfo");
}
public takeDamage(this, idinflictor, idattacker, Float:damage, damagebits){
if(((IsPlayer(idattacker) && is_user_connected(idattacker) && g_Vip[idattacker] && (ioid=idattacker)) ||
(ioid=pev(idinflictor, pev_owner) && IsPlayer(ioid) && is_user_connected(ioid) && g_Vip[ioid]))){
damage*=(100+5)/100;
}
}
public DeathMsg(){
new killer=read_data(1);
new victim=read_data(2);
if(is_user_alive(killer) && g_Vip[killer] && get_user_team(killer) != get_user_team(victim)){
DeathMsgVip(killer,victim,read_data(3));
}
}
public DeathMsgVip(kid,vid,hs){
set_user_health(kid, min(get_user_health(kid)+(hs?15:10),130));
cs_set_user_money(kid, cs_get_user_money(kid)+(hs?500:300));
recharge(kid);
}
public VipStatus(){
new id=get_msg_arg_int(1);
if(is_user_alive(id) && g_Vip[id]){
set_msg_arg_int(2, ARG_BYTE, get_msg_arg_int(2)|4);
}
}
public ShowVips(id){
new g_Name[64],g_Message[192];
new g_Size=ArraySize(g_Array);
for(new i = 0; i < g_Size; i++){
ArrayGetString(g_Array, i, g_Name, charsmax(g_Name));
add(g_Message, charsmax(g_Message), g_Name);
if(i == g_Size - 1){
add(g_Message, charsmax(g_Message), ".");
}
else{
add(g_Message, charsmax(g_Message), ", ");
}
}
ColorChat(id,GREEN,"^x03Vipy ^x04na ^x03serwerze: ^x04%s", g_Message);
return PLUGIN_CONTINUE;
}
public client_infochanged(id){
if(g_Vip[id]){
new szName[64];
get_user_info(id,"name",szName,charsmax(szName));
new Name[64];
get_user_name(id,Name,charsmax(Name));
if(!equal(szName,Name)){
ArrayPushString(g_Array,szName);
new g_Size=ArraySize(g_Array);
new g_Name[64];
for(new i = 0; i < g_Size; i++){
ArrayGetString(g_Array, i, g_Name, charsmax(g_Name));
if(equal(g_Name,Name)){
ArrayDeleteItem(g_Array,i);
break;
}
}
}
}
}
public plugin_end(){
ArrayDestroy(g_Array);
}
public ShowMotd(id){
show_motd(id, "vip.txt", "Informacje o vipie");
}
public damage(id){
new attacker=get_user_attacker(id);
new damage=read_data(2);
if(g_Vip[id]){
set_hudmessage(255, 0, 0, 0.45, 0.50, 2, 0.1, 4.0, 0.1, 0.1, -1);
ShowSyncHudMsg(id, g_Hudmsg, "%i^n", damage);
}
if(is_user_connected(attacker) && g_Vip[attacker]){
set_hudmessage(0, 100, 200, -1.0, 0.55, 2, 0.1, 4.0, 0.02, 0.02, -1);
ShowSyncHudMsg(attacker, g_Hudmsg, "%i^n", damage);
}
}
public handleSayText(msgId,msgDest,msgEnt){
new id = get_msg_arg_int(1);
if(is_user_connected(id) && g_Vip[id]){
new szTmp[256],szTmp2[256];
get_msg_arg_string(2,szTmp, charsmax(szTmp))
new szPrefix[64] = "^x04[VIP]";
if(!equal(szTmp,"#Cstrike_Chat_All")){
add(szTmp2,charsmax(szTmp2),szPrefix);
add(szTmp2,charsmax(szTmp2)," ");
add(szTmp2,charsmax(szTmp2),szTmp);
}
else{
add(szTmp2,charsmax(szTmp2),szPrefix);
add(szTmp2,charsmax(szTmp2),"^x03 %s1^x01 : %s2");
}
set_msg_arg_string(2,szTmp2);
}
return PLUGIN_CONTINUE;
}
public plugin_precache(){
precache_model("models/player/vipc/vipc.mdl");
precache_model("models/player/vipt/vipt.mdl");
sprSkull=precache_model("sprites/skull.spr");
}
public traceAttack(vid, aid, Float:dmg, Float:dir[3], ptr, dmgbits){
if(IsPlayer(aid)){
hs[aid][vid]=bool:(get_tr2(ptr, TR_iHitgroup)==1);
}
}
public screen_flash(id, red, green, blue, alpha){
message_begin(MSG_ONE_UNRELIABLE, m_ScreenFade, _, id);
write_short(1<<12);
write_short(1<<12);
write_short(1<<12);
write_byte(red);
write_byte(green);
write_byte(blue);
write_byte(alpha);
message_end();
}
public find_free_spawn(iTeamNumber, Float:spawnOrigin[3], Float:spawnAngle[3]){
new iSpawn;
if(iTeamNumber==2)
iSpawn=0;
else
iSpawn=1;
const maxSpawns=128;
new spawnPoints[maxSpawns], bool:spawnChecked[maxSpawns], spawnpoint, spawnnum;
new ent=-1, spawnsFound=0;
while((ent=fm_find_ent_by_class(ent,spawnEntString[iSpawn])) && spawnsFound<maxSpawns)
spawnPoints[spawnsFound++]=ent;
new Float:vicinity = 100.0; //(32x32x96)
new i, entList[1];
for(i=0; i<maxSpawns; i++)
spawnChecked[i]=false;
// Loop through all the spawn points
i=0;
while(i++<spawnsFound*10){
spawnnum=random(spawnsFound);
spawnpoint=spawnPoints[spawnnum];
if(spawnpoint && !spawnChecked[spawnnum]){
//don't check this spawn point again
spawnChecked[spawnnum]=true;
// Get the origin of the spawn point
pev(spawnpoint, pev_origin, spawnOrigin);
// Determine if something is in this near the spawn point
if(!fm_find_sphere_class(0, "player", vicinity, entList, 1, spawnOrigin)){
// If there is nothing, return the angles and spawnpoint
pev(spawnpoint, pev_angles, spawnAngle);
return spawnpoint;
}
}
}
return 0;
}
stock fm_find_sphere_class(ent, const _classname[], Float:radius, entlist[], maxents, Float:origin[3]={0.0,0.0,0.0}){
if( pev_valid(ent) )
pev( ent, pev_origin, origin );
new tempent, tempclass[32], entsfound;
while( (tempent = fm_find_ent_in_sphere(tempent, origin, radius) ) && entsfound < maxents ){
if( pev_valid(tempent) ){
pev(tempent, pev_classname, tempclass, 31);
if( equal( _classname, tempclass ) )
entlist[entsfound++] = tempent;
}
}
return entsfound;
}
public teleport_to_own_spawn(data[]){
new id=data[0];
new origin[3], Float:fl_origin[3];
new Float:angle[3], Float:fOrigin[3];
pev(id, pev_origin, fOrigin);
fOrigin[2]+=35.0;
message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_SPRITE);
write_coord_f(fOrigin[0]);
write_coord_f(fOrigin[1]);
write_coord_f(fOrigin[2]);
write_short(sprSkull);
write_byte(20);
write_byte(255);
message_end();
find_free_spawn(get_user_team(id), fl_origin, angle);
FVecIVec(fl_origin, origin);
set_user_origin(id, origin);
set_pev(id, pev_angles, angle);
}
public remove_godmode(data[]){
set_user_godmode(data[0]);
}
public recharge0(data[]){
recharge(data[0]);
}
public do_deathmsg(iKiller, iVictim, iHS, const szWeapon[]){
message_begin(MSG_BROADCAST, m_DeathMsg);
write_byte(iKiller);
write_byte(iVictim);
write_byte(iHS);
write_string(szWeapon);
message_end();
}
public killedPre(id, kid){
if(g_Vip[id] && random(100)<2){
ExecuteHam(Ham_AddPoints, kid, 1, true);
screen_flash(id, 255, 0, 0, 100);
set_user_health(id, 100);
set_user_godmode(id, 1);
new data[1];
data[0]=id;
set_task(0.1, "teleport_to_own_spawn", _, data, 1);
set_task(0.55, "recharge0", _, data, 1);
set_task(1.0, "remove_godmode", _, data, 1);
new bool:suicide;
if(IsPlayer(kid)){
if(id==kid){
suicide=true;
do_deathmsg(id, id, 0, "suicide");
} else {
if(get_user_team(kid)!=get_user_team(id)){
ExecuteHam(Ham_AddPoints, kid, 1, true);
}
new szWeapon[24];
get_weaponname(get_user_weapon(kid), szWeapon, 23);
replace(szWeapon, 23, "weapon_", "");
do_deathmsg(kid, id, hs[kid][id], szWeapon);
}
} else {
suicide=true;
do_deathmsg(id, id, 0, "suicide");
}
message_begin(MSG_BROADCAST, m_ScoreAttrib, {0,0,0}, 0);
write_byte(id);
write_byte((user_has_weapon(id, CSW_C4)?2:0)|cs_get_user_vip(id));
message_end();
message_begin(MSG_BROADCAST, m_ScoreInfo);
write_byte(id);
write_short(get_user_frags(id)-_:suicide);
write_short(cs_get_user_deaths(id)+1);
write_short(0);
write_short(get_user_team(id));
message_end();
set_pdata_int(id, 362, 0);
return HAM_SUPERCEDE;
}
return HAM_IGNORED;
}
public amxbans_admin_connect(id){
client_authorized(id);
}