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

Some newbe questions on mm coding


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Carolus
Member
Join Date: Jun 2010
Old 07-21-2010 , 08:34   Some newbe questions on mm coding
Reply With Quote #1

Hi,

I'm trying to move from sm to mm, but there are some things that I just have
no clue how to do.

Can you help me translate these snippets to C++/MM ?

(my trouble is mostly to mimic some of the stock SM functions)

Code:
PrintToChat(index,"%s :D","hello world");
Code:
PlayerCashOffset = FindSendPropOffs("CCSPlayer","m_iAccount");      
if (PlayerCashOffset == -1)
{
   cash = GetEntData(index, PlayerCashOffset);
}
Code:
    new maxclients = GetMaxClients();
    decl teams[maxclients];
    for(new j=1; j <= maxclients; j++)
    {
        if (IsClientConnected(j) && IsClientInGame(j) && !IsFakeClient(j))
        {
            if (GetClientTeam(j) == TEAM_CTS)
            {
                teams[j] = TEAM_CTS;
            } else {
                teams[j] = TEAM_TS;
            }
        }        
    }        
    for(new j=1; j <= maxclients; j++)
    {
        if (IsClientConnected(j) && IsClientInGame(j) && !IsFakeClient(j))
        {
            if (teams[j] == TEAM_CTS)
            {
                ChangeClientTeam(j, TEAM_TS);
            } else {
                ChangeClientTeam(j, TEAM_CTS);
            }
        }        
    }
Thanks a lot for your time and help!


oops wrong forum, can someone move my thread? thanks!
__________________
Carolus is offline
Afronanny
Veteran Member
Join Date: Aug 2009
Old 07-22-2010 , 07:52   Re: Some newbe questions on mm coding
Reply With Quote #2

Look at the SourceMod sourcecode and see how sourcemod does it.

http://hg.alliedmods.net/releases/sourcemod-1.3/summary
Afronanny is offline
Carolus
Member
Join Date: Jun 2010
Old 07-22-2010 , 08:50   Re: Some newbe questions on mm coding
Reply With Quote #3

I tried that but sourcemod uses other internal sourcemod functions which use other internal functions .. all of these have their own header includes and so on and so on.

I just wish I could write an overly simple plugin without having to analyse the whole SDK codebase and all of sourcemod.. and thats why I asked for help.
__________________
Carolus is offline
psychonic

BAFFLED
Join Date: May 2008
Old 07-22-2010 , 09:25   Re: Some newbe questions on mm coding
Reply With Quote #4

Quote:
Originally Posted by Carolus View Post
I just wish I could write an overly simple plugin without having to analyse the whole SDK codebase and all of sourcemod.. and thats why I asked for help.
That's why SM plugin functionality exists.
psychonic is offline
Carolus
Member
Join Date: Jun 2010
Old 07-22-2010 , 12:09   Re: Some newbe questions on mm coding
Reply With Quote #5

Yes but only MM plugins can have closed source...
http://forums.alliedmods.net/showthread.php?t=131961

And I'm pretty sure it would only take a few minutes to the experienced
MM coders to help me out.

EDIT:
I don't want to sound like I'm lazy and I want others to do the work for me. But isn't
the whole point of these forums to help each other rather than pointing out obvious facts?
I mean I'm asking a consice, clear question about MM development and all I get in return are questions
as to why I need help and how I wouldn't need the help if I had all the knowledge possible around MM coding..

Whats the point of these forums then? Just post a sticky to the HL SDK and SM trunk and lock down the MM question/coding forums.
That would be even easier.

I'm sorry, I really am, but it doesn't feel like you're even wanting to help people...I'm used to the Java programming world, and when you ask
people how to do something, they don't reply with a link to the Java API. They give you examples. Its what I do whenever I can.


__________________

Last edited by Carolus; 07-22-2010 at 12:18.
Carolus is offline
psychonic

BAFFLED
Join Date: May 2008
Old 07-22-2010 , 14:06   Re: Some newbe questions on mm coding
Reply With Quote #6

Quote:
Originally Posted by Carolus View Post
Whats the point of these forums then? Just post a sticky to the HL SDK and SM trunk and lock down the MM question/coding forums.
That would be even easier.
umad?


I was pointing out that SM plugins were much easier because it was not apparent that you needed it to be closed source (no I did not recognize your username from the other thread).

The issue is that there is very little documentation for the sdk, which is directly what you need to interact with.

Afronanny's suggestion was apt. Looking at other plugins or the sdk is the quickest way to figure out how to do the things you are asking. You might want to start with the public headers in the sdk. IServer has GetMaxClients and IPlayerInfo has the ChangeTeam function (and it also has a IsFakeClient function, but it's not necessarily accurate). If ClientPutInServer has been called for a client (without a later, corresponding ClientDisconnect), you know they are ingame.

Coming in here and demanding answers isn't likely to garner good will and help.
psychonic is offline
BAILOPAN
Join Date: Jan 2004
Old 07-23-2010 , 04:43   Re: Some newbe questions on mm coding
Reply With Quote #7

Making plugins like this closed-source is sad and harmful. Anyway, there are two problems with your post.

The first is, you basically asked for someone to come along and do a 1:1 translation of extremely high-level code. It's not possible. SourceMod abstracts away the deep complexities of C++ and the SDK. It'd probably be 500 lines of delicate code to correctly implement your snippet, and it'd take pages and pages to explain it.

If you're serious about developing plugins in C++, you will need to be able to maintain and debug your plugin, and you will need to be able to research both the SDK and prior work like SourceMod (made possible by open-source).

The forums are here to point you in the right direction, and contrary to your opinion, it's filled with great Q&A threads. No one said systems programming was easy like Java.

My advice: ask specific questions. How does this code work? Where can I find how X works? How can I do Z? Show that you've done some research, and people will know how to help you better.
__________________
egg

Last edited by BAILOPAN; 07-23-2010 at 04:51.
BAILOPAN is offline
Carolus
Member
Join Date: Jun 2010
Old 07-23-2010 , 12:15   Re: Some newbe questions on mm coding
Reply With Quote #8

First of all, thank you both very much!

Please let me apologise for my previous post, I was wrong to take that tone.

Quote:
Originally Posted by psychonic View Post
umad?
I kinda was, please accept my apology.

Quote:
Originally Posted by psychonic View Post
Afronanny's suggestion was apt. Looking at other plugins or the sdk is the quickest way to figure out how to do the things you are asking
I agree, and I did look at existing plugins, but most of them are outdated,
and those who aren't usually don't make use of the things I'm looking for.

Quote:
Originally Posted by psychonic View Post
You might want to start with the public headers in the sdk. IServer has GetMaxClients and IPlayerInfo has the ChangeTeam function (and it also has a IsFakeClient function, but it's not necessarily accurate). If ClientPutInServer has been called for a client (without a later, corresponding ClientDisconnect), you know they are ingame.
Thats basically the info I was looking for. Thank you very much.

Quote:
Originally Posted by psychonic View Post
Coming in here and demanding answers isn't likely to garner good will and help.
I understand that, and I'll try to be more civilised in the future.


Quote:
Originally Posted by BAILOPAN View Post
Making plugins like this closed-source is sad and harmful.
I agree and I wish there was another way, but surely you must agree that it is probably one of the best ways (except off course being able to ensure the integrity of the application at runtime) to prevent abuse of the source code in this context.


Quote:
Originally Posted by BAILOPAN View Post
SourceMod abstracts away the deep complexities of C++ and the SDK. It'd probably be 500 lines of delicate code to correctly implement your snippet, and it'd take pages and pages to explain it.
I don't agree.
The SDK and MM may be complex, but C++ is just a programming language.
Translating the high level code I wrote above should be a simple matter of refactoring if you know both MM & SM.

Quote:
Originally Posted by BAILOPAN View Post
If you're serious about developing plugins in C++, you will need to be able to maintain and debug your plugin, and you will need to be able to research both the SDK and prior work like SourceMod (made possible by open-source).
Right I have no problems with that at all. But there's a problem here.
- There is virtually no documentation (as I have read oh so many times on these forums)
- the deep complexities of [..] the SDK

So basically if I want to use MM I have to fully understand the SDK.

Quote:
Originally Posted by BAILOPAN View Post
The forums are here to point you in the right direction, and contrary to your opinion, it's filled with great Q&A threads.
I'm sure it looks that way to you since you can see how older code interconnects with the newer releases, but unless I try to compile those things with every possible release, there is no way to know how those examples fit in. (not without any documentation)

Quote:
Originally Posted by BAILOPAN View Post
No one said systems programming was easy like Java.
Right because there's no way to program systems with Java.
I wonder what we were doing back at school when we were programming CPUs using Java?


Quote:
Originally Posted by BAILOPAN View Post
My advice: ask specific questions. How does this code work? Where can I find how X works? How can I do Z? Show that you've done some research, and people will know how to help you better.
Yep thats another one of my mistakes, I should have made the following things clear :

- I have had courses on C/C++ programming, but I (almost) never practice it
- I'm a fluent programmer in many (most?) high-level programming languages
- I have read the documentation on the sourcemm.net website but found it insufficient (which is probably a failure on my part)
- I have read articles on the valve dev pages and compiled some easy examples
- I have gone trough most of the plugins available on these forums but found them outdated or off topic
- I hope to be able to devise a way to make the source code public :
Currently my idea is to use every function/method within the plugin (kinda the unit-testing way) and have the return values put in an md5-buffer, along with a user defined parameter and returning the resulting md5 to the end user (allowing that token to be compared). But I'm still not sure if this would achieve acceptable security. Thinking of it : does SourcePawn have an md5 implementation?
- As you may know by now Ive been making SM plugins.

And finally I wish to learn more about MM coding, but I can't seem to find a good trail.
__________________

Last edited by Carolus; 07-23-2010 at 12:17.
Carolus is offline
Afronanny
Veteran Member
Join Date: Aug 2009
Old 07-23-2010 , 13:47   Re: Some newbe questions on mm coding
Reply With Quote #9

Not sure if you've seen this: http://wiki.alliedmods.net/Category:...ce_Development
Afronanny is offline
Carolus
Member
Join Date: Jun 2010
Old 07-23-2010 , 16:27   Re: Some newbe questions on mm coding
Reply With Quote #10

I have afronanny, but thanks anyway. Most of the information is either out-dated either too technical (SH part) to dive in without background knowledge, unless you can make it clear for me

By the way, how much would you charge to extend SM/MM to include "decent" security. And by security I mean a means to ensure loaded SM plugins are authentic.
Also would you be interested in bandwidth or source server hosting as payment?
__________________

Last edited by Carolus; 07-23-2010 at 16:31.
Carolus 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 09:41.


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