Raised This Month: $151 Target: $400
 37% 

Scripting onjoin msg help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
retsam
Veteran Member
Join Date: Aug 2008
Location: so-cal
Old 09-24-2008 , 20:37   Scripting onjoin msg help
Reply With Quote #1

Ok so, im new to sm scripting. I really have no clue how to do anything yet, so im trying to learn.

If anyone here is familiar with eventscripts, can you convert a simple advert onjoin script I made to sourcemod plugin? If I could just see how a simple script is done like this in sourcemod, it would help greatly.

Code:
block load
{
//Version
  es_xset nade_adverts v0.1
  es_makepublic nade_adverts
  
  es_msg [nade_adverts] is loading..
  
  
}

block unload
{
    es_msg [nade_adverts] is unloading..
  
}


event player_activate
{
    
    //Menu display info about tools upon join
    es_delayed 5 es_tell event_var(userid) #multi #greenServer features TF2 Nades!   -    Bind a key #default+nade2 #greenor say #default!nades #greenfor help!
}


How would you duplicate this in SM?
retsam is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 09-24-2008 , 20:53   Re: Scripting onjoin msg help
Reply With Quote #2

PHP Code:
#pragma semicolon 1

#include <sourcemod>

public OnPluginStart()
{
    
LogMessage("[nade_adverts] is loading..");
}

public 
OnPluginEnd()
{
    
LogMessage("[nade_adverts] is unloading..");
}

public 
OnClientPutInServer(client)
{
    
CreateTimer(5.0Messageclient);
}

public 
Action:Message(Handle:timerany:client)
{
    if (
IsClientConnected(client))
        
PrintToChat(client"\x03Server features TF2 Nades!  -  Bind a key \x00+nade2 \x03or say \x00!nades \x03for help!");


Last edited by bl4nk; 09-24-2008 at 20:59.
bl4nk is offline
retsam
Veteran Member
Join Date: Aug 2008
Location: so-cal
Old 09-24-2008 , 23:32   Re: Scripting onjoin msg help
Reply With Quote #3

Awesome Bl4nk. Thanks so much.

The script works. Looks like there are some errors in the text part though. Its in lightgreen instead of green for one, and it cuts off the words after bind a key. Doesnt show any text after that. Why is that?


EDIT: NM. I think I got it. It looks like you meant to probably put \x04 for green and \x01 for the white part. \x00 makes the text after that disappear. Putting \x01 seemed to fix it.

Is that correct?

x04 is green
x03 is lightgreen
x02 = ?
x01 = white
x00 = text gone?

Last edited by retsam; 09-25-2008 at 00:43.
retsam is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 09-25-2008 , 00:53   Re: Scripting onjoin msg help
Reply With Quote #4

Yeah, you're right. I forgot what the color codes were, but what you said is right.
bl4nk is offline
retsam
Veteran Member
Join Date: Aug 2008
Location: so-cal
Old 09-25-2008 , 02:05   Re: Scripting onjoin msg help
Reply With Quote #5

Gotcha. Just been fiddling around.

So here is what I have now.

Code:
#pragma semicolon 1

#include <sourcemod>
#define PLUGIN_VERSION "0.1"

public Plugin:myinfo =
{
    name = "tf2nades_adverts",
    author = "Retsam",
    description = "TF2 Nades Adverts",
    version = PLUGIN_VERSION,
    url = "http://www.sourcemod.net/"
};


public OnPluginStart()
{
    LogMessage("[nade_adverts] is loading..");
    // convars
        CreateConVar("sm_tf2nades_advert_version", PLUGIN_VERSION, "TF2NADES ADVERTS version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
}

public OnPluginEnd()
{
    LogMessage("[nade_adverts] is unloading..");
}

public OnClientPutInServer(client)
{
    CreateTimer(5.0, Message, client);
}

public Action:Message(Handle:timer, any:client)
{
    if (IsClientConnected(client))
        PrintToChat(client, "\x04Server features TF2 Nades!  -  Bind a key \x01+nade2 \x04or say \x01!nades \x04for help!");
}
If I wanted to take this 1 step further, and add a timer to this script that displays another different set of text at the top of the screen in like yellow, repeats infinite amount of times after a set delay, is that easy to do?

Last edited by retsam; 09-25-2008 at 02:07.
retsam is offline
Antithasys
Moderator
Join Date: Apr 2008
Old 09-26-2008 , 14:35   Re: Scripting onjoin msg help
Reply With Quote #6

5 seconds is pretty short of a time for that timer. When they enter the game kill spam with scroll/replace any message they would see. I would change it to 30 seconds. In addition I would add a client == 0 and isclientconnected to the start of the timer as well to avoid in unnecessary timer creations. Something like:

PHP Code:
public OnClientPutInServer(client)
{
    if (
client == || !IsClientConnected(client))
        return;
    
CreateTimer(30.0Messageclient);

Antithasys 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 12:39.


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