View Single Post
  #2  
Old 05-03-2011, 06:54 PM
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
Issues:

1. You shouldn't have code outside of functions, code placed like that is executed every time an event occurs.
2. You're comparing player.chat to itself, which is effectively the same as doing if (true) which is pointless.
3. player.chat is a variable not a function.
4. The way your loop is setup on the client-side you're sending (playercount+ircbots) triggers to the server which is really bad.
5. Code isn't indented properly.

PHP Code:
//Scripted by Emera. Chat Customizer!
function ActionServerSide() {
  if ( 
params[0] == "chat" ) {
    
player.chat(params[1]); // Issue 3: player.chat is a variable not a function.
  
}
}
//#CLIENTSIDE


function onPlayerChats() {
// Issue 5: Code isn't indented properly.
if (player.chat == player.chat) { // Issue 2: Comparing player.chat to itself, will always evaluate be true.
player.chat "Emera: "@player.chat;
}
}

// Issue 1: Code outside of a function.
for ( temp.allplayers ) { // Issue 4: Will send (playercount + ircbots) amount of triggerservers. You should only need to send one.
  
with (temp.p) {
    
triggerServer"gui"this.name"chat"message );
  }

Re-arranged and fixed issues:

PHP Code:
function ActionServerSide() { 
  if ( 
params[0] == "chat" ) { 
    for (
temp.pallplayers) {
      
with (temp.p) {
        
player.chat params[1];
      }
    }
  } 
}
 
//#CLIENTSIDE

function onPlayerChats() { 
  
triggerserver("gui"this.name"chat"player.chat);

I believe the above is what you were aiming for.
__________________
Quote:

Last edited by fowlplay4; 05-03-2011 at 07:08 PM..
Reply With Quote