Blockland Forums > Modification Help
Adding 2 requiredments in your if statment???
Ephialtes:
--- Quote from: Orthone on June 30, 2010, 05:59:38 AM ---If %val is 1, and client is admin OR %val isn't 1 and client is SA AND player is an actual player.. That's a bit confusing.
So either of the first two need to meet the requirement, and the last one needs to. A bit confusing.
--- End quote ---
It's a terrible example, yes. There should be more brackets in there.
MegaScientifical:
--- Quote from: Orthone on June 30, 2010, 05:59:38 AM ---If %val is 1, and client is admin OR %val isn't 1 and client is SA AND player is an actual player.. That's a bit confusing.
So either of the first two need to meet the requirement, and the last one needs to. A bit confusing.
--- End quote ---
Just an example of a compact check instead of a series. It can be confusing, but you just have to read through it and you'll get it at some point.
Also, who wants to learn Switch and Switch$ from MegaScientifical?! :cookieMonster:
tyler0:
ok i need help... i want to make it so when you use the key ctrl m it will send the message to all players...
This code works but i need it to only work if client is admin.
--- Code: ---moveMap.bind(keyboard, "ctrl m", buttonA);
function buttonA(%val)
{
if (%val)
{
messageAll('',$Messages::2);
}
}
--- End code ---
but for some reason this code doesn't work...
--- Code: ---moveMap.bind(keyboard, "ctrl m", buttonA);
function buttonA(%val)
{
if (%val && %Client.isAdmin)
{
messageAll('',$Messages::2);
}
}
--- End code ---
MegaScientifical:
--- Quote from: tyler0 on June 30, 2010, 01:58:46 PM ---ok i need help... i want to make it so when you use the key ctrl m it will send the message to all players...
This code works but i need it to only work if client is admin.
-snip-
but for some reason this code doesn't work...
-snip-
--- End quote ---
That's because %client is never defined. Either way, you're running "messageAll" which can only be run serverside unless you've done some modification. This code should work clientside and also check admin-only.
Client.cs
--- Code: ---moveMap.bind(keyboard, "ctrl m", buttonA);
function buttonA(%val) {
if (%val)
commandToServer('specMessageAll', $Messages::2);
}
--- End code ---
Server.cs
--- Code: ---function serverCmdSpecMessageAll(%client, %msg) {
if(%client.isAdmin)
messageAll(%client, %msg);
}
--- End code ---
There's many others ways to do it, but that's one way that should work.
tyler0:
--- Quote from: MegaScientifical on June 30, 2010, 02:26:32 PM ---That's because %client is never defined. Either way, you're running "messageAll" which can only be run serverside unless you've done some modification. This code should work clientside and also check admin-only.
Client.cs
--- Code: ---moveMap.bind(keyboard, "ctrl m", buttonA);
function buttonA(%val) {
if (%val)
commandToServer('specMessageAll', $Messages::2);
}
--- End code ---
Server.cs
--- Code: ---function serverCmdSpecMessageAll(%client, %msg) {
if(%client.isAdmin)
messageAll(%client, %msg);
}
--- End code ---
There's many others ways to do it, but that's one way that should work.
--- End quote ---
thank you! thank you! thank you! thank you! thank you! thank you!