Raised This Month: $32 Target: $400
 8% 

Novice needing sourcepawn help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
The Solid lad
Senior Member
Join Date: Oct 2018
Old 01-24-2019 , 17:34   Novice needing sourcepawn help
Reply With Quote #1

Hy!
I'm very much a novice when it comes to tampering with plugins...

I want to enable the usage of more custom colors ({YELLOW} in particular) in this plugin via using "colorvariables.inc" (the same one, which the well known "Advertisements 2.0" plugin uses)

So far I've tried adding "#include <colorvariables>" to the first line of the source code and then compiling the "Autoresponder" plugin with the complier included in the latest sourcemod build.
The compilation was succesful (I had the colorvariables.inc placed in the includes folder), but I'm still not able to use other colors than the four basic ones which were available by default...
Please enlighten me.

Btw, is there a good "getting started with sourcepawn" kind of tutorial available anywhere?
The Solid lad is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 01-24-2019 , 19:58   Re: Novice needing sourcepawn help
Reply With Quote #2

First and most importantly, use the search function on the site. All the answers you seek are more than likely already answered.

Second, this is the wrong place to be seeking help, this section of the forum is for Source Servers (SRCDS). Ask in the correct section, such as scripting. As for why you can only use four of the basic ones, we have no idea, you haven't given any information on what game, any of the code you used, or even what colors you have tried. Don't expect help if you don't provide us with the information to help you. If this is a post about scripting, provide what you are doing and the code you are using, give examples. Also, don't go making another post, edit your post with the correct content and report the post so that a moderator can move it for you.

Tutorials are everywhere if you search. Review the introduction for SourcePawn 1.7: Here you go.
Maxximou5 is offline
The Solid lad
Senior Member
Join Date: Oct 2018
Old 01-25-2019 , 13:07   Re: Novice needing sourcepawn help
Reply With Quote #3

Nice passive aggression on your end, must be a pretty miserable life you lead if you took the time to make me seem stupid, instead of trying to actually help me.

It would have been very easy for someone more versed in plugin making to give me an answer based on the information I gave.
I gave a link to the plugin I was talking about and very clearly worded what my intents were.
This is a very simple problem, yet all I get is an elitist, condescending response with a "let me google that for you" link baked into it.

The all so "abundant" tutorials are nowhere to be found.
The only proper search results in google are the very long winded introductory alliedmods wiki articles, and those, despite their lenght, don't answer my simple, but specific question.

I'm most likely more versed in video editing, monitors and computer mice than you are, but if you were to ask a simple question about them, I wouldn't treat you like a stupid mongrel, (which you just did) but instead I would answer your question, and would be glad that you trusted me with the task of giving you more wisdom... which in turn would leave a good impression in you.

With this toxic and alienating of an approach to newcomers, this community shouldn't be surprised that not many people have the drive to continue trying to learn about sm and sourcepawn, and much less contributing to it.
The Solid lad is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 01-25-2019 , 13:36   Re: Novice needing sourcepawn help
Reply With Quote #4

My apologies for making it come off that way. I still suggest supplying the game(s) you are trying to do this for. Different games handle colors differently, such as TF2 and CS:GO do not handle the same way, and even colors from CS:S and CS:GO are different as well. If colorvariables.inc isn't working for you, it could be how you're using it. There may be a better include that would work for you in this case instead.

You can also check the Snippets and Tutorials section if you want more things to browse.
Maxximou5 is offline
The Solid lad
Senior Member
Join Date: Oct 2018
Old 01-25-2019 , 13:46   Re: Novice needing sourcepawn help
Reply With Quote #5

The game in question is CS:S, and I don't even know if I did the "including" right....did I?
Is putting the include file in the correct folder, and adding that string (#include <colorvariables>) to the first line of the script for the plugin, all there is to "including"?
(I don't even know the proper name for it...up to this point I've only touched config files, not the plugins themselves)
The Solid lad is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 01-25-2019 , 14:36   Re: Novice needing sourcepawn help
Reply With Quote #6

If you would, attach or use the code tags/php tags and give us the code you are using. That include should work with CS:S as it's in the list as supported.

However, I don't see yellow as a listing of available colors in CSS itself, but I do see it in colorvariables.inc as \x09. With that said you don't need to incorporate the include you can just add it to the replacement string, like such:
Spoiler


In the above, we've added the replacement ability for {YELLOW} which will use \x09 so that it appears in the game as yellow. You can go ahead and try that one and see if it does come out as yellow. Otherwise we would move onto what the issue you may have been facing. The issue which is that just because you added the include it may not be used, you would need to use the functions that would call those colors.

For this we remove the replacement of colors, such as {GREEN} and let the include do the hard work in replacing that. HOWEVER, you would need to change your .cfg file that has {GREEN} in it to {green} as that's how colorvariables treats those. We use the function CPrintToChat, much like PrintToChat but with the benefit of colorvariables doing the print and changing the colors for us.

Spoiler


Let me know if you have any issues compiling it, and of course if I've made any mistakes someone here would certainly love to point it out for me. Unfortunately I can't test it right now but will later and make any corrections to point you in the right direction.

Last edited by Maxximou5; 01-25-2019 at 14:39. Reason: made a mistake already
Maxximou5 is offline
The Solid lad
Senior Member
Join Date: Oct 2018
Old 01-25-2019 , 18:30   Re: Novice needing sourcepawn help
Reply With Quote #7

Thank you, that was very informative!
I've learned so much from this single post...because it is explained in a relatively noob friendly way, with real world examples!

And yes, CS:S doesn't have a {yellow} text color by default, the advertisements 2.0 plugin does however, which most (including mine) CS:S servers employ.

Now that we've dived into this, let me bore you a bit with the whole story:
I have set up the advertisements plugin so that it displays adverts in green, with a yellow prefix. (Which prefix is the name of my clan: |Happy Lads|)
Which is all fine and dandy, but now that I downloaded the Autoresponder plugin for my servers, I'm stuck wanting consistency... I don't just want to leave out the prefix, or display it in the default color... I want it displayed in yellow.
So I've started looking into how Dj Tsunami got all those colors working in his plugin...looked at the source code of his plugin, and saw that he had these two lines right at the beginning of it:
#include <sourcemod>
#include <colorvariables>

The rest is probably obvious... I'm trying to get all those colors (or at least yellow) working with the Autoresponder plugin.

So back to topic:
I've compiled the second version... because all colors is better than some colors, right? And it works! Thank you! Not only did I accomplish what I wanted, I also learnt things in the process.

However, you saying "With that said you don't need to incorporate the include you can just add it to the replacement string"
makes me wonder, what does incorporating an "include" actually do? Does it have it's drawbacks compared to using a replacement string? And what are the drawbacks of using a replacement string other than the obvious? (More typing to be done)
I'm sorry for seemingly wasting your time btw, but I'm really curious.
The Solid lad is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 01-25-2019 , 19:04   Re: Novice needing sourcepawn help
Reply With Quote #8

Excellent, good to hear you were able to compile it and get it working the way you wanted.

An include won't do anything more than be included in the compilation of the plugin. It is up to the coder (you) to use what functions, forwards, natives, or stocks that it may have inside it. If none of it is used, you should remove the include as to reduce the size and it's just a good coding habit. In the case I presented earlier, the code used CPrintToChat which was inside of the include you wanted to use (colorvariables.inc). CPrintToChat has other functions inside of it that did all the work in finding the {yellow} color and replacing it with what CS:S uses in order to make the text appear that color when you specified it in your configuration file.

I'll do a step by step for you in trying to describe the replacement string in the first example I provided earlier.
Spoiler


I think this is what you will find most helpful in seeing the relationship of \xYY and where in the include it uses it.
https://github.com/ErikMinekus/sm-ad....inc#L966-L983
Maxximou5 is offline
The Solid lad
Senior Member
Join Date: Oct 2018
Old 01-28-2019 , 05:20   Re: Novice needing sourcepawn help
Reply With Quote #9

Thank you again! Very informative!

One thing I noticed is that the version which you edited to use "CPrintToChat" now prints a the response to a player's trigger, before their message...
which makes it so that it doesn't seem like it's actually "responding" to it anymore.
The Solid lad is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 01-28-2019 , 22:03   Re: Novice needing sourcepawn help
Reply With Quote #10

The color codes Max used above (yellow = \x09) are specific to CS:GO. For CS:S, some colors can be done using \x03, \x04, etc., but most are achieved using hex color codes. Everywhere you want to change color, put \x07 followed by the 6-digit color code. e.g. Red = \x07FF0000

Hex color codes can be found on many websites such as this or this. Basically, just google search "hex color codes". Hope that helps.

Note: Using the above for formatting colors, you do not need any includes. If you wish to use the More Colors include, you would use its functions (e.g. CPrintToChat or CPrintToChatAll) in combo with the color names in brackets that the plugin creates. However, that is just a wrapper for doing the above hex color codes.
__________________

Last edited by ThatOneGuy; 01-28-2019 at 22:10.
ThatOneGuy is offline
Reply


Thread Tools
Display Modes

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 13:16.


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