Raised This Month: $ Target: $400
 0% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Teamkiller324
Senior Member
Join Date: Feb 2014
Location: Earth
Old 03-05-2021 , 20:58   [CSGO] Is it possible to spawn a proper weapon with CreateEntityByName.
Reply With Quote #1

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);

__________________

Last edited by Teamkiller324; 03-05-2021 at 22:38. Reason: yes
Teamkiller324 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-06-2021 , 04:03   Re: [CSGO] Is it possible to spawn a proper weapon with CreateEntityByName.
Reply With Quote #2

:/
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 );

... 

Last edited by Bacardi; 03-06-2021 at 04:04.
Bacardi is offline
Teamkiller324
Senior Member
Join Date: Feb 2014
Location: Earth
Old 03-06-2021 , 07:02   Re: [CSGO] Is it possible to spawn a proper weapon with CreateEntityByName.
Reply With Quote #3

Quote:
Originally Posted by Bacardi View Post
:/
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
__________________

Last edited by Teamkiller324; 03-06-2021 at 07:03.
Teamkiller324 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-06-2021 , 07:57   Re: [CSGO] Is it possible to spawn a proper weapon with CreateEntityByName.
Reply With Quote #4

Your welcome ��
__________________
Do not Private Message @me
Bacardi is offline
Reply


Thread Tools
Display Modes

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 02:03.


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