AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Set players view (https://forums.alliedmods.net/showthread.php?t=204914)

alonelive 01-04-2013 16:18

Set players view
 
2 Attachment(s)
Hello. I have a 2 questions..
Help me please with this:

1. how can i set view of ALL dead players \ spectators to FORCECHASECAM of last 2 alive players on map?

There are 2 alive players on map remaining (1 in TERR team, 1 - in CT team).
PHP Code:

for(new <= g_iMaxPlayers i++) {
if(!
is_user_alive(i) || cs_get_user_team == CS_TEAM_SPECTATOR || cs_get_user_team == CS_TEAM_UNASSIGNED) {

/*..there is command to change view mode to free chase cam of 2 alive players (dead CT -> to last alive CT, dead T - to last alive T, spectators - randomly (to T or CT) 

2. Is possible to dropping bomb (when alive player drop the bomb or dead player drop the bomb) directly perpendicular of the floor? Without range..

alonelive 01-04-2013 17:05

Re: Set players view
 
add to 1st question:
i have a code which calculate those 2 last alive players (ex. iPlayerLastT and iPlayerLastCT. I need only a command to set camera view to this players (free chase cam).

PHP Code:

for(new <= g_iMaxPlayers i++) {
   if(!
is_user_alive(i)) {

      if(
cs_get_user_team(i) == CS_TEAM_T) {
      
set_camera(iforcechasecam,  iPlayerLastT)
      } else

      if(
cs_get_user_team(i) == CS_TEAM_T) {
      
set_camera(iforcechasecam,  iPlayerLastCT)
      } else

      if(
cs_get_user_team(i) == CS_TEAM_SPECTATOR) {
      
set_camera(iforcechasecamrandom[iPlayerLastCTiPlayerLastT])
      }
   }


something like this..

alonelive 01-05-2013 06:07

Re: Set players view
 
First question i solve.
Help me with c4 code please (q. № 2)

bibu 01-05-2013 06:23

Re: Set players view
 
You can show how you have resolved it, so others can also see it.
I will try todo something with the c4 and will post later.

bibu 01-05-2013 07:56

Re: Set players view
 
Alright I tried todo something. It will for sure give you the idea what I have done or make it better since I just used natives from all modules. Not that it is bad, just use the right natives and it is fine.

In that code I basically removed the c4 drop from a player and c4 drop by dieing. It creates an entity with the c4 model and hooks the touch and gives the c4 to that player.

Keep in mind, that I have added a code that the owner of the last thrower of the c4 can't pickup it anymore, since he would pick it right up if he drops it.

PHP Code:

#include <amxmodx>
#include <engine>
#include <cstrike>
#include <fun>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN "C4 Drop"
#define VERSION "1.0"
#define AUTHOR "AMXX Community"

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
RegisterHam(Ham_Killed"player""Ham_CBasePlayer_Killed_Pre"0)
    
    
register_touch("weapon_c4_custom""player""TouchBomb")
    
    
register_clcmd("drop""DropBomb")
}

public 
Ham_CBasePlayer_Killed_Pre(iVictim)
{
    if(
user_has_weapon(iVictimCSW_C4))
    {
        new 
Float:origin[3]
        
pev(iVictim,pev_origin,origin)
        
        
ham_strip_c4(iVictim"weapon_c4")
        
create_c4(iVictimorigin)
    }
}

public 
DropBomb(id)
{
    if(
is_user_alive(id) && get_user_weapon(id) == CSW_C4)
    {
        new 
Float:iOrigin[3]
        
pev(idpev_originiOrigin)
        
        
ham_strip_c4(id"weapon_c4")
        
create_c4(idiOrigin)
        
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE
}

create_c4(idFloat:iOrigin[3])
{
    new 
C4 create_entity("func_wall")
    
    
entity_set_string(C4EV_SZ_classname"weapon_c4_custom")
    
entity_set_model(C4"models/w_backpack.mdl")
    
entity_set_int(C4EV_INT_solidSOLID_TRIGGER)
    
entity_set_size(C4Float:{-2.0,-2.0,-2.0}, Float:{2.0,2.0,2.0})
    
entity_set_edict(C4EV_ENT_ownerid)
    
    
entity_set_origin(C4iOrigin)
    
    
drop_to_floor(C4)
}

public 
TouchBomb(C4id)
{
    new 
owner entity_get_edict(C4EV_ENT_owner)
    
    if(
owner == id)
        return
   
    
give_item(id"weapon_c4")
    
remove_entity(C4)
}

ham_strip_c4(id,weapon[])
{
    new 
wId get_weaponid(weapon);
    if(!
wId) return 0;

    new 
wEnt;
    while((
wEnt engfunc(EngFunc_FindEntityByString,wEnt,"classname",weapon)) && pev(wEnt,pev_owner) != id) {}
    if(!
wEnt) return 0;

    if(
get_user_weapon(id) == wIdExecuteHamB(Ham_Weapon_RetireWeapon,wEnt);

    if(!
ExecuteHamB(Ham_RemovePlayerItem,id,wEnt)) return 0;
    
ExecuteHamB(Ham_Item_Kill,wEnt);

    
set_pev(id,pev_weapons,pev(id,pev_weapons) & ~(1<<wId));

    
cs_set_user_plant(id,0,0);
    
cs_set_user_bpammo(id,CSW_C4,0);
    
    return 
1;



meTaLiCroSS 01-05-2013 11:58

Re: Set players view
 
PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
//#include <cstrike>

// "weaponbox"
const XO_CWEAPONBOX 4
const m_rgpWeaponBoxItems_Slot0 34

const PDATA_SAFE 2

public plugin_init() 
{
    
register_plugin("Drop C4 perpendicular to floor""0.1""meTaLiCroSS")
    
    
register_forward(FM_SetModel"fw_SetModel")
}

public 
fw_SetModel(iEntId, const szModel[])
{
    if(
pev_valid(iEntId) != PDATA_SAFE)
        return;
        
    new 
szClassName[32]
    
pev(iEntIdpev_classnameszClassNamecharsmax(szClassName))
    
    if(
equal(szClassName"weaponbox"))
    {
        new 
iWeaponEntId get_pdata_cbase(iEntIdm_rgpWeaponBoxItems_Slot0 5XO_CWEAPONBOX)
        
        if(
pev_valid(iWeaponEntId/* == 2 && cs_get_weapon_id(iWeaponEntId) == CSW_C4 */// no need to check pvPrivateData because we are just going to modify an entvar
            
set_pev(iEntIdpev_velocityFloat:{ 0.00.0, -2.0 })
    } 
}

// cstrike commented because the C4 is the unique weapon which uses the 5th slot 

Try that one.

alonelive 01-05-2013 12:28

Re: Set players view
 
1 Attachment(s)
Quote:

Originally Posted by bibu (Post 1867424)
You can show how you have resolved it, so others can also see it.
I will try todo something with the c4 and will post later.

Of course :) This is a very simple way(without fakemeta, set_camera, etc):


PHP Code:

server_cmd("mp_forcechasecam 1"//(dead CT can view ONLY alive CT, dead T - only alive T. No need to search users in CS_TEAM_T, CS_TEAM_CT, etc)
client_cmd(0"spec_mode 2")  // all dead \ spec players switch their modes to Free Chase Cam 

about c4:
bibu: thank you for work, but bomb falls so far (see screenshot);
meTaLiCroSS: thank you too, works fine.

bibu 01-05-2013 15:29

Re: Set players view
 
My code should work fine, I tested it. But just use metalicross' version, since it is much more better.

alonelive 01-06-2013 03:52

Re: Set players view
 
Quote:

Originally Posted by bibu (Post 1867704)
My code should work fine, I tested it. But just use metalicross' version, since it is much more better.

Your code is also useful to me, but for other project (in future) :)) Thnk


All times are GMT -4. The time now is 13:40.

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