• What do you need help with? Version 1
    5,001 replies, posted
[QUOTE=ZeekyHBomb;21685869]Nope.[/QUOTE] :/ Well, I'm basically fucked. I can't learn without documentation, it just doesn't make sense for me ._.
It is pretty skippy, but basically you will have to learn by Valves code and the stuff you can find on their wiki.
Right, guess I'll ask something; why is a function clearly called "UploadFileAsync" in C# stopping the GUI from working until it finishes uploading? [cpp]// blah blah blah crap above snipped public partial class Form1 : Form { WebClient wcUploader = new WebClient(); public Form1() { InitializeComponent(); wcUploader.UploadFileCompleted += new UploadFileCompletedEventHandler(UploadFileCompletedCallback); wcUploader.UploadProgressChanged += new UploadProgressChangedEventHandler(UploadProgressCallback); } private void button1_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { string toUpload = openFileDialog1.FileName; wcUploader.UploadFileAsync(new Uri("http://anyhub.net/api/upload"), "POST", toUpload); } } void UploadFileCompletedCallback(object sender, UploadFileCompletedEventArgs e) { textBox1.Text = System.Text.Encoding.UTF8.GetString(e.Result); } void UploadProgressCallback(object sender, UploadProgressChangedEventArgs e) { textBox1.Text = (string)e.UserState + "\n\n" + "Uploaded " + e.BytesSent + "/" + e.TotalBytesToSend + "b (" + e.ProgressPercentage + "%)"; } }[/cpp]
[QUOTE=Chris220;21673967]There is a "Compiling under VS2008" page as well ;)[/QUOTE] Already saw that nothing useful in there
[QUOTE=ColdFusion;21688893]Already saw that nothing useful in there[/QUOTE] Worked for me :/
[QUOTE=a2h;21688751]Right, guess I'll ask something; why is a function clearly called "UploadFileAsync" in C# stopping the GUI from working until it finishes uploading?[/quote] You're doing it wrong - it shouldn't. [quote] [cpp] wcUploader.UploadFileCompleted += new UploadFileCompletedEventHandler(UploadFileCompletedCallback); wcUploader.UploadProgressChanged += new UploadProgressChangedEventHandler(UploadProgressCallback);[/cpp][/QUOTE] Quick hint: you don't need the new blahblahEventHandler() around the method group. C# will figure out what you mean without them.
[QUOTE=turb_;21689622]You're doing it wrong - it shouldn't.[/QUOTE] Yeah... figured it out after a while that it was because the file I was uploading was tiny. [i]However[/i], that doesn't solve the problem of why the GUI doesn't respond when the upload starts and finishes
[QUOTE=ColdFusion;21673950]First: I hate Linker Errors They dont make any sense [code] ------ Build started: Project: forceconvar, Configuration: Debug Win32 ------ Linking... Creating library C:\Users\Koen\Documents\Visual Studio 2008\Projects\forceconvar\Debug\forceconvar.lib and object C:\Users\Koen\Documents\Visual Studio 2008\Projects\forceconvar\Debug\forceconvar.exp main.obj : error LNK2019: unresolved external symbol __imp___ExitOnFatalAssert referenced in function "public: __thiscall Vector2D::Vector2D(float,float)" (??0Vector2D@@QAE@MM@Z) main.obj : error LNK2019: unresolved external symbol __imp__DoNewAssertDialog referenced in function "public: __thiscall Vector2D::Vector2D(float,float)" (??0Vector2D@@QAE@MM@Z) main.obj : error LNK2019: unresolved external symbol __imp__ShouldUseNewAssertDialog referenced in function "public: __thiscall Vector2D::Vector2D(float,float)" (??0Vector2D@@QAE@MM@Z) main.obj : error LNK2019: unresolved external symbol __imp___SpewMessage referenced in function "public: __thiscall Vector2D::Vector2D(float,float)" (??0Vector2D@@QAE@MM@Z) main.obj : error LNK2019: unresolved external symbol __imp___SpewInfo referenced in function "public: __thiscall Vector2D::Vector2D(float,float)" (??0Vector2D@@QAE@MM@Z) C:\Users\Koen\Documents\Visual Studio 2008\Projects\forceconvar\Debug\forceconvar.dll : fatal error LNK1120: 5 unresolved externals Build log was saved at "file://c:\Users\Koen\Documents\Visual Studio 2008\Projects\forceconvar\forceconvar\Debug\BuildLog.htm" forceconvar - 6 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========[/code] I found a solution here [url]http://developer.valvesoftware.com/wiki/Compiling_under_VS2005[/url] One Problem is that i am using 2008 not 2005 and i am not compiling the sdk just parts of it i use a module for gmod. And that the solution wont help[/QUOTE] Link against user32.lib.
[QUOTE=a2h;21689995]Yeah... figured it out after a while that it was because the file I was uploading was tiny. [i]However[/i], that doesn't solve the problem of why the GUI doesn't respond when the upload starts and finishes[/QUOTE] Just chuck it in another thread: [cpp] using System.Threading; new Thread( () => mywebclient.UploadFile(...) ).Start(); [/cpp]
[QUOTE=raBBish;21680892]Using PhysicsImpact makes no sense: [code] //----------------------------------------------------------------------------- // Purpose: Two entities have touched, so run their touch functions // Input : *other - // *ptrace - //----------------------------------------------------------------------------- void CBaseEntity::PhysicsImpact( CBaseEntity *other, trace_t &trace )[/code] I'd rather try ent->SetVelocity( tr.plane.normal * -velocity )[/QUOTE] [code]r:\hl2\src\game\client\forcepush.cpp(26) : error C2039: 'SetVelocity' : is not a member of 'C_BaseEntity' 1> r:\hl2\src\game\client\c_baseentity.h(173) : see declaration of 'C_BaseEntity'[/code] what? Do you mean SetAbsVelocity?
You cannot do this on the client-side. Shared (client & server) will work best, or server only (will only preform good in singleplayer). Also try VelocityPunch, iirc this one works well.
OK, what's wrong with it now? it's in Server\source [cpp] #include "cbase.h" #include "c_baseplayer.h" #include "c_baseentity.h" #include "c_basehlplayer.h" #include "tier0/memdbgon.h" void ForcePush() { CBasePlayer *ply = CBasePlayer::GetLocalPlayer(); trace_t tr; Vector v_Begin, v_Stop, v_Dir; AngleVectors(ply->EyeAngles(), &v_Dir); v_Begin = ply->EyePosition(); v_Stop = v_Begin + v_Dir * MAX_TRACE_LENGTH; UTIL_TraceLine(v_Begin, v_Stop, MASK_ALL, ply, COLLISION_GROUP_BREAKABLE_GLASS | COLLISION_GROUP_NPC, &tr); if(tr.m_pEnt) { DevMsg("Entity hit"); CBaseEntity *ent = tr.m_pEnt; if(tr.m_pEnt->IsNPC()) { DevMsg("Entity is NPC"); ent->VelocityPunch(tr.plane.normal * -30); } } } ConCommand force_push("force_push", ForcePush, "Use the force", NULL); [/cpp]
CBasePlayer::GetLocalPlayer() On the server you will have multiple people. Even the single-player is coded on a networked structure to allow easier porting. What you want is UTIL_GetCommandClient(). Also, next time post the error. It's better than having to guess ;)
There is no error, it just doesn't do anything to the zombie I spawn =( also, it isn't a multiplayer mod
Try using a single collision group. I don't think they're meant to be used as flags.
[QUOTE=raccoon12;21693010][code]r:\hl2\src\game\client\forcepush.cpp(26) : error C2039: 'SetVelocity' : is not a member of 'C_BaseEntity' 1> r:\hl2\src\game\client\c_baseentity.h(173) : see declaration of 'C_BaseEntity'[/code] what? Do you mean SetAbsVelocity?[/QUOTE] Yeah, SetAbsVelocity. Damn Garry's Mod API messing my head.
Hmm... still doesn't work
If you put a DevMsg on top of the function, does it print that?
Tried that, here's what I have so far [cpp] #include "cbase.h" #include "tier0/memdbgon.h" void ForcePush() { CBasePlayer *ply = UTIL_GetCommandClient(); trace_t tr; Vector v_Begin, v_Stop, v_Dir; AngleVectors(ply->EyeAngles(), &v_Dir); v_Begin = ply->EyePosition(); v_Stop = v_Begin + v_Dir * MAX_TRACE_LENGTH; UTIL_TraceLine(v_Begin, v_Stop, MASK_ALL, ply, COLLISION_GROUP_NPC, &tr); if(tr.m_pEnt) {// DevMsg("Entity hit"); CBaseEntity *ent = tr.m_pEnt; if(tr.m_pEnt->IsNPC()) { DevMsg("Entity is NPC"); ent->VelocityPunch(tr.plane.normal * -30); //If that doesn't work, might as well try this ent->SetAbsVelocity(tr.plane.normal * -30); } } } ConCommand force_push("force_push", ForcePush, "Use the force", NULL); // maybe I should set this to FCVAR_ something? [/cpp] No message comes up when I aim at a zombie, and I bound force_push to mouse1, same thing, nothing =(
OK, two questions related to C++: 1. What does (int*)foo mean? 2. What does &bar mean?
I think the second one means you are passing a reference to that variable instead of it's value so for example if you have a function like void SetTo4 (int &x) { x=4; } and call it with int a=56; SetTo4(&a); cout << a << endl; it would output 4. Not 100% sure about that.
The first one does a C-style cast to a pointer to int on foo. The second one uses the address-of operator on bar. @raccoon12: Does it output something when you place a DevMsg at the top of your function?
[QUOTE=Darwin226;21712503]SetTo4(&a);.[/QUOTE] You only need SetTo4(a);
Ok, why do you need & for functions like scanf?
[QUOTE=ZeekyHBomb;21712589]The first one does a C-style cast to a pointer to int on foo. The second one uses the address-of operator on bar. @raccoon12: Does it output something when you place a DevMsg at the top of your function?[/QUOTE] I'll check later today, busy at the moment
I'm trying to create an array to hold pointers to variables like this: [code]extern const u8 foo[];[/code] Here's what my array looks like so far: [code]const u8* pl[] = { &foo, &bar };[/code] I'm getting this error: "cannot convert 'const u8 (*)[]' to 'const u8*' in initialization" I've tried changing the u8* in the array to things like u8 (*)[] to no avail, any ideas? Thanks.
[QUOTE=Darwin226;21712977]Ok, why do you need & for functions like scanf?[/QUOTE] scanf is a C-function and requires pointers, not references. [QUOTE=a2h;21713049]I'm trying to create an array to hold pointers to variables like this: [code]extern const u8 foo[];[/code] Here's what my array looks like so far: [code]const u8* pl[] = { &foo, &bar };[/code] I'm getting this error: "cannot convert 'const u8 (*)[]' to 'const u8*' in initialization" I've tried changing the u8* in the array to things like u8 (*)[] to no avail, any ideas? Thanks.[/QUOTE] In the first snippet you have a const array of u8, in the second snippet you have a const array of u8 [i]pointers[/i].
[QUOTE=ZeekyHBomb;21713409]In the first snippet you have a const array of u8, in the second snippet you have a const array of u8 [i]pointers[/i].[/QUOTE] But isn't that what I want to do? I want to stuff these variables which I have little control under due to the library I'm using into an array, but without using up more memory with a duplicate of the variable's contents.
In the first snippet you have an array of u8, not of u8 pointers tho.
[QUOTE=ZeekyHBomb;21713470]In the first snippet you have an array of u8, not of u8 pointers tho.[/QUOTE] I tried adding [] to the end of the pointers in the array, but that caused "expected primary-expression before ']' token". Bleh, I'm confused, off to sleep.
Sorry, you need to Log In to post a reply to this thread.