Raised This Month: $ Target: $400
 0% 

[Alien Swarm] Finding current equipped weapon name


Post New Thread Reply   
 
Thread Tools Display Modes
comp_noob
Senior Member
Join Date: Nov 2010
Old 12-02-2010 , 21:46   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #31

hi, thanks for your new functions, can i ask you a question? the function Swarm_EquipMarineWeapon(marine, weapon), what do you mean by weapon? is it the classname of the weapon or?

1st error:
PHP Code:
L 12/03/2010 10:40:45: [SMNative "CloseHandle" reportedHandle 0 is invalid (error 4)
L 12/03/2010 10:40:45: [SMDisplaying call stack trace for plugin "swarmtools.smx":
L 12/03/2010 10:40:45: [SM]   [0]  Line 94swarmtools.sp::OnPluginStart() 
this results in the plugin being paused, and the other functions all unable to be used...

EDIT: i know what's the problem, it's something to do with the hGameConfig, i've edited the error part, uploaded it, here it is:
Attached Files
File Type: smx swarmtools.smx (7.1 KB, 65 views)
File Type: sp Get Plugin or Get Source (swarmtools.sp - 159 views - 9.1 KB)

Last edited by comp_noob; 12-02-2010 at 21:58.
comp_noob is offline
psychonic

BAFFLED
Join Date: May 2008
Old 12-02-2010 , 22:10   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #32

Quote:
Originally Posted by comp_noob View Post
PHP Code:
L 12/03/2010 10:40:45: [SMNative "CloseHandle" reportedHandle 0 is invalid (error 4)
L 12/03/2010 10:40:45: [SMDisplaying call stack trace for plugin "swarmtools.smx":
L 12/03/2010 10:40:45: [SM]   [0]  Line 94swarmtools.sp::OnPluginStart() 
This has been fixed in the 1.2.1 version.

Quote:
Originally Posted by comp_noob View Post
hi, thanks for your new functions, can i ask you a question? the function Swarm_EquipMarineWeapon(marine, weapon), what do you mean by weapon? is it the classname of the weapon or?
It's the entity of a weapon. You would have to create the weapon first with CreateEntityByName for example.
psychonic is offline
comp_noob
Senior Member
Join Date: Nov 2010
Old 12-02-2010 , 22:33   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #33

Quote:
Originally Posted by psychonic View Post
This has been fixed in the 1.2.1 version.


It's the entity of a weapon. You would have to create the weapon first with CreateEntityByName for example.
erm straight away after CreateEntityByName, you call that function or you need to spawn it first? i tried giving a weapon to a marine after spawning the item, the game crashed... o.O
comp_noob is offline
psychonic

BAFFLED
Join Date: May 2008
Old 12-02-2010 , 22:39   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #34

Quote:
Originally Posted by comp_noob View Post
erm straight away after CreateEntityByName, you call that function or you need to spawn it first? i tried giving a weapon to a marine after spawning the item, the game crashed... o.O
I don't know. I'll look into it later. The entity probably just needs some setup after creating it, before spawn. (setting the model, etc.)
psychonic is offline
comp_noob
Senior Member
Join Date: Nov 2010
Old 12-02-2010 , 22:46   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #35

Quote:
Originally Posted by psychonic View Post
I don't know. I'll look into it later. The entity probably just needs some setup after creating it, before spawn. (setting the model, etc.)
i created a function to spawn the identity at the origin of the marine, no problem, but when i use ur function, it crashed the game right away... here's my code...
PHP Code:
public Action:Spawn_Entity(clientargs)
{
    if (
args || args 2)
    {
        
ReplyToCommand(client"[SM] spawn <playerid> <entity classname> - Spawn <entity classname> at <playerid>'s marine origin.");
        return 
Plugin_Handled;
    }
    else
    {
        
decl String:argstring1[5], String:argstring2[30], clientidmarineidweapon;
        
GetCmdArg(1argstring1sizeof(argstring1));
        
GetCmdArg(2argstring2sizeof(argstring2));
        
clientid StringToInt(argstring1);
        if (
clientid || clientid MaxClients)
        {
            
ReplyToCommand(client"[SM] Player index is out of valid range.");
            return 
Plugin_Handled;
        }
        
weapon CreateEntityByName(argstring2);
        if(
IsValidEntity(weapon))
        {        
            
DispatchSpawn(weapon); //Spawn weapon (entity)
            
marineid Swarm_GetMarine(clientid);
            
decl Float:position[3];
            
GetEntPropVector(marineidProp_Send"m_vecOrigin"position);
            
TeleportEntity(weaponpositionNULL_VECTORNULL_VECTOR);
            if (
client == 0)
            {
                
ReplyToCommand(client"Spawned %s and teleported to %N's position."argstring2clientid);
                return 
Plugin_Handled;
            }
            
PrintToChat(client"Spawned %s and teleported to %N's position."argstring2clientid);
            return 
Plugin_Handled;
        }
        else
        {
            if (
client == 0)
            {
                
ReplyToCommand(client"Invalid weapon classname entered.");
                return 
Plugin_Handled;
            }
            
PrintToChat(client"Invalid weapon classname entered.");
        }
        return 
Plugin_Handled;
    }

and also, is there any way to respawn a marine? it will be very good if one can respawn a marine that is killed in action...

EDIT 2: error on your Swarm_MarineForceSuicide function...
PHP Code:
killmarine 1
L 12
/03/2010 12:04:00: [SMNative "Swarm_ForceMarineSuicide" reportedSuicide function not found
L 12
/03/2010 12:04:00: [SMDisplaying call stack trace for plugin "ready.smx":
L 12/03/2010 12:04:00: [SM]   [0]  Line 58ready.sp::Kill_Player_Marine() 
here's my code:
PHP Code:
public Action:Kill_Player_Marine(clientargs)
{
    if (
args || args 1)
    {
        
ReplyToCommand(client"[SM] killmarine <playerid> - Slays <playerid>'s marine.");
        return 
Plugin_Handled;
    }
    else
    {
        
decl String:argstring1[5], clientidmarineid;
        
GetCmdArg(1argstring1sizeof(argstring1));
        
clientid StringToInt(argstring1);
        if (
clientid || clientid MaxClients)
        {
            
ReplyToCommand(client"[SM] Player index is out of valid range.");
            return 
Plugin_Handled;
        }
        
marineid Swarm_GetMarine(clientid);
        
Swarm_ForceMarineSuicide(marineid);
        if (
client == 0)
        {
            
ReplyToCommand(client"Slayed %N's marine."clientid);
            return 
Plugin_Handled;
        }
        
PrintToChat(client"Slayed %N's marine."clientid);
        return 
Plugin_Handled;
    }


Last edited by comp_noob; 12-02-2010 at 23:06.
comp_noob is offline
psychonic

BAFFLED
Join Date: May 2008
Old 12-02-2010 , 23:45   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #36

There was a typo in the equip (and drop) natives. It was trying to equip/drop the player to/from the player, rather than the weapon to/from the player. Fixed in 1.2.2.
psychonic is offline
comp_noob
Senior Member
Join Date: Nov 2010
Old 12-02-2010 , 23:46   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #37

Quote:
Originally Posted by psychonic View Post
You'll probably just have to get by with commands for now. I don't currently have time to work on it.



There may be some event you can hook for marines existing and being destroyed; I haven't looked much at the events yet.

Regardless, you should be checking that the return of Swarm_GetMarine isn't -1. Per the docs, "Marine entity index or -1 for none or not found".

On a side note, I have posted the SwarmTools plugin in the New Plugins section and also added even more natives to give marine versions of client-only functions in sdktools, such as slap, slay, eye angles, equip weapon, drop weapon. I also added functions for triggering and curing infestation.
hi, it's not possible to check if Swarm_GetMarine is equal to -1 or not, because in your swarmtools.smx, the part:
PHP Code:
new marineResource GetEntDataEnt2(g_GameResourceEntg_MarineResourceOffset + (i*4)); 
the GetEntDataEnt2 is returning g_GameResourceEnt is equals to -1, so the whole function Swarm_GetMarine is not fully processed and it will not be able to return a value...
is it possible to add a check to see if the g_GameResourceEnt is -1 or not to ur swarmtools.smx? so that when it's -1 the functions will return -1 instead of spewing errors...

Last edited by comp_noob; 12-02-2010 at 23:59.
comp_noob is offline
psychonic

BAFFLED
Join Date: May 2008
Old 12-03-2010 , 00:07   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #38

Quote:
Originally Posted by comp_noob View Post
hi, it's not possible to check if Swarm_GetMarine is equal to -1 or not, because in your swarmtools.smx, the part:
PHP Code:
new marineResource GetEntDataEnt2(g_GameResourceEntg_MarineResourceOffset + (i*4)); 
the GetEntDataEnt2 is returning g_GameResourceEnt is equals to -1, so the whole function Swarm_GetMarine is not fully processed and it will not be able to return a value...
is it possible to add a check to see if the g_GameResourceEnt is -1 or not to ur swarmtools.smx? so that when it's -1 the functions will return -1 instead of spewing errors...
I see what you're saying now. I added a new native, bool:Swarm_IsGameActive(), but realistically, you shouldn't have an issue if you don't make calls after OnMapEnd or before OnMapStart.
psychonic is offline
comp_noob
Senior Member
Join Date: Nov 2010
Old 12-03-2010 , 00:39   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #39

thanks but there's an error again... this error happens when i complete one mission and it goes on to the other... resulting in the whole of your plugin paused...
PHP Code:

L 12
/03/2010 13:36:39: [SMNative "FindEntityByClassname" reportedEntity 2 is not valid
L 12
/03/2010 13:36:39: [SMDisplaying call stack trace for plugin "swarmtools.smx":
L 12/03/2010 13:36:39: [SM]   [0]  Line 111swarmtools.sp::GetGameResource()
L 12/03/2010 13:36:39: [SM]   [1]  Line 100swarmtools.sp::OnMapStart() 
to be exact, i completed a mission when playing offline training, after that, when i create an online game, with only myself (1 player only) using the command asw_ignore_need_two_player_requirement...

Last edited by comp_noob; 12-03-2010 at 00:53.
comp_noob is offline
psychonic

BAFFLED
Join Date: May 2008
Old 12-03-2010 , 00:57   Re: [Alien Swarm] Finding current equipped weapon name
Reply With Quote #40

Quote:
Originally Posted by comp_noob View Post
thanks but there's an error again... this error happens when i complete one mission and it goes on to the other... resulting in the whole of your plugin paused...
PHP Code:

L 12
/03/2010 13:36:39: [SMNative "FindEntityByClassname" reportedEntity 2 is not valid
L 12
/03/2010 13:36:39: [SMDisplaying call stack trace for plugin "swarmtools.smx":
L 12/03/2010 13:36:39: [SM]   [0]  Line 111swarmtools.sp::GetGameResource()
L 12/03/2010 13:36:39: [SM]   [1]  Line 100swarmtools.sp::OnMapStart() 
to be exact, i completed a mission when playing offline training, after that, when i create an online game, with only myself (1 player only) using the command asw_ignore_need_two_player_requirement...
This should be fixed in 1.2.4.
psychonic is offline
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 21:05.


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