Poll

Did you need any of these commands?

Yes
No

Author Topic: Requesting code : Access key.  (Read 1666 times)

1.
Can someone Please give me the console script, used in most private mods, that when you say something in chat it does a command?

Example :

Player says "GetStats"
Console runs command RetrieveStats(Playername); and displays the player's BL_ID, name, score, ETC.

Player says "Omg"
Console makes chat message "wtfbbq."

Player says (number)+(number2)
Console returns, in chat, the sum of the values.



2.
I'm trying to make a database system for one of my mods i'm messing around with,
and it has an error in the storage command.
I think it might be that i'm trying to nest a variable in another variable for the name.
Like so:

Function databaseAdd(%variable,%value) {$(%variable) += %value;}
The error is in the $(%variable).
Pls help!


Ninjedit :
Okay, i need one more thing.
I want to restrict rights to using the command...

It needs to:
Be able to set three levels of access: Read|ReadWrite|EditaccessReadWrite
EditaccessReadWrite must be able to change access level of all other players, and edit the database
ReadWrite must be able to edit the database but not access levels
Read must not be able to edit the database or access levels

So basically, i need variables.

Also, how do i include a text variable in the first command
package chatstuff
{
    function serverCmdMessageSent(%client,%message)
    {
        Parent::serverCmdMessageSent(%client,%message);
        if(%message $= "omg")
            messageAll('','wtfbbq');

    }
};
ActivatePackage(chatstuff);

What if i wanted to have a blank spot in there, where it would allow a numeral?
(Copied from bottom, since nobody will probably scroll all the way down there.)

NINJEDIT II:
Okay, i have teh answers to all that.

1. How do i do the access-code script, told about below by Headcrab Zombie?

2. What's wrong with this script?
Shown like Console, ## on side of error stop.
No matter what i enter in between the "", it always thinks the first " is not supposed to be there.
If i remove the "", it errors the first character.
//Comments not in actual code.

//ATTEMPT 1
if(getSubStr(%message,0,2) $= ##"##CB");

//ATTEMPT 2
if(getSubStr(%message,0,2) $= ##"##*");

//ATTEMPT 3
if(getSubStr(%message,0,2) $= ##C##B);

//ATTEMPT 4
if(getSubStr(%message,0,2) $= ##X##); //I knew in this one that a * would completely break it.
\
Fixed dis.
« Last Edit: August 09, 2010, 01:44:11 PM by ThinkInvisible »

Looks like you're working on something pretty hard. but. Couldn't you do. /getstats %client.somthing = %client.score or.. %client.BL_ID or %client.name stuff like that.

function serverCmdgetstats(%client)
{
     %database.client.name.name = %client.name;
     %database.client.name.BL_ID = %client.BL_ID;
     %database.client.name.score = %client.score;
}

Then have somthing display there variables on a different command. I'm to lazy to type up a example of it. But i'm sure you know what im talking about. Clientgroup etc.


Oh. I do NOT know if %database.client.name will actually work

Oh and. I don't know what te error woould be.
« Last Edit: August 05, 2010, 06:27:34 PM by Honorable »

1.

servercmdWhatThePlayerSaysHere(%client, %word1, %word2, %word3,...%word16){
dostuff
}


Where %client is the client that said it, and %word1-16 is the word they say after (Ex: /dostuff this, this would be %word1)


1.

servercmdWhatThePlayerSaysHere(%client, %word1, %word2, %word3,...%word16){
dostuff
}


Where %client is the client that said it, and %word1-16 is the word they say after (Ex: /dostuff this, this would be %word1)



That's for a slash command.
I need the one where you just say something with no symbols before it.

package chatstuff
{
    function serverCmdMessageSent(%client,%message)
    {
        Parent::serverCmdMessageSent(%client,%message);
        if(%message $= "omg")
            messageAll('','wtfbbq');

    }
};
ActivatePackage(chatstuff);


package chatstuff
{
    function serverCmdMessageSent(%client,%message)
    {
        Parent::serverCmdMessageSent(%client,%message);
        if(%message $= "omg")
            messageAll('','wtfbbq');

    }
};
ActivatePackage(chatstuff);
-snip-
Blablablaarrayblablabla
Thank you. So. Much.
But i don't think i need a package, if it's in an add-on...

Thank you. So. Much.
But i don't think i need a package, if it's in an add-on...

Yes you do.

Unless you want it breaking everything else that uses that function.

A package is a way of adding a block of code before or after the original function instead of completely rewriting it.
In this example, the unmodified code is called by Parent::serverCmdMessageSent(%client,%message); before the added code is run.

As for your second problem, there's a few ways you could do it.
Either an array
$Database[%variable] += %value;

Or eval
eval("$" @ %variable @ "+=" @ %value);
Not very good with eval since I 've only used it in an add-on a few times, so I'm not sure if that would work.
I'd recommend just using an array anyways, it's easier
« Last Edit: August 05, 2010, 06:34:30 PM by Headcrab Zombie »

Okay, i need one more thing.
I want to restrict rights to using the command...

It needs to:
Be able to set three levels of access: Read|ReadWrite|EditaccessReadWrite
EditaccessReadWrite must be able to change access level of all other players, and edit the database
ReadWrite must be able to edit the database but not access levels
Read must not be able to edit the database or access levels

So basically, i need variables.

Also, how do i include a text variable in the first command
package chatstuff
{
    function serverCmdMessageSent(%client,%message)
    {
        Parent::serverCmdMessageSent(%client,%message);
        if(%message $= "omg")
            messageAll('','wtfbbq');

    }
};
ActivatePackage(chatstuff);

What if i wanted to have a blank spot in there, where it would allow a numeral?
« Last Edit: August 05, 2010, 06:40:45 PM by ThinkInvisible »

1. Just make a setAccess command that checks if the user can setAccess, and make the database edit commands check for access levels.
Right now I'm just taking a breakbeing distracted from writing a paper and I don't want to be too distracted by writing more than a few lines of script

I don't think I quite understand what you mean.
Like "omg 1" doing something different than "omg 2"?

1. Just make a setAccess command that checks if the user can setAccess, and make the database edit commands check for access levels.
Right now I'm just taking a breakbeing distracted from writing a paper and I don't want to be too distracted by writing more than a few lines of script

I don't think I quite understand what you mean.
Like "omg 1" doing something different than "omg 2"?
No...
Like "1 + 2" making it say 3, and "1 + 64" making it say 65.
Or like "omg 1" saying "WTFBBQ1" and "omg 2" saying "WTFBBQ2"

Simple variable-result system.

"setAccess command that checks if the user can setAccess, and make the database edit commands check for access levels." Er, how2?
« Last Edit: August 05, 2010, 06:54:20 PM by ThinkInvisible »

Or like "omg 1" saying "WTFBBQ1" and "omg 2" saying "WTFBBQ2"

if(getSubStr(%message,0,3) $= "omg")
{
    %num = getSubStr(%message,4,10);
    switch(%num)
    {
        case 1:
            messageAll('','WTFBBQ1');
        case 2:
            messageAll('','WTFBBQ2');
        case 3:
            messageAll('','WTFBBQ3');   
    }
}


Like "1 + 2" making it say 3, and "1 + 64" making it say 65.
I had something like this long ago, something with eval

how2?
I don't want to be too distracted by writing more than a few lines of script

@HCZ:
Your code there doesn't work, first line is error'd.
EDIT - Never mind, got this working.

And i have no idea about the access key thing.
« Last Edit: August 07, 2010, 08:53:31 PM by ThinkInvisible »


Works fine for me
Once again, i got it working now.

I still really want to know how to do access key.