problem spawing smoke grenade and he grenade

Please post any questions about developing your plugin here. Please use the search function before posting!
8guawong
Senior Member
Posts: 148
Joined: Sat Sep 20, 2014 3:06 am

problem spawing smoke grenade and he grenade

Postby 8guawong » Sun Oct 26, 2014 12:11 am

Syntax: Select all

def give_sg(player):
index = server_tools.create_entity('weapon_smokegrenade')
edict_from_index(index).set_key_value_vector('origin', player.m_vecOrigin)
server_tools.spawn_entity(index)

def give_he(player):
index = server_tools.create_entity('weapon_hegrenade')
edict_from_index(index).set_key_value_vector('origin', player.m_vecOrigin)
server_tools.spawn_entity(index)
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Sun Oct 26, 2014 12:32 am

That doesn't really explain the "problem". What is/isn't happening?

*Edit: also, what game is this for?
Image
8guawong
Senior Member
Posts: 148
Joined: Sat Sep 20, 2014 3:06 am

Postby 8guawong » Sun Oct 26, 2014 12:48 am

its not giving/spawing the items

this is for csgo
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Sun Oct 26, 2014 12:55 am

Is "player" a PlayerEntity instance? If so, try the following:

Syntax: Select all

def give_sg(player):
index = server_tools.create_entity('weapon_smokegrenade')
edict_from_index(index).set_key_value_vector(
'origin', player.get_key_value_vector('origin'))
server_tools.spawn_entity(index)

def give_he(player):
index = server_tools.create_entity('weapon_hegrenade')
edict_from_index(index).set_key_value_vector(
'origin', player.get_key_value_vector('origin'))
server_tools.spawn_entity(index)
Image
8guawong
Senior Member
Posts: 148
Joined: Sat Sep 20, 2014 3:06 am

Postby 8guawong » Sun Oct 26, 2014 6:32 am

satoon101 wrote:Is "player" a PlayerEntity instance? If so, try the following:

Syntax: Select all

def give_sg(player):
index = server_tools.create_entity('weapon_smokegrenade')
edict_from_index(index).set_key_value_vector(
'origin', player.get_key_value_vector('origin'))
server_tools.spawn_entity(index)

def give_he(player):
index = server_tools.create_entity('weapon_hegrenade')
edict_from_index(index).set_key_value_vector(
'origin', player.get_key_value_vector('origin'))
server_tools.spawn_entity(index)


yes playerentity

example frome here
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Sun Oct 26, 2014 7:16 am

Since you are not giving your complete code (like everytime you ask for help), I will assume it is complete and answer you that's normal if you are not getting them since those functions are never called.
8guawong
Senior Member
Posts: 148
Joined: Sat Sep 20, 2014 3:06 am

Postby 8guawong » Sun Oct 26, 2014 10:57 pm

L'In20Cible wrote:Since you are not giving your complete code (like everytime you ask for help), I will assume it is complete and answer you that's normal if you are not getting them since those functions are never called.


heres the full code

Syntax: Select all

from events import Event
from players.entity import PlayerEntity
from players.helpers import index_from_userid
from messages import SayText2
from weapons.manager import weapon_manager
from tools import server_tools
from entities.helpers import edict_from_index
from entities.entity import BaseEntity
from entities.helpers import pointer_from_index
from engines.server import engine_server

@Event
def player_jump(game_event):
index = index_from_userid(game_event.get_int('userid'))
player = PlayerEntity(index)
give_sg(player)
give_he(player)
give_ak(player)

def give_ak(player):
index = server_tools.create_entity('weapon_ak47')
edict_from_index(index).set_key_value_vector('orig in', player.m_vecOrigin)
server_tools.spawn_entity(index)

def give_sg(player):
index = server_tools.create_entity('weapon_smokegrenade')
edict_from_index(index).set_key_value_vector('orig in', player.m_vecOrigin)
server_tools.spawn_entity(index)

def give_he(player):
index = server_tools.create_entity('weapon_hegrenade')
edict_from_index(index).set_key_value_vector('orig in', player.m_vecOrigin)
server_tools.spawn_entity(index)


its spawning smoke grenade now........ but not he grenade............
here is a video of it in action
some very weird behavior



around 20 sec i throw my sg then i pick up all up the sg on the ground but it does not show up in my inventory to the right and i can't switch to it either @@

after testing some more it seems like you to have drop the original ak that was spawned before it'll start spawning smokegrenade and for it to show up in your inventory

kinda like the c4 problem i posted here

some more testing showed i need to buy a HE first before it'll spawn HE ... but it'll sometimes spawn HE by itself or both HE or SG ............ so weird !?
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Sun Oct 26, 2014 11:23 pm

If you drop your ak and jump again, you will get another ak and a smoke. If you move the hegrenade above the smoke, it will give you the hegrenade instead of the smoke. This is why we really need to figure out how to actually use GiveNamedItem in CS:GO.

As I have stated previously, there is a new argument in CS:GO's GiveNamedItem that we need to figure out how to utilize:

Code: Select all

CBasePlayer::GiveNamedItem(char const*,int,CEconItemView *,bool)
CCSPlayer::GiveNamedItem(char const*,int,CEconItemView *,bool)


I'm also not sure what the boolean value is for, but at least we have the ability to pass that already. The CEconItemView class is what we need to get access to. Once we have that, we can easily create a give_weapon method for PlayerEntity based on the engine/game the server is running.
Image
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Mon Oct 27, 2014 11:10 am

Alright so, I made further testing and yes, something is missing. If I give myself, for example, a weapon_awp entity using the code snippet above, I get an awp: right. But if I attempt to use it, there is no recoil, no sound, nothing. If I drop it, the game says I'm dropping a knife. There is surely some info we need to set manually which parse out a mapping where the first item is the knife. I also made some testing about CCSPlayer::GiveNamedItem. I hooked this function and compared values when the game is automatically giving you a weapon (such as when you respawn), when using the cheat command "give" and then when using the "buy" command. The integer and the bool values are always 0 and False respectively. The CEconItemView is always a NULL pointer except when using the "buy" command. I will make more tests comparing memory and data to see what need to be set...

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 24 guests