![]() |
Chat System
2 Attachment(s)
New and improved!
It allows you to press C and chat to other players on the server. Add whoever's account into this.admins to make their name red. Script is attached, simply ulpoad as a weapon and add to whomever you wish to have it. Features 1. Click W to toggle a list of online players using chat, Press R to refresh the list. 2. Automatically detects HTML and disallows it. To come A right click on player with ban, kick, etc etc for admins. -Enjoy |
You're still making the basic mistake of having multiple instances of if(condition){} occurring when a previous condition has already been established as true.
It's also a bad idea to store staff accounts clientside this way as it can be modified via a memory editor, this really needs to be validated serverside. I'm sure you've already been told about these 2 issues about a dozen times already. |
You should remove the HTML serverside, anyone could still easily send HTML simply by disabling that check on clientside. Same thing goes for admins. The receiver should determine if the sender is an admin. The sender should never tell other people it's an admin since it's not trusted.
Why are you using four triggers to get the online list (which, by the way, is available clientside in allplayers)? Two triggers would work fine. You're also relying on the this. variable to remain unchanged in between the triggers which in this case won't cause problems but is a little naive. You shouldn't treat booleans as integers (e.g. line 32), this is confusing to the reader although not really a performance issue. Why is the player sending their own name with the send message trigger? This is easily faked. I could make it look like any player was sending a message if I wanted to. On line 138 you forgot to close the <font> tag for the admin color and for the message. If you closed the admin color one, you wouldn't need to specify the color as white. This should have hinted you in on the error. You should name related GUI controls with a similar prefix (e.g. everything should start with Chat_). You're also using a weird mixture of width, height, extent, and clientextent. You should always use client, and pick either extent or width/height and stick with it throughout the script. I prefer width/height but others prefer extent. Why can't I send a message starting with a space? Shouldn't it just trim my message for me? That's all I noticed on first read through. Please stop posting in the code gallery until you can produce scripts without blatant errors like these ones. They're bad examples for others. I've brought this up before. |
Quote:
Thus pointless to close it. I will fix the account check now and re post. Update I have changed the script around. Are there still problems with it anywhere? |
Quote:
Yes, most of the issues I'd originally pointed out still exist, like not allowing text starting with a space rather than just trimming it, the use of four triggers when none (at most, two) are needed, the misuse of integers, the mixing of extent/width/height/clientextent, the bad naming of GUI controls, etc. I wouldn't be so tough on you if you stopped ignoring advice. This does not belong in the code gallery. |
I'm not ignoring advice, I am trying to correct the errors.
|
Imagine you were to lose something, for example a pair of keys.
Now imagine you spend a couple of minutes searching for them, then you manage to find them. Would you then continue searching for them after you've found them? Ofcourse not, that would be absurd. Checking conditions after a condition has already been established may not have any real effect on performance in this instance, but it makes just as little sense. |
Are you talking about the serverside and clientside checks?
For triggering things? |
Quote:
PHP Code:
If the parameter is something, there is then no need to check if it is somethingelse. You should either use a switch statement or a return; within the bracket. |
Ah ok, I will make it a switch / case then.
Thanks. |
Quote:
|
Whats the difference between if and elseif o.o
They do the exact same thing.. |
Quote:
PHP Code:
Like talking english. |
Quote:
PHP Code:
|
Quote:
PHP Code:
PHP Code:
But seriously, why are we wasting our time on this kid? He clearly has no desire to learn and is stubborn as ****, is he worth any of our time? When I had people teaching me, I literally salivated over the **** they were saying, because I knew they were better than me and they knew what they were doing. Now the table's have turned and I hate seeing idiots like this. |
I think the design of the system is really quite nice! Good work with the design.
|
@Emera, Thanks, at least I have done something right o_o
@Hezzy Lol, Kid? I'm 23. And I'm not an idiot, I am just simply asking why it is necessary to do it so I can learn more. |
Quote:
|
I have to admin you just owned me....
But regardless, I am trying to become better but all I did was ask why it's better to do it that way so that I know, I'm trying to learn as much as I can. And a Merry Christmas and a Happy New Year to you too. |
Quote:
Quote:
|
Ah, have been playing around with this.
It goes a little buggy with an if statement after an else. So would it be better to do an else if statement in this situation? |
| All times are GMT +2. The time now is 04:05 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.