First, you never want functions to be inside any if-blocks*. The checks you did for the towntag and the townrank should be inside the function.
PHP Code:
// Scripté par Trakan :D
//#CLIENTSIDE
//Pour Xenos
function onPlayerChats() {
if (clientr.towntag == Xen) {
if (clientr.towntagrank == Guerrier) {
switch (player.chat) {
case "/add": {
player.chat = "Work!";
} else {
player.chat = "not work !";
}
}
}
}
}
The next problem is that strings need to be inside quotations:
PHP Code:
if (clientr.towntag == "Xen") {
if (clientr.towntagrank == "Guerrier") {
You're using the switch statement wrong. I'm going to recommend that you avoid it entirely until you have a better understanding of GScript (in this case I would advise not using it anyway). You can use a standard if statement like this:
PHP Code:
// Scripté par Trakan :D
//#CLIENTSIDE
//Pour Xenos
function onPlayerChats() {
if (clientr.towntag == "Xen") {
if (clientr.towntagrank == "Guerrier") {
if (player.chat == "/add") {
player.chat = "Work!";
} else {
player.chat = "not work !";
}
}
}
}
The problem now is that even though the code is correct, it's logically not right. If the player has towntag of "Xen" and towntagrank of "Guerrier" and says anything except "/add", it will make them say "not work !".
Instead, you want to change it so it checks if the player is saying "/add" before checking their tag and tagrank. I'm also combining the rank and tag check into one statement:
PHP Code:
// Scripté par Trakan :D
//#CLIENTSIDE
//Pour Xenos
function onPlayerChats() {
if (player.chat == "/add") {
if (clientr.towntag == "Xen" && clientr.towntagrank == "Guerrier") {
player.chat = "Work!";
} else {
player.chat = "not work !";
}
}
}
If anything I said doesn't make sense, I'll be happy to explain it further.
* This doesn't apply to anonymous functions, but don't worry about them yet.