AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   [CSGO] Is it possible to spawn a proper weapon with CreateEntityByName. (https://forums.alliedmods.net/showthread.php?t=331089)

Teamkiller324 03-05-2021 20:58

[CSGO] Is it possible to spawn a proper weapon with CreateEntityByName.
 
I'm wondering if it's possible to spawn a proper "weapon" via CreateEntityName and EquipPlayerWeapon since if you just create weapon as an entity and give it to yourself, it is buggy (no reload animation) and is solid once stepping into it.

Something i've tested:
PHP Code:


#include        <tk>

#pragma        semicolon    1
#pragma        newdecls    required

public void OnPluginStart()    {
    
RegAdminCmd("sm_test"GiveWeaponADMFLAG_ROOT"Testing");
}


Action GiveWeapon(int clientint args)    {
    
int weapon CreateEntityByName("weapon_ak47");
    
    
SetWeaponAmmoEx(weapon3090);
    
    
EquipPlayerWeapon(weapon);



Bacardi 03-06-2021 04:03

Re: [CSGO] Is it possible to spawn a proper weapon with CreateEntityByName.
 
:/
PHP Code:

...

    
int entity CreateEntityByName("weapon_ak47");

    
float origin[3];
    
GetClientAbsOrigin(clientorigin);
    
origin[2] += 100.0;

    
TeleportEntity(entityoriginNULL_VECTORNULL_VECTOR);
    
SetEntPropVector(entityProp_Send"m_vecOrigin"origin);

    
int SF_NORESPAWN =    ( << 30 ); // !!!set this bit on guns and stuff that should never respawn.
    
int flags GetEntProp(entityProp_Data"m_spawnflags");
    
flags |= SF_NORESPAWN;

    
SetEntProp(entityProp_Data"m_spawnflags"flags);

    
DispatchSpawn(entity);
    
    
// Touch( client );

... 


Teamkiller324 03-06-2021 07:02

Re: [CSGO] Is it possible to spawn a proper weapon with CreateEntityByName.
 
Quote:

Originally Posted by Bacardi (Post 2739447)
:/
PHP Code:

...

    
int entity CreateEntityByName("weapon_ak47");

    
float origin[3];
    
GetClientAbsOrigin(clientorigin);
    
origin[2] += 100.0;

    
TeleportEntity(entityoriginNULL_VECTORNULL_VECTOR);
    
SetEntPropVector(entityProp_Send"m_vecOrigin"origin);

    
int SF_NORESPAWN =    ( << 30 ); // !!!set this bit on guns and stuff that should never respawn.
    
int flags GetEntProp(entityProp_Data"m_spawnflags");
    
flags |= SF_NORESPAWN;

    
SetEntProp(entityProp_Data"m_spawnflags"flags);

    
DispatchSpawn(entity);
    
    
// Touch( client );

... 


Seems like Dispatchspawn together with teleporting entity to the client fixes the issue with EquipPlayerWeapon since i guess that sends the entity to the client too early i think which causes the weapon to have 0 ammo and have glitchy reload animations and solid when interacted with. Thanks mate :D

Bacardi 03-06-2021 07:57

Re: [CSGO] Is it possible to spawn a proper weapon with CreateEntityByName.
 
Your welcome ��


All times are GMT -4. The time now is 04:06.

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