Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Mute Script (https://forums.graalonline.com/forums/showthread.php?t=134265421)

BboyEatsbacon 12-27-2011 01:22 AM

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.

Chompy 12-27-2011 01:55 AM

Tip: Check out the onRemotePlayerChats(playerobject) event ^^

Gunderak 12-27-2011 02:28 AM

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); 


cbk1994 12-27-2011 03:38 AM

Gunderak, use temporary variables if they're not used outside the function.

callimuc 12-27-2011 03:42 AM

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.

scriptless 12-27-2011 03:53 AM

What all does this mute?

Sword sounds? Microphone? Player chat above head?

Gunderak 12-27-2011 06:01 AM

Quote:

Originally Posted by cbk1994 (Post 1679605)
Gunderak, use temporary variables if they're not used outside the function.

Oopsie sorry :3
I'll fix it up.

BboyEatsbacon 12-27-2011 06:04 AM

Quote:

Originally Posted by scriptless (Post 1679607)
What all does this mute?

Sword sounds? Microphone? Player chat above head?

It "mutes" the player.chat variable.

Quote:

Originally Posted by callimuc (Post 1679606)
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!

fowlplay4 12-27-2011 06:12 AM

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.


All times are GMT +2. The time now is 05:31 AM.

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