Author Topic: Adding 2 requiredments in your if statment???  (Read 694 times)

k so i want to make my script take admin as well so...

here is the code:
Code: [Select]
if (%val)
{
//code
}

so would i add it like?

Code: [Select]
if (%val & %Client.isAdmin)
{
//code
}



More Complex:
Code: [Select]
if((%val && %client.isAdmin) || (!%val && %client.isSuperAdmin) && isObject(%client.player)) {
  %client.player.changeDataBlock(QuakePlayer);
}

More Complex:
Code: [Select]
if((%val && %client.isAdmin) || (!%val && %client.isSuperAdmin) && isObject(%client.player)) {
  %client.player.changeDataBlock(QuakePlayer);
}
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.

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.

It's a terrible example, yes. There should be more brackets in there.

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.

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:
« Last Edit: June 30, 2010, 10:08:57 AM by MegaScientifical »

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: [Select]
moveMap.bind(keyboard, "ctrl m", buttonA);

function buttonA(%val)   
{
if (%val)
{
messageAll('',$Messages::2);
}
}

but for some reason this code doesn't work...

Code: [Select]
moveMap.bind(keyboard, "ctrl m", buttonA);

function buttonA(%val)   
{
if (%val && %Client.isAdmin)
{
messageAll('',$Messages::2);
}
}

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-

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: [Select]
moveMap.bind(keyboard, "ctrl m", buttonA);

function buttonA(%val) {
if (%val)
commandToServer('specMessageAll', $Messages::2);
}

   Server.cs
Code: [Select]
function serverCmdSpecMessageAll(%client, %msg) {
if(%client.isAdmin)
messageAll(%client, %msg);
}

There's many others ways to do it, but that's one way that should work.

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: [Select]
moveMap.bind(keyboard, "ctrl m", buttonA);

function buttonA(%val) {
if (%val)
commandToServer('specMessageAll', $Messages::2);
}

   Server.cs
Code: [Select]
function serverCmdSpecMessageAll(%client, %msg) {
if(%client.isAdmin)
messageAll(%client, %msg);
}

There's many others ways to do it, but that's one way that should work.

thank you! thank you! thank you! thank you! thank you! thank you!