Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-27-2011, 01:22 AM
BboyEatsbacon BboyEatsbacon is offline
The Bacon Man
BboyEatsbacon's Avatar
Join Date: Feb 2011
Location: United States
Posts: 60
BboyEatsbacon will become famous soon enough
Mute Script

Hello Everyone! I'm back to post another horrible script and hope for future improvement; today I'm "showing off" a mute script I made awhile back. It's a system based upon client. flags because players are normally only muted for short periods of time.

Weapon -Staff/Mute:
PHP Code:
function onActionServerSide() {
    if (
params[0] == "StaffMutePlayerAccount") {
        
findplayer(params[1]).addweapon("-Muted");
        
findplayer(params[1]).triggerclient("gui"name"SetMutedTimeStaff"params[2]);
        
player.chat "Muted: " params[1];
    }
    if (
params[0] == "StaffMutePlayerCommunity") {
        
findplayerbycommunityname(params[1]).addweapon("-Muted");
        
findplayerbycommunityname(params[1]).triggerclient("gui"name"SetMutedTimeStaff"params[2]);
        
player.chat "Muted: " params[1];
    }
    if (
params[0] == "StaffUnMutePlayerAccount") {
        
findplayer(params[1]).removeweapon("-Muted");
        
findplayer(params[1]).chat "Un-Muted!";
        
player.chat "Un-Muted: " params[1];
    }
    if (
params[0] == "StaffUnMutePlayerCommunity") {
        
findplayerbycommunityname(params[1]).removeweapon("-Muted");
        
findplayerbycommunityname(params[1]).chat "Un-Muted!";
        
player.chat "Un-Muted: " params[1];
    }
}

//#CLIENTSIDE
function onActionClientSide() {
   if (
params[0] == "SetMutedTimeStaff") {
       
player.client.mutedtimeleft params[1];
   }
}

function 
onPlayerChats() {
    if (
clientr.gagright == "1") {
        if (
player.chat.starts("/mute")) {
            if (
player.chat.substring(6).starts("Graal")) {
                
tokens player.chat.tokenize();
                
triggerserver("gui"name"StaffMutePlayerAccount"tokens[1], tokens[2]);
            }
            else {
                
tokens player.chat.tokenize();
                
triggerserver("gui"name"StaffMutePlayerCommunity"tokens[1], tokens[2]);
            }
        }
        if (
player.chat.starts("/unmute")) {
            if (
player.chat.substring(8).starts("Graal")) {
                
tokens player.chat.tokenize();
                
triggerserver("gui"name"StaffUnMutePlayerAccount"tokens[1], tokens[2]);
            }
            else {
                
tokens player.chat.tokenize();
                
triggerserver("gui"name"StaffUnMutePlayerCommunity"tokens[1], tokens[2]);
            }
        }
    }

Weapon -Muted:
PHP Code:
function onActionServerSide() {
    if (
params[0] == "RemoveStaffMute") {
        
player.chat "Un-Muted!";
        
removeweapon(name);
    }
}

//#CLIENTSIDE
function onCreated() {
    
setTimer(1);
    
player.chat "-Muted-";
}

function 
onPlayerChats() {
    
player.chat "-Muted-";
}

function 
onTimeOut() {
    
player.client.mutedtimeleft --;
    if (
player.client.mutedtimeleft <= 0) {
        
triggerserver("gui"name"RemoveStaffMute");
    }
    else {
        
setTimer(1);
    }

I hope I've improved at least a tad bit since my last post; I haven't had much time to focus on scripting due to other server work and school.
__________________

Last edited by BboyEatsbacon; 12-27-2011 at 06:04 AM..
Reply With Quote
  #2  
Old 12-27-2011, 01:55 AM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Tip: Check out the onRemotePlayerChats(playerobject) event
__________________
Reply With Quote
  #3  
Old 12-27-2011, 02:28 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Not a bad start, But why not do something like this?
PHP Code:
function onActionServerSide(){
  if(
params[0] == "Mute"){
    
temp.muted GetPlayer(params[1]);
    
//handle other stuff here
  
}
}
function 
GetPlayer(plyr){
  for(
temp.pl allplayers){
     if(
pl.nick.starts(plyr)){
       
temp.plyr pl;
     } 
  }
}return 
plyr
And just send the players chat of someone's name in the trigger.
Then all you have to do is like /mute Bbo
And if you're name was BboyEatsBacon it would select you.
So for the clientside what I mean is do something like this.
PHP Code:
temp.items player.chat.tokenize();
temp.plyr items[1];
triggerserver("weapon"this.name"Mute"plyr); 
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion

Last edited by Gunderak; 12-27-2011 at 06:02 AM..
Reply With Quote
  #4  
Old 12-27-2011, 03:38 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Gunderak, use temporary variables if they're not used outside the function.
__________________
Reply With Quote
  #5  
Old 12-27-2011, 03:42 AM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Would use
PHP Code:
if (player.client.mutedtimeleft <=0
instead of the == thing. There could always come up a problem and the player won't get unmuted at the correct time.
__________________
MEEP!
Reply With Quote
  #6  
Old 12-27-2011, 03:53 AM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
What all does this mute?

Sword sounds? Microphone? Player chat above head?
Reply With Quote
  #7  
Old 12-27-2011, 06:01 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Quote:
Originally Posted by cbk1994 View Post
Gunderak, use temporary variables if they're not used outside the function.
Oopsie sorry :3
I'll fix it up.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #8  
Old 12-27-2011, 06:04 AM
BboyEatsbacon BboyEatsbacon is offline
The Bacon Man
BboyEatsbacon's Avatar
Join Date: Feb 2011
Location: United States
Posts: 60
BboyEatsbacon will become famous soon enough
Quote:
Originally Posted by scriptless View Post
What all does this mute?

Sword sounds? Microphone? Player chat above head?
It "mutes" the player.chat variable.

Quote:
Originally Posted by callimuc View Post
Would use
PHP Code:
if (player.client.mutedtimeleft <=0
instead of the == thing. There could always come up a problem and the player won't get unmuted at the correct time.
Added. Thanks!
__________________
Reply With Quote
  #9  
Old 12-27-2011, 06:12 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
This thread about 'muting' should help you too (particularly the use of ChatBar.onAction()):
http://forums.graalonline.com/forums...hp?t=134264038

It's also for muting a level with just a level npc.
__________________
Quote:
Reply With Quote
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 +2. The time now is 10:23 AM.


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