Raised This Month: $51 Target: $400
 12% 

Spawn protection until player moves or shoots


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iclassdon
AlliedModders Donor
Join Date: May 2006
Old 10-24-2019 , 16:23   Spawn protection until player moves or shoots
Reply With Quote #1

Spawn protection until player moves or shoots. I searched all over the forum and only found it for SourceMod.
iclassdon is offline
Send a message via MSN to iclassdon
E1_531G
Senior Member
Join Date: Dec 2017
Old 10-24-2019 , 17:03   Re: Spawn protection until player moves or shoots
Reply With Quote #2

Search inside CSDM2 by KWo.
__________________
My English is A0
E1_531G is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 10-24-2019 , 17:50   Re: Spawn protection until player moves or shoots
Reply With Quote #3

Not Fully tested, but log seems to be ok

Code:
#include <amxmodx> #include <amxmisc> #include <hamsandwich> #include <engine> #include <fakemeta> #include <fun> new bool:CanTakeDmg[33] new gOldAngles[33][3] #define XO_WEAPON 4 #define m_pPlayer 41 public plugin_init() {     register_plugin("Test", AMXX_VERSION_STR, "Alliedmodders")     RegisterHam(Ham_Spawn, "player", "PlayerSpawn", 1)         new Ent = create_entity("info_target")     register_think("checking_players_ent", "afkCheck_entThink")     entity_set_string(Ent, EV_SZ_classname, "checking_players_ent")     entity_set_float(Ent, EV_FL_nextthink, get_gametime() + 0.1)         new szWeaponName[32]     new NOSHOT_BITSUM = (1<<CSW_KNIFE) | (1<<CSW_HEGRENADE) | (1<<CSW_FLASHBANG) | (1<<CSW_SMOKEGRENADE)     for(new iId = CSW_P228; iId <= CSW_P90; iId++)     {         if( ~NOSHOT_BITSUM & 1<<iId && get_weaponname(iId, szWeaponName, charsmax(szWeaponName)))         {             RegisterHam(Ham_Weapon_PrimaryAttack, szWeaponName, "WEAPON_PrimaryAttack_PRE", 0)         }     } } public WEAPON_PrimaryAttack_PRE( iWeapon ) {     static id         id = get_pdata_cbase(iWeapon, m_pPlayer, XO_WEAPON)         CanTakeDmg[id] = true } public PlayerSpawn(id) {     if(is_user_alive(id))     {         CanTakeDmg[id] = false         get_user_origin(id, gOldAngles[id])     } } public afkCheck_entThink(ent) {     checkPlayers()         entity_set_float(ent, EV_FL_nextthink, get_gametime() + 0.5) } public checkPlayers() {     new iPlayers[32], iNum, id     get_players(iPlayers, iNum, "a")     for(new i = 0; i < iNum; i++)     {         id = iPlayers[i]                 new NewAngle[3]         get_user_origin(id, NewAngle)                 if (NewAngle[0] != gOldAngles[id][0] && NewAngle[1] != gOldAngles[id][1] && NewAngle[2] != gOldAngles[id][2])         {             CanTakeDmg[id] = true                         set_pev(id, pev_takedamage, DAMAGE_AIM)                         set_user_rendering(id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 255)         }                 else                 {                         set_user_rendering(id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 70)                         set_pev(id, pev_takedamage, DAMAGE_NO)                 }     } }
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/

Last edited by iceeedr; 10-24-2019 at 22:41.
iceeedr is offline
Send a message via Skype™ to iceeedr
iclassdon
AlliedModders Donor
Join Date: May 2006
Old 10-24-2019 , 19:31   Re: Spawn protection until player moves or shoots
Reply With Quote #4

Quote:
Originally Posted by iceeedr View Post
Not Fully tested, but log seems to be ok

Code:
#include <amxmodx> #include <amxmisc> #include <hamsandwich> #include <engine> #include <fakemeta> new bool:CanTakeDmg[33] new gOldAngles[33][3] #define XO_WEAPON 4 #define m_pPlayer 41 public plugin_init() {     register_plugin("Test", AMXX_VERSION_STR, "Alliedmodders")     RegisterHam(Ham_Spawn, "player", "PlayerSpawn", 1)     new Ent = create_entity("info_target")     register_think("checking_players_ent", "afkCheck_entThink")     entity_set_string(Ent, EV_SZ_classname, "checking_players_ent")     entity_set_float(Ent, EV_FL_nextthink, get_gametime() + 0.1)     new szWeaponName[32]     new NOSHOT_BITSUM = (1<<CSW_KNIFE) | (1<<CSW_HEGRENADE) | (1<<CSW_FLASHBANG) | (1<<CSW_SMOKEGRENADE)         for(new iId = CSW_P228; iId <= CSW_P90; iId++)         {             if( ~NOSHOT_BITSUM & 1<<iId && get_weaponname(iId, szWeaponName, charsmax(szWeaponName)))             {                     RegisterHam(Ham_Weapon_PrimaryAttack, szWeaponName, "WEAPON_PrimaryAttack_PRE", 0)             }         } } public WEAPON_PrimaryAttack_PRE( iWeapon ) {     static id     id = get_pdata_cbase(iWeapon, m_pPlayer, XO_WEAPON)     CanTakeDmg[id] = true } public PlayerSpawn(id) {     if(is_user_alive(id))     {         CanTakeDmg[id] = false         get_user_origin(id, gOldAngles[id])         set_pev(id, pev_takedamage, DAMAGE_NO)         if(CanTakeDmg[id])         {             set_pev(id, pev_takedamage, DAMAGE_AIM)         }     } } public afkCheck_entThink(ent) {     if(!CanTakeDmg[ent])         checkPlayers()             entity_set_float(ent, EV_FL_nextthink, get_gametime() + 0.1) } public checkPlayers() {     new iPlayers[32], iNum, id     get_players(iPlayers, iNum, "a")     for(new i = 0; i < iNum; i++)     {         id = iPlayers[i]         new NewAngle[3]         get_user_origin(id, NewAngle)         if (NewAngle[0] != gOldAngles[id][0] && NewAngle[1] != gOldAngles[id][1] && NewAngle[2] != gOldAngles[id][2])         {             CanTakeDmg[id] = true         }     } }
Thanks for your time iceeedr. I compiled it on amxmodx 1.9. I get the warning below.

"warning 217: loose indentation"

I went ahead and loaded it up on my CSDM server and it's like everyone has god mode. No one dies.

Btw can you add transparent semi clip look when they are in the protected spawn mode?
iclassdon is offline
Send a message via MSN to iclassdon
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 10-24-2019 , 22:43   Re: Spawn protection until player moves or shoots
Reply With Quote #5

Updated code, tested and working. If something does not work is incompatibility with CSDM (which was not mentioned in the main post) and honestly I will not delve into why possible incompatibility.
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-25-2019 , 01:07   Re: Spawn protection until player moves or shoots
Reply With Quote #6

checkPlayers function is unnecessary since the OP asked only if the player shoots or move so hooking player think would be fine
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
iclassdon
AlliedModders Donor
Join Date: May 2006
Old 10-25-2019 , 10:04   Re: Spawn protection until player moves or shoots
Reply With Quote #7

I tried it again and this time it didn't work at all. I tried it with CSDM spawn protect disabled and enabled. I don't want to take up anymore of your time. Thanks again iceeedr.
iclassdon is offline
Send a message via MSN to iclassdon
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:05.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode