Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-11-2011, 12:59 AM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
Wink News System

I've noticed that most UC servers are looking for news systems.
Add this to all players and poof you can easily edit the news from the client, within the news system. Also, you can use HTML code so that you can edit your news more cleanly. This is what my news code on Vortex looks like so far.
PHP Code:
<font color yellow> <font size 5> <center> <bWelcome To Vortex! </b> </center> <font size 3><font color black> <br><b8/10 - </b>8/10 Test News 3 <br><b8/10 - </b>Test News 2<br><b8/10 - </b>Test Image: <img src "block.png"> (test news 1
That was just a few tests

Some HTML coding is
PHP Code:
<font color COLOR> (Changes Color)
<
font size =  #> (Changes Size)
<bHi </b> (Makes Hi bold)
<
br> (Skips a line)
<
img src "block.png"> (Would show block.png)
<
img src "http://www.mariowiki.com/images/thumb/f/ff/MvsDK_Toad.jpg/180px-MvsDK_Toad.jpg"> (Would show the link's image)
<center> Middle </center> (Centers the word Middle) 
So, load this up in a weapon, also to edit who can edit the news get to line 122 and add your account to this.can. For all of you new scripters to add something to an array edit the array like this

PHP Code:
this.can = {"FIRST ACCOUNT""SECOND ACCOUNT""THIRD ACCOUNT"}; 
Okay, so here's the script, just load it in to a weapon, and add it to all player. Oh, and you can also toggle its visibility by pressing N.

PHP Code:
function onActionServerSide() {
  if (
params[0] == "getNews") {
    
triggerclient("gui"this.name"returnNews"serverr.news);
  }
  if (
params[0] == "Publish") {
    
serverr.news params[1];
    for (
temp.pallplayers) {
      
p.triggerclient("gui"this.name"NNews");
    }
  }
  if (
params[0] == "reGetNews") {
    
triggerclient("gui"this.name"Editor"serverr.news);
  }
}

//#CLIENTSIDE
function onCreated() {
  
getIt();
}

function 
onKeyPressed(codekeyscancode) {
  if (
key == "N") {
    if (
NNews_Window1.visible == false) {
      
getIt();
    } else {
      
NNews_Window1.hide();
    }
  }
}

function 
getIt() {
  
triggerserver("gui"this.name"getNews");
}

function 
onActionClientSide() {
  if (
params[0] == "returnNews") {
    
openNews(params[1]);
  }
  if (
params[0] == "NNews") {
    
getIt();
  }
  if (
params[0] == "Editor") {
    
openNEditor(params[1]);
  }
}

function 
openNews(newz) {
  
NNews_Window1.show();
  new 
GuiWindowCtrl("NNews_Window1") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "737,343";
    
canmove false;
    
canclose false;
    
canmaximize false;
    
canresize false;
    
closequery false;
    
destroyonhide false;
    
text "News";
    
ScreenWidth 350;
    
ScreenHeight 150;
    new 
GuiButtonCtrl("NNews_Button1") {
      
profile GuiBlueButtonProfile;
      
height 34;
      
text "Close News [N]";
      
width 737;
      
309;
    }
    new 
GuiButtonCtrl("NNews_Button2") {
      
profile GuiBlueButtonProfile;
      
height 34;
      
text "Edit News (Admin Only)";
      
width 737;
      
275;
    }
    new 
GuiScrollCtrl("NNews_MultiLine1_Scroll") {
      
profile GuiBlueScrollProfile;
      
height 231;
      
hscrollbar "dynamic";
      
vscrollbar "dynamic";
      
width 737;
      
34;
      new 
GuiMLTextCtrl("NNews_MultiLine1") {
        
profile GuiBlueMLTextProfile;
        
height 17;
        
horizsizing "width";
        
plaintext "Multi Line Text Field Standard Content";
        
text newz;
        
width 712;
      }
    }
    new 
GuiTextCtrl("NNews_Text1") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Created By Toad";
      
width 111;
      
626;
    }
  }
}

function 
NNews_Button1.onAction() {
  
NNews_Window1.hide();
}

function 
NNews_Button2.onAction() {
  
this.can = {
    
"Graal749201""Graal754954"
  
};
  if (
player.account in this.can) {
    
NNews_Window1.hide();
    
triggerserver("gui"this.name"reGetNews");
    
NNews_Window2.show();
  } else {
    
player.chat "I don't have rights!";
  }
}

function 
openNEditor(newk) {
  new 
GuiWindowCtrl("NNews_Window2") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "860,376";
    
canmove true;
    
canresize false;
    
canmaximize false;
    
canclose false;
    
canminimize false;
    
closequery false;
    
destroyonhide false;
    
text "News Editor";
    
ScreenWidth 400;
    
ScreenHeight 150;
    new 
GuiTextCtrl("NNews_Text2") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "HTML coding is included!";
      
width 162;
      
345;
      
7;
    }
    new 
GuiScrollCtrl("NNews_MultiLineEdit1_Scroll") {
      
profile GuiBlueScrollProfile;
      
height 294;
      
hscrollbar "dynamic";
      
vscrollbar "dynamic";
      
width 860;
      
31;
      new 
GuiMLTextEditCtrl("NNews_MultiLineEdit1") {
        
profile GuiBlueMLTextEditProfile;
        
height 17;
        
horizsizing "width";
        
plaintext newk;
        
text newk;
        
width 835;
      }
    }
    new 
GuiButtonCtrl("NNews_Button3") {
      
profile GuiBlueButtonProfile;
      
height 37;
      
text "Publish News (done)";
      
width 860;
      
339;
    }
  }
}

function 
NNews_Button3.onAction() {
  
NNews_Window2.hide();
  
triggerserver("gui"this.name"Publish"NNews_MultiLineEdit1.getText());

I am also working on updates such as Tabs for like event news, or any other news needed.
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!



Last edited by Astram; 08-11-2011 at 01:16 AM.. Reason: Beautified
Reply With Quote
 


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 +2. The time now is 05:06 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.