Raised This Month: $51 Target: $400
 12% 

Orientation Fix.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
[email protected]
Junior Member
Join Date: Aug 2013
Old 08-12-2013 , 02:04   Orientation Fix.
Reply With Quote #1

Ok, so I have very, very basic knowledge of how to code stuff for sourcemod, but I have tried my best. Now it seems like I am unable to find things on google, and my other helpthread are dead aswell.

Therefore I am giving away 5$ PayPal to the first person who offers 10 minutes to make this code.

To see what I want, see my other thread here.

Here are some of the code I tried, but failed:

PHP Code:
public OnEntityCreated(entity, const String:classname[])
{
    if (
StrEqual(classname"func_tanktrain"))
    {
        
SDKHook(entitySDKHook_SpawnPostSpawnTrain);
    }
}

public 
SpawnTrain(entity)
{
    
DispatchKeyValue(entity"orientationtype""0");

Creds to Powerlord for this code.

I also remember I got this code working, but now, however it doesn't work. (don't know what happened here...)
PHP Code:
public OnPluginStart() 

    new 
ent = -1
    while ((
ent FindEntityByClassname(ent"func_tanktrain")) != -1
    { 
        new 
String:classname[32]; 
        
GetEdictClassname(entclassname32); 
        
DispatchKeyValue(ent"orientationtype""0"); 
    }     

Thanks to Doodil for making that code.

Thanks in advance, I know it isn't much money, but it really doesn't take much to make it for someone who have experience in coding.
Thanks.
aMasheep@gmail.com is offline
[email protected]
Junior Member
Join Date: Aug 2013
Old 08-12-2013 , 19:13   Re: Orientation Fix.
Reply With Quote #2

I am willing to go a little higher if someone can do this for me, thanks
aMasheep@gmail.com is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 08-12-2013 , 20:03   Re: Orientation Fix.
Reply With Quote #3

PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdkhooks>
#include <sdktools>

new bool:g_bLateLoad;

public 
APLRes:AskPluginLoad2(Handle:myselfbool:lateString:error[], err_max)
{
    
g_bLateLoad late;

    return 
APLRes_Success;
}

public 
OnConfigsExecuted()
{
    if(
g_bLateLoad)
    {
        
decl String:sClassname[32];
        for(new 
MaxClients<= 2047i++)
        {
            if(
IsValidEntity(i) && IsValidEdict(i))
            {
                
GetEntityClassname(isClassnamesizeof(sClassname));
                if(
StrEqual(sClassname"func_tanktrain") || StrEqual(sClassname"path_track"))
                {
                    new 
iState GetEntProp(iProp_Data"m_eOrientationType");
                    
PrintToChatAll("%s %d OnConfigsExecuted with orientationtype %d"sClassnameiiState);
                    
LogError("%s %d OnConfigsExecuted with orientationtype %d"sClassnameiiState);
                    if(
iState)
                    {
                        
SetEntProp(iProp_Data"m_eOrientationType"0);
                        
CreateTimer(2.0Timer_CheckEntIndexToEntRef(i), TIMER_FLAG_NO_MAPCHANGE);
                    }
                }
            }
        }
        
g_bLateLoad false;
    }
}

public 
OnEntityCreated(entity, const String:classname[])
{
    if (
StrEqual(classname"func_tanktrain") || StrEqual(classname"path_track"))
    {
        
SDKHook(entitySDKHook_SpawnPostOnSpawnPost);
    }
}

public 
OnSpawnPost(entity)
{
    
decl String:sClassname[32];
    
GetEntityClassname(entitysClassnamesizeof(sClassname));
    new 
iState GetEntProp(entityProp_Data"m_eOrientationType");
    
PrintToChatAll("%s %d SpawnPost with orientationtype %d",  sClassnameentityiState);
    
LogError("%s %d SpawnPost with orientationtype %d"sClassnameentityiState);
    if(
iState)
    {
        
SetEntProp(entityProp_Data"m_eOrientationType"0);
        
CreateTimer(2.0Timer_CheckEntIndexToEntRef(entity), TIMER_FLAG_NO_MAPCHANGE);
    }
}

public 
Action:Timer_Check(Handle:hTimerany:ref)
{
    new 
entity EntRefToEntIndex(ref);
    if(
entity != INVALID_ENT_REFERENCE)
    {
        
decl String:sClassname[32];
        
GetEntityClassname(entitysClassnamesizeof(sClassname));
        new 
iState GetEntProp(entityProp_Data"m_eOrientationType");
        
PrintToChatAll("%s %d Timer_Check with orientationtype %d",  sClassnameentityiState);
        
LogError("%s %d Timer_Check with orientationtype %d"sClassnameentityiState);
    }

Tested on CS:S map mg_ka_trains.
PHP Code:
L 08/12/2013 19:03:01: [orientation.smxpath_track 43 SpawnPost with orientationtype 1
L 08
/12/2013 19:03:01: [orientation.smxpath_track 44 SpawnPost with orientationtype 1
L 08
/12/2013 19:03:01: [orientation.smxpath_track 46 SpawnPost with orientationtype 1
L 08
/12/2013 19:03:01: [orientation.smxpath_track 48 SpawnPost with orientationtype 1
L 08
/12/2013 19:03:01: [orientation.smxpath_track 57 SpawnPost with orientationtype 1
L 08
/12/2013 19:03:01: [orientation.smxfunc_tanktrain 58 SpawnPost with orientationtype 1
L 08
/12/2013 19:03:01: [orientation.smxpath_track 59 SpawnPost with orientationtype 1
L 08
/12/2013 19:03:01: [orientation.smxpath_track 60 SpawnPost with orientationtype 1
L 08
/12/2013 19:03:01: [orientation.smxpath_track 61 SpawnPost with orientationtype 1
L 08
/12/2013 19:03:01: [orientation.smxpath_track 71 SpawnPost with orientationtype 1
L 08
/12/2013 19:03:01: [orientation.smxpath_track 72 SpawnPost with orientationtype 1
L 08
/12/2013 19:03:01: [orientation.smxpath_track 73 SpawnPost with orientationtype 1
L 08
/12/2013 19:03:03: [orientation.smxpath_track 73 Timer_Check with orientationtype 0
L 08
/12/2013 19:03:03: [orientation.smxpath_track 72 Timer_Check with orientationtype 0
L 08
/12/2013 19:03:03: [orientation.smxpath_track 71 Timer_Check with orientationtype 0
L 08
/12/2013 19:03:03: [orientation.smxpath_track 61 Timer_Check with orientationtype 0
L 08
/12/2013 19:03:03: [orientation.smxpath_track 60 Timer_Check with orientationtype 0
L 08
/12/2013 19:03:03: [orientation.smxpath_track 59 Timer_Check with orientationtype 0
L 08
/12/2013 19:03:03: [orientation.smxfunc_tanktrain 58 Timer_Check with orientationtype 0
L 08
/12/2013 19:03:03: [orientation.smxpath_track 57 Timer_Check with orientationtype 0
L 08
/12/2013 19:03:03: [orientation.smxpath_track 48 Timer_Check with orientationtype 0
L 08
/12/2013 19:03:03: [orientation.smxpath_track 46 Timer_Check with orientationtype 0
L 08
/12/2013 19:03:03: [orientation.smxpath_track 44 Timer_Check with orientationtype 0
L 08
/12/2013 19:03:03: [orientation.smxpath_track 43 Timer_Check with orientationtype 0 
You can compile it here: http://spider.limetech.org/
__________________

Last edited by thetwistedpanda; 08-12-2013 at 20:19.
thetwistedpanda is offline
[email protected]
Junior Member
Join Date: Aug 2013
Old 08-14-2013 , 13:18   Re: Orientation Fix.
Reply With Quote #4

Thanks mate, that works very good. But on some maps, at least maps who I have tested with, have decompile protection. I don't know what this have to say for the plugin, but it does not work on those maps.

It does work on some maps, but it does not work on other maps... Here are two maps where it is not currently working:
http://css.gamebanana.com/maps/167702 (decompile protected)
http://css.gamebanana.com/maps/163079 (No issue decompiling this one, but it still don't work.)

(Btw, it says in chat it fixed all both path_tracks and func_tanktrains to orientationtype 0, even on the maps the plugin didn't work on.)

Thanks a lot for spending time on this! I really appreciate it.
aMasheep@gmail.com is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 08-14-2013 , 13:24   Re: Orientation Fix.
Reply With Quote #5

Decompile protection? Don't use VMEX. http://ata4.info/bspsrc/downloads.html, or load the map and dump the entities with Stripper: Source. That being said, orientationtype isn't the only thing that causes directions to reverse if memory serves. You'll want to compare the spawnflags of the entities that don't work with the entities that do. A quick glance shows all of the entities not working as desired spawn with spawnflags of 144, but of the two maps I checked, both had different spawnflags ~ 538.
__________________

Last edited by thetwistedpanda; 08-14-2013 at 13:37.
thetwistedpanda is offline
[email protected]
Junior Member
Join Date: Aug 2013
Old 08-14-2013 , 14:05   Re: Orientation Fix.
Reply With Quote #6

So if we set the same spawn flags for all the func_tanktrains as well, it will work no matter if its decompile protected? (BTW, thanks for the tip on VMEX)
aMasheep@gmail.com is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 08-14-2013 , 14:08   Re: Orientation Fix.
Reply With Quote #7

decompile protection is just a material that prevents the decompiler from working, it has no bearing on the entities within it. The spawn flags appear to have an influence on those entities so removing the undesired ones would be the next step.
__________________
thetwistedpanda is offline
[email protected]
Junior Member
Join Date: Aug 2013
Old 08-14-2013 , 14:51   Re: Orientation Fix.
Reply With Quote #8

By moving the undesired ones, do you mean change the flags so it is correct? If that is possible? So its the same entity with just different flags? Just like you changed some of the index values of all entities?
Sorry for late response, I'll try to refresh the page more often) :p
aMasheep@gmail.com is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 08-14-2013 , 14:58   Re: Orientation Fix.
Reply With Quote #9

You'd take the current spawnflags, remove the ones that seem to be causing the errors (likely take some trial and error on your part) and then set the entity's spawnflags back.

https://developer.valvesoftware.com/wiki/Func_tanktrain lists
PHP Code:
No Pitch (X-rot)
No User Control
Passable
16 
Fixed Orientation
128 
HL1 Train
256 
: Use max speed for pitch shifting move sound
512 
Is unblockable by player 
as valid spawn flags. So you'd start by removing some of them and seeing if it fixes the rotation issue.
__________________
thetwistedpanda is offline
[email protected]
Junior Member
Join Date: Aug 2013
Old 08-14-2013 , 17:47   Re: Orientation Fix.
Reply With Quote #10

Thanks, I did not quite understand how I would use those flags, but I tested some stuff.
I just copypasted the SetEntProp and changed it to m_SpawnFlags", 16 (for fixed orientation?) in both places where EntityProperties are set. here are the code:
PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdkhooks>
#include <sdktools>

new bool:g_bLateLoad;

public 
APLRes:AskPluginLoad2(Handle:myselfbool:lateString:error[], err_max)
{
    
g_bLateLoad late;

    return 
APLRes_Success;
}

public 
OnConfigsExecuted()
{
    if(
g_bLateLoad)
    {
        
decl String:sClassname[32];
        for(new 
MaxClients<= 2047i++)
        {
            if(
IsValidEntity(i) && IsValidEdict(i))
            {
                
GetEntityClassname(isClassnamesizeof(sClassname));
                if(
StrEqual(sClassname"func_tanktrain") || StrEqual(sClassname"path_track"))
                {
                    new 
iState GetEntProp(iProp_Data"m_eOrientationType");
                    
PrintToChatAll("%s %d OnConfigsExecuted with orientationtype %d"sClassnameiiState);
                    
LogError("%s %d OnConfigsExecuted with orientationtype %d"sClassnameiiState);
                    if(
iState)
                    {
                        
SetEntProp(iProp_Data"m_eOrientationType"0);
                        
SetEntProp(iProp_Data"m_spawnflags"16);
                        
CreateTimer(2.0Timer_CheckEntIndexToEntRef(i), TIMER_FLAG_NO_MAPCHANGE);
                    }
                }
            }
        }
        
g_bLateLoad false;
    }
}

public 
OnEntityCreated(entity, const String:classname[])
{
    if (
StrEqual(classname"func_tanktrain") || StrEqual(classname"path_track"))
    {
        
SDKHook(entitySDKHook_SpawnPostOnSpawnPost);
    }
}

public 
OnSpawnPost(entity)
{
    
decl String:sClassname[32];
    
GetEntityClassname(entitysClassnamesizeof(sClassname));
    new 
iState GetEntProp(entityProp_Data"m_eOrientationType");
    
PrintToChatAll("%s %d SpawnPost with orientationtype %d",  sClassnameentityiState);
    
LogError("%s %d SpawnPost with orientationtype %d"sClassnameentityiState);
    if(
iState)
    {
        
SetEntProp(entityProp_Data"m_eOrientationType"0);
        
SetEntProp(entityProp_Data"m_SpawnFlags"16);
        
CreateTimer(2.0Timer_CheckEntIndexToEntRef(entity), TIMER_FLAG_NO_MAPCHANGE);
    }
}

public 
Action:Timer_Check(Handle:hTimerany:ref)
{
    new 
entity EntRefToEntIndex(ref);
    if(
entity != INVALID_ENT_REFERENCE)
    {
        
decl String:sClassname[32];
        
GetEntityClassname(entitysClassnamesizeof(sClassname));
        new 
iState GetEntProp(entityProp_Data"m_eOrientationType");
        
PrintToChatAll("%s %d Timer_Check with orientationtype %d",  sClassnameentityiState);
        
LogError("%s %d Timer_Check with orientationtype %d"sClassnameentityiState);
    }

I alsed tried changing the "m_SpawnFlags" to "m_spawnflags" and "m_fFlags" with no luck.

Did I get it wrong? Compile says "Warning 217: Loose indentation" on the lines I added the "SetEntProp(entity, Prop_Data, "m_SpawnFlags", 16);" and the line starting with "CreateTimer" after those. I am not really sure how to use that information to edit the flags. Did some googling and this is what I came up with. What did I do wrong?
Thanks again!!
aMasheep@gmail.com 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 01:06.


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