AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Scripting onjoin msg help (https://forums.alliedmods.net/showthread.php?t=77970)

retsam 09-24-2008 19:37

Scripting onjoin msg help
 
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?

bl4nk 09-24-2008 19:53

Re: Scripting onjoin msg help
 
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!");



retsam 09-24-2008 22:32

Re: Scripting onjoin msg help
 
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?

bl4nk 09-24-2008 23:53

Re: Scripting onjoin msg help
 
Yeah, you're right. I forgot what the color codes were, but what you said is right.

retsam 09-25-2008 01:05

Re: Scripting onjoin msg help
 
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?

Antithasys 09-26-2008 13:35

Re: Scripting onjoin msg help
 
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);




All times are GMT -4. The time now is 00:57.

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