Raised This Month: $ Target: $400
 0% 

Advertisements with more than 1 line!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CFN|Toky
Junior Member
Join Date: Jun 2006
Old 06-15-2007 , 15:51   Advertisements with more than 1 line!
Reply With Quote #1

Hi!

I already tried to do it by myself ( I am a c++ programmer ) but I can't do it ->

I want the plugin ad_manager.sma to support advertisements with more than 1 line f.e. by using \n to start a new line.

Problem: Some people already asked the coder of the plugin but he doesn't add this function. He said he will rewrite the plugin but nothing happens.

This is the code of the output function. I think the only thing to do is a query to look up if the message contains a \n and if there is one in it to break the line at this point by splitting it in more messages (max 5).

Here is a C++ example. I hope its now not so much work for you.
PS: I have no idea if something like this.. ..I coded.. is possible!
Code:
//Here is the String with the complete Message
AnsiString Message="TEXT \n TEXT \n TEXT"

//Now there is a loop going as long as the message contains '\n'
while (Message.Pos("\n")==true){

        //The Text from Letter 1 up to the '\n' is written in the Chat but you have to sort the '\n' out with -2!

        SEND_TEXT_TO_PLAYERS(Message.SubString(1,Message.Pos("\n")-2));

        //Delete the string from position 1 up to the '\n' with the '\n' so you dont need -2!
         Message.delete(1,Message.Pos("\n"));
         };

         //The last line is not sent because there is no more '\n' is in the message!
         SEND_TEXT_TO_PLAYERS(Message);
};
THX for help!

Code:
public displayAd(params[])
{
    //Get the string that is going to be displayed
    new message[128];
    getString(STORE, params[1], message, 127, params[0], params[1]);
    
    //If its enabled by cvar and id is set, display to person who triggered message only
    if(get_cvar_num("ad_react_all") == 0 && params[2] != 0)
    {
        message_begin(MSG_ONE, gmsgSayText, {0,0,0}, params[2]);
        write_byte(params[2]);
        write_string(message);
        message_end();
    
    } else
    {
        //Display the message to everyone
        new plist[32], playernum, player;
        
        get_players(plist, playernum, "c");
    
        for(new i = 0; i < playernum; i++)
        {
            player = plist[i];
            
            message_begin(MSG_ONE, gmsgSayText, {0,0,0}, player);
            write_byte(player);
            write_string(message);
            message_end();
        }
    }
    
    return PLUGIN_HANDLED;
}
__________________
Regards/Gruß CFN|Toky
Administrator Clanforums Network - www.clanforums.com


Last edited by CFN|Toky; 06-15-2007 at 15:53.
CFN|Toky is offline
Send a message via ICQ to CFN|Toky Send a message via MSN to CFN|Toky Send a message via Skype™ to CFN|Toky
CFN|Toky
Junior Member
Join Date: Jun 2006
Old 06-16-2007 , 06:04   Re: Advertisements with more than 1 line!
Reply With Quote #2

I found something but I cant get this things together working... PLS HELP!!!

The code checks for spaces! -> StringVar[a]==32 (SPACE);

I need (
StringVar[a]==92 && StringVar[a+1]==110) <- "\n"
Code:
// StringVar = "map sq1 linebattle"
remove_quotes(StringVar)
new a=0,i=0,b[80] //change b to higher number if you want to find more than 80 spaces
while(a<strlen(StringVar)) {
    if(StringVar[a]==32) {
        b[i]=a
        i++
    }
    a++
}
parse(StringVar,Msg,b[0],Msg1,b[1]-b[0],Msg2,40)  //change 40 to b[2]-b[1] if you want to look for more strings
//returns  Msg="map" Msg1="sq1" Msg2="linebattle" 
__________________
Regards/Gruß CFN|Toky
Administrator Clanforums Network - www.clanforums.com


Last edited by CFN|Toky; 06-16-2007 at 06:07.
CFN|Toky is offline
Send a message via ICQ to CFN|Toky Send a message via MSN to CFN|Toky Send a message via Skype™ to CFN|Toky
CFN|Toky
Junior Member
Join Date: Jun 2006
Old 06-16-2007 , 07:57   Re: Advertisements with more than 1 line!
Reply With Quote #3

Hey I can compile it do you think it will work?

Code:
public displayAd(params[])
{
    //Get the string that is going to be displayed
    new message[128];
    new messageend[128];
    new zz=-1;

    getString(STORE, params[1], message, 127, params[0], params[1]);

    //If its enabled by cvar and id is set, display to person who triggered message only
    if(get_cvar_num("ad_react_all") == 0 && params[2] != 0)
    {
        message_begin(MSG_ONE, gmsgSayText, {0,0,0}, params[2]);
        write_byte(params[2]);
        write_string(message);
        message_end();

    } else
    {
        //Display the message to everyone
        new plist[32], playernum, player;

        get_players(plist, playernum, "c");

          while (strfind(message,"\",false,0)!=zz){
           new messagesend[128];
           strbreak(message,messagesend,sizeof(message)-strfind(message,"\",false,0),messageend,strfind(message,"\",false,0));
           //copy(message_send,strfind(message,"\"),message);

            for(new i = 0; i < playernum; i++)
            {
                player = plist[i];

                message_begin(MSG_ONE, gmsgSayText, {0,0,0}, player);
                write_byte(player);
                write_string(message);
                message_end();
            }
            
          }
    }
    
    return PLUGIN_HANDLED;
}
__________________
Regards/Gruß CFN|Toky
Administrator Clanforums Network - www.clanforums.com


Last edited by CFN|Toky; 06-17-2007 at 09:15.
CFN|Toky is offline
Send a message via ICQ to CFN|Toky Send a message via MSN to CFN|Toky Send a message via Skype™ to CFN|Toky
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-16-2007 , 08:00   Re: Advertisements with more than 1 line!
Reply With Quote #4

Quote:
Hey I can compile it do you think it will work?
Why don't you test by yourself ? oO

Put some debug messages and see.
__________________
Arkshine is offline
CFN|Toky
Junior Member
Join Date: Jun 2006
Old 06-17-2007 , 09:12   Re: Advertisements with more than 1 line!
Reply With Quote #5

I am not a amxx programmer ;)
how can I put some debug messages in it - that will help me very much!
__________________
Regards/Gruß CFN|Toky
Administrator Clanforums Network - www.clanforums.com

CFN|Toky is offline
Send a message via ICQ to CFN|Toky Send a message via MSN to CFN|Toky Send a message via Skype™ to CFN|Toky
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 06-17-2007 , 14:01   Re: Advertisements with more than 1 line!
Reply With Quote #6

i take log_amx("this is a debug message"); because i test it localy and see the server console on my desktop..
You can also put client_print(0, print_chat, "this is a debug message"); in the code which prints in chat...

greetz regalis
__________________
regalis is offline
CFN|Toky
Junior Member
Join Date: Jun 2006
Old 06-18-2007 , 11:59   Re: Advertisements with more than 1 line!
Reply With Quote #7

thx for help!
__________________
Regards/Gruß CFN|Toky
Administrator Clanforums Network - www.clanforums.com

CFN|Toky is offline
Send a message via ICQ to CFN|Toky Send a message via MSN to CFN|Toky Send a message via Skype™ to CFN|Toky
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 10:40.


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