Auto Announcement sPWAdmin [need help]

Page 1 of 2 12 LastLast
Results 1 to 25 of 46
  1. #1
    Sorcerer Supreme ivanaivana is offline
    Member +Rank
    Oct 2010 Join Date
    RussiaLocation
    323Posts

    Auto Announcement sPWAdmin [need help]

    Tryed Bash's script Risingmoon DEV - Powered by Discuz!, but seems iweb and pwadmin works more different than i thought.
    If some1 know how to remake that script for pwadmin, that would be great

    p.s. thx.
    p.p.s. sorry for my bad english.
    Last edited by ivanaivana; 16-01-11 at 10:31 PM. Reason: p.p.s. edited :D


  2. #2
    Black Magic Development das7002 is offline
    Grand MasterRank
    Apr 2010 Join Date
    EarthLocation
    2,188Posts

    Re: Auto Announcement sPWAdmin [need help]

    No it doesn't need iWeb, all it needs is the protocol API which every server release has

    pwAdmin include it so it would run fine as well with pwAdmin however it is not a pwAdmin plugin you would have to edit the include/classpath for it to work properly

  3. #3
    Sorcerer Supreme ivanaivana is offline
    Member +Rank
    Oct 2010 Join Date
    RussiaLocation
    323Posts

    Re: Auto Announcement sPWAdmin [need help]

    Thx alot, will try to do some noobish magic with protocols :D

  4. #4
    Sorcerer Supreme ivanaivana is offline
    Member +Rank
    Oct 2010 Join Date
    RussiaLocation
    323Posts

    Re: Auto Announcement sPWAdmin [need help]

    Ok i tryed and no results :D
    Code broadcast.jsp
    Code:
    <%@page contentType="text/html; charset=UTF-8"%> //this is to see russian simbols
    <%@page import="java.lang.*"%>
    <%@page import="java.util.*"%>
    <%@page import="java.text.SimpleDateFormat"%> // copy from pwadmin
    <%@page import="org.apache.commons.lang.StringEscapeUtils"%>
    <%@page import="protocol.*"%>
    <%@page import="com.goldhuman.auth.*"%>
    <%@page import="com.goldhuman.util.*"%>
    <%@page import="org.apache.commons.logging.Log"%>
    <%@page import="org.apache.commons.logging.LogFactory"%>
    <%@page import="java.io.*"%>
    <%@page import="java.sql.*"%>
    <%@page import="org.apache.axis.encoding.Base64"%> // copy from pwadmin
    <%@include file="../../WEB-INF/.pwadminconf.jsp"%> // copy from pwadmin
    
    <%
    	boolean allowed = true; //so we don need enter password for pwadmin
    
    	if(request.getSession().getAttribute("ssid") != null)
    	{
    		allowed = true;
    	}
    %>
    
    <%
            String msg = "Automatic Broadcast System Test";
    try {
            protocol.DeliveryDB.broadcast((byte)9,-1,msg);
    }
    catch (Exception e)
    {
            out.println("<font color=red>Error Attempting to Broadcast Message!</font>");
    }        
    %>
    <%
    out.println("<font color=green>Successfully Sent Broadcast Message!</font>");
    %>
    Cron test anons
    Code:
    /opt/jetty-7.2.0/webapps/pwadmin/broadcast.jsp
    xx xx * * * *
    What is wrong?
    Last edited by ivanaivana; 17-01-11 at 02:10 PM.

  5. #5
    Grand Master 343 is offline
    Grand MasterRank
    Oct 2009 Join Date
    Ancient DGN CTYLocation
    5,510Posts

    Re: Auto Announcement sPWAdmin [need help]

    use a script; example:

    cron
    Code:
    00 * * * *  root    /etc/cron.pw/aa1.sh
    aa1.sh
    Code:
    #!/bin/sh
    
    wget http://127.0.0.1:8080/pwAdmin/AA/aa1.jsp
    rm *jsp*
    aa1.jsp
    Code:
    <%@page contentType="text/html; charset=GBK"%>
    <%@page import="java.lang.*"%>
    <%@page import="java.util.*"%>
    <%@page import="java.text.*"%>
    <%@page import="org.apache.commons.lang.StringEscapeUtils"%>
    <%@page import="protocol.*"%>
    <%@page import="com.goldhuman.auth.*"%>
    <%@page import="com.goldhuman.util.*"%>
    <%@page import="org.apache.commons.logging.Log"%>
    <%@page import="org.apache.commons.logging.LogFactory"%>
    <%@page import="java.io.*"%>
    <%@page import="java.sql.*"%>
    <%
    	//
    	// Coded by [B]aSH from Vendetta Gaming Network.
    	// 
    String msg = "PUT ANNOUNCEMENT HERE";
    try {
    	protocol.DeliveryDB.broadcast((byte)9,-1,msg);
    }
    catch (Exception e)
    {
    	out.println("<font color=red>Error Attempting to Broadcast Message!</font>");
    }	
    %>
    <%
    out.println("<font color=green>Successfully Sent Broadcast Message!</font>");
    %>

  6. #6
    Sorcerer Supreme ivanaivana is offline
    Member +Rank
    Oct 2010 Join Date
    RussiaLocation
    323Posts

    big grin Re: Auto Announcement sPWAdmin [need help]

    Quote Originally Posted by 343 View Post
    use a script; example:

    cron
    Code:
    del
    aa1.sh
    Code:
    del
    aa1.jsp
    Code:
    del
    Thx)
    Another tests this night for me

  7. #7
    Sorcerer Supreme ivanaivana is offline
    Member +Rank
    Oct 2010 Join Date
    RussiaLocation
    323Posts

    Re: Auto Announcement sPWAdmin [need help]

    It works

  8. #8
    Grand Master 343 is offline
    Grand MasterRank
    Oct 2009 Join Date
    Ancient DGN CTYLocation
    5,510Posts

    Re: Auto Announcement sPWAdmin [need help]

    YW ;)

    Just to explain why (in case you wanted to know, or whatever) cron directly calls whatever you tell it to. Well there is no way to 'execute' a .JSP from 'bash'. You can call the JSP using wget, so to make it automated as desired you make the simple script to be activated automatically by cron, which in turn uses wget to call the announcement JSP

    ;) :D

    ---------- Post added at 02:08 PM ---------- Previous post was at 02:05 PM ----------

    so ofc the way cron is (it's really nice because) you can make almost unlimited numbers of these announce scripts & JSPs, ie... you could make one run hourly that announces "welcome to xxx server", you could make one run every year at new years (at midnight your server time) that announces "happy new year" etc etc etc... :D
    Last edited by 343; 17-01-11 at 08:13 PM.

  9. #9
    Sorcerer Supreme ivanaivana is offline
    Member +Rank
    Oct 2010 Join Date
    RussiaLocation
    323Posts

    Re: Auto Announcement sPWAdmin [need help]

    I have about 3-4 handmade (not Pwi events) automated events runnin a day, that runs without GM's, also 5 waves of ADC invasion at evenin automated. I placed all information about "when and where all that stuff starts", but we all know that players are lazy and don read wiki's at all.
    Since last year autumn i searched for some sort of auto announcements to free-up GM's time.
    so ofc the way cron is (it's really nice because) you can make almost unlimited numbers of these announce scripts & JSPs, ie... you could make one run hourly that announces "welcome to xxx server", you could make one run every year at new years (at midnight your server time) that announces "happy new year" etc etc etc... :D
    So i've made about 10 dayli anons
    Last edited by ivanaivana; 17-01-11 at 08:51 PM.

  10. #10
    Grand Master 343 is offline
    Grand MasterRank
    Oct 2009 Join Date
    Ancient DGN CTYLocation
    5,510Posts

    Re: Auto Announcement sPWAdmin [need help]

    awesome!

  11. #11
    [B]aSH nofxpunkerbrian is offline
    Grand MasterRank
    Apr 2009 Join Date
    1,151Posts

    Re: Auto Announcement sPWAdmin [need help]

    You missed in your script "//Created by Bash from Vendetta Gaming Network" out of respect, just because you modified a bit doesnt entitle you to remove that.

    Also PWAdmin folder shouldnt be used to create new jsp always use the iweb folder and reboot your java service clearing your cache so any changes or new additions will be added without an issue.

  12. #12
    Sorcerer Supreme ivanaivana is offline
    Member +Rank
    Oct 2010 Join Date
    RussiaLocation
    323Posts

    Re: Auto Announcement sPWAdmin [need help]

    Quote Originally Posted by nofxpunkerbrian View Post
    You missed in your script "//Created by Bash from Vendetta Gaming Network" out of respect, just because you modified a bit doesnt entitle you to remove that.

    Also PWAdmin folder shouldnt be used to create new jsp always use the iweb folder and reboot your java service clearing your cache so any changes or new additions will be added without an issue.
    I didnt shared it, didnt say that my script. Look 1st post.
    Just cleared coz them locked and no need to keep in 10+ files... i have your clear script with copyrights in my @downloaded@ folder.
    If you ll look second script without copyrights, there is some parts of chat.jsp from pwadmin - i cant place there only bash... and that mixed script didnt work.

    I shared some calculations for battle pets page seledit in forum, but didnt placed there copyrights, coz not me created seledit, not me created pw and formulas i made - is some sort of original wanmei core formulas, i just found it thru tests.

    p.s. thx for script and don be like this ===> "YOU SNEAKE STEALER!!!11 WHERE IS MY NAME IN ALL YOUR 10+ NO ONE SEEING SCRIPTS CHMOD 644???777"
    Last edited by ivanaivana; 18-01-11 at 11:40 AM.

  13. #13
    [B]aSH nofxpunkerbrian is offline
    Grand MasterRank
    Apr 2009 Join Date
    1,151Posts

    Re: Auto Announcement sPWAdmin [need help]

    I am just messing around :P

  14. #14
    Newbie twiggy345 is offline
    MemberRank
    Jun 2010 Join Date
    24Posts

    Re: Auto Announcement sPWAdmin [need help]

    Wrong page.....
    Last edited by twiggy345; 10-02-11 at 11:01 PM. Reason: wrong page

  15. #15
    Elite Member hi im zeus is offline
    Member +Rank
    Dec 2006 Join Date
    121Posts

    Re: Auto Announcement sPWAdmin [need help]

    Quote Originally Posted by ivanaivana View Post
    I have about 3-4 handmade (not Pwi events) automated events runnin a day, that runs without GM's, also 5 waves of ADC invasion at evenin automated. I placed all information about "when and where all that stuff starts", but we all know that players are lazy and don read wiki's at all.
    Since last year autumn i searched for some sort of auto announcements to free-up GM's time.

    So i've made about 10 dayli anons
    I know its a really old topic but how do you set it to trigger a event?

  16. #16
    Member HadesLis is offline
    MemberRank
    Feb 2011 Join Date
    At WorkLocation
    36Posts

    Re: Auto Announcement sPWAdmin [need help]

    trigger has time to start (xxx) and time to end (yyy) in npcgen, cron activates anons script about start at (xxx) and anons script about finish at (yyy).
    you can edit triggers with a npcgen-editors, there is a few workable full npcgens.

  17. #17
    Elite Member hi im zeus is offline
    Member +Rank
    Dec 2006 Join Date
    121Posts

    Re: Auto Announcement sPWAdmin [need help]

    I've been trying to get one to work still, can you post a example or a working one or pm it to me?

  18. #18
    Member HadesLis is offline
    MemberRank
    Feb 2011 Join Date
    At WorkLocation
    36Posts

    Re: Auto Announcement sPWAdmin [need help]

    Im at work now and dont have my files here. Gimme a screenshoot of your trigger in npcgen and paste a codes: java, php and cron. Ill look and say where are mistakes.

    6 Hours Ago - some sort of 4 am in my town :D

  19. #19
    Member jh281978 is offline
    MemberRank
    Jan 2011 Join Date
    WashingtonLocation
    85Posts

    Re: Auto Announcement sPWAdmin [need help]

    Quote Originally Posted by 343 View Post



    aa1.sh
    Code:
    #!/bin/sh
    
    wget http://127.0.0.1:8080/pwAdmin/AA/aa1.jsp
    rm *jsp*
    What does this code pull the .jsp from? Should mine look like this
    http:// ***.***.*.***:8080/PWServer/jetty-7.2.0/webapps/pwAdmin/***.jsp, to match my test server and the file path to were I placed the .jsp. I am asking this now so it's right the first time. Thanks 343.

  20. #20
    Grand Master 343 is offline
    Grand MasterRank
    Oct 2009 Join Date
    Ancient DGN CTYLocation
    5,510Posts

    Re: Auto Announcement sPWAdmin [need help]

    Quote Originally Posted by jh281978 View Post
    What does this code pull the .jsp from? Should mine look like this
    http:// ***.***.*.***:8080/PWServer/jetty-7.2.0/webapps/pwAdmin/***.jsp, to match my test server and the file path to were I placed the .jsp. I am asking this now so it's right the first time. Thanks 343.
    Basically, yes. However you should always use 127.0.0.1 / since you're referencing a local file (on the 'localhost') {no need to use WAN or even LAN IP}

  21. #21
    Black Magic Development das7002 is offline
    Grand MasterRank
    Apr 2010 Join Date
    EarthLocation
    2,188Posts

    Re: Auto Announcement sPWAdmin [need help]

    I'd actually recommend just using php5-cli over that

    PHP Code:
    <?php

    function broadcast($message){
            
    $sock socket_create(AF_INETSOCK_STREAMSOL_TCP);
            if(
    $sock){
                    if(
    socket_connect($sock"127.0.0.1"29100)){
                            
    socket_set_block($sock);
                            
    $data2 mByte(9) . mByte(0) . mInt(-1) . mInt(0) . mString($message);
                            
    $data mUInt32(79) . mUInt32(strlen($data2)) . $data2;
                            
    socket_send($sock$data81920);
                            
    socket_set_nonblock($sock);
                            
    socket_close($sock);
                            echo 
    "Message Sent Successfully";
                    } else {
                            echo 
    "Message Sending Failed";
                    }
            }
    }

    // pack - http://ru2.php.net/pack
    function mByte($p) { return pack('C'$p 0xFF); }

    function 
    mf($i$j) { return ($i >> $j) & 0xFF; }
    function 
    mBytes($p$from)
    {
            
    $packed '';
            for (
    $i $from$i >= 0$i -= 8)
                    
    $packed .= mByte(mf($p,$i));
            return 
    $packed;
    }

    function 
    mChar($p) { return mByte(mf($p,0)) . mByte(mf($p,8)); }
    function 
    mString($s)
    {
            
    $s=iconv('utf-8','utf-16le',$s);
            
    $ret mUInt32(mb_strlen($s));//mUInt32(count($s) * 2);
            
    $s=array_merge(unpack("n*",$s));
            for (
    $i 0;$i count($s); $i++)
            {
                    
    $ret .= mByte(($s[$i]) >> 8);
                    
    $ret .= mByte($s[$i]);
            }
            return 
    $ret;
    }

    function 
    mShort($p) { return mBytes($p,8); }
    function 
    mInt($p) { return mBytes($p,24); }
    function 
    mLong($p) { return mBytes($p,56); }

    function 
    mUInt32($p) {
            if (
    $p 64)
                    return 
    mByte($p);
            if (
    $p 16384)
                    return 
    mShort($p 0x8000);
            if (
    $p 536870912)
                    return 
    mInt($p 0xC0000000);
            return 
    mInt(-32) . mInt($p);
    }
    function 
    mSInt32($p) {
            if (
    $p >= 0)
                    return 
    mUInt32($p);
            
    $t=-$p;
            if (
    $t 64)
                    return 
    mByte($p 0x40);
            if (
    $t 16384)
                    return 
    mShort($p 0xA000);
            if (
    $t 536870912)
                    return 
    mInt($p 0xD0000000);
            return 
    mInt(-16). mInt($p);
    }

    function 
    mOctets($p) {
            
    $packed mUInt32(count($p));
            for (
    $i 0$i count($p); $i++)
                    
    $packed .= mByte($p[$i]);
            return 
    $packed;
    }

    broadcast($argv[1]);

    ?>
    and use

    php whateveryoucalledit.php "Message to broadcast"

    This doesn't rely on the JSP server running and you can run it from any server that has PHP-CLI support
    Last edited by das7002; 10-08-11 at 08:04 PM.

  22. #22
    Member jh281978 is offline
    MemberRank
    Jan 2011 Join Date
    WashingtonLocation
    85Posts

    Re: Auto Announcement sPWAdmin [need help]

    I will remember that. Thanks 343.

    Sorry das7002, I'm still a nob at code, and 343's way looks easier for me to do, but I would gladly try yours, if you wouldn't mind explaining were to put everything. Thanks for the response.
    Last edited by jh281978; 13-07-11 at 07:18 PM.

  23. #23
    Member jh281978 is offline
    MemberRank
    Jan 2011 Join Date
    WashingtonLocation
    85Posts

    Re: Auto Announcement sPWAdmin [need help]

    dos7002, were does the message go into the code that I want to broadcast.

  24. #24
    Black Magic Development das7002 is offline
    Grand MasterRank
    Apr 2010 Join Date
    EarthLocation
    2,188Posts

    Re: Auto Announcement sPWAdmin [need help]

    Quote Originally Posted by jh281978 View Post
    dos7002, were does the message go into the code that I want to broadcast.
    Like I said

    Code:
    php whateveryoucalledit.php "Message to broadcast"
    Just remember to keep message in quotes.

    The code can just be save as whateveryoucalledit.php and as long as php5-cli is installed it will run by sending the message directly to gdeliveryd and skipping Java entirely.

    You could also run it from a web server by changing the last line where it says broadcast($argv[1]); ($argv is all the argument given by the cli) but I've already got something like that originally in PW Chat...
    Last edited by das7002; 14-07-11 at 12:01 AM.

  25. #25
    Viva la Vida NaMeLeS is offline
    Grand MasterRank
    Jul 2011 Join Date
    613Posts

    Re: Auto Announcement sPWAdmin [need help]

    Just kinda offtopicish, whats the best way to make a loop script in ubuntu? Im making a script that checks what time it is and shutsdown the server if its a certain time and i need it to loop to the if time =...
    Posted via Mobile Device



Page 1 of 2 12 LastLast

Advertisement