Very dumb question
#1

Hi,

I am quite new to scripting and I have a few dumb questions, really. I tried to find but I couldn't. What I ask is for the SIMPLEST way, the EASIEST to do those:

1- "/startfs <filterscript name>" which would send the "SendRconCommand("loadfs <filterscript name");"

( I tried like: SendRconCommand("loadfs %s", ... - but I didn't know how to do it really )

2- "/ann <announcement>" which would send a "SendClientMsgAll (something like that) and then with what the annoucement is"

I'm really new. If you could just tell me how to do these two, it would help me to continue my "wannabe" script.

Thanks.
Reply
#2

I`ll help you with the second problem. Here`s a /announce command, in ZCMD:

pawn Код:
CMD:announce( playerid, params[ ] )
{
    if ( GetAdminLevel( playerid ) < 3 ) // Here you put your admin levels defined.
        return 1;

    new temptext[ 128 ]; // Here we define the first parameter in the command, for like /announce "TEXT" - text is the parameter
    if ( sscanf( params, "s[128]", temptext ) ) // Here we check if there`s any parameter ... if not, it`ll SendClientMessage to admin that uses /announce
        return SendClientMessage( playerid, -1, "Usage: /(ann)ounce  <Text>");

    new String[ 128 ];

    format( String, sizeof String, "Admin announce: %s", temptext ); // Here`s the output of the command. This message we`ll be send to all players
    SendClientMessageToAll( -1, String );
    return 1;
}
CMD:ann( playerid, params[] ) return cmd_announce( playerid,params ); // With this, you can use /ann instead of /announce
About your first problem ... I can`t really help you.
Reply
#3

pawn Код:
CMD:loadfs(playerid,params[])
{
    if(PInfo[playerid][Level] >=5 || IsPlayerAdmin(playerid))
    {
        new fs, string[128];
        if(sscanf(params,"s",fs)) return SendClientMessage(playerid,RED,"Usage: /loadfs [FilterScript Name]");
        else {
            format(string,sizeof(string),"%s",fs);
            SendRconCommand(string);
        }
    }
    else return SendClientMessage(playerid,RED,"You are not a high enough level to use this command");
    return 1;
}
Can't test this as my pawno is fuxed right now.
Reply
#4

Quote:
Originally Posted by antonio112
Посмотреть сообщение
I`ll help you with the second problem. Here`s a /announce command, in ZCMD:

pawn Код:
CMD:announce( playerid, params[ ] )
{
    if ( GetAdminLevel( playerid ) < 3 ) // Here you put your admin levels defined.
        return 1;

    new temptext[ 128 ]; // Here we define the first parameter in the command, for like /announce "TEXT" - text is the parameter
    if ( sscanf( params, "s[128]", temptext ) ) // Here we check if there`s any parameter ... if not, it`ll SendClientMessage to admin that uses /announce
        return SendClientMessage( playerid, -1, "Usage: /(ann)ounce  <Text>");

    new String[ 128 ];

    format( String, sizeof String, "Admin announce: %s", temptext ); // Here`s the output of the command. This message we`ll be send to all players
    SendClientMessageToAll( -1, String );
    return 1;
}
CMD:ann( playerid, params[] ) return cmd_announce( playerid,params ); // With this, you can use /ann instead of /announce
About your first problem ... I can`t really help you.
Just a question: Why "temptext" (or it could be any other names?) and why "128" in String[ 128 ]; ?


But thanks to you both, I'll test that asap.
Reply
#5

Quote:
Originally Posted by anumaz
Посмотреть сообщение
Just a question: Why "temptext" (or it could be any other names?) and why "128" in String[ 128 ]; ?


But thanks to you both, I'll test that asap.
temptext[128];

temptext(which is by the way CAPS SENSITIVE, as any other int/string/variable) can be any other name, he just wanted to use temptext.
Also
[128] is the SIZE of array of temptext.
meaning that temptext can hold up to 128 characters, it goes like:
pawn Код:
0
1
2
3
etc...
The bigger it is, the more size it takes on your disc. And the more the buffering time.
The less the faster, but if you're storing an integer for an example like 199999 and you're using something line integ[3]
It will only be 199.
Good luck!
Reply
#6

pawn Код:
CMD:ann(playerid, params[]) {
    // Replace 'IsPlayerAdmin(playerid)' with a check for your scripts admin levels.
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFF00AA, "You are not an admin or do not retain the sufficient power to execute this command.");

    if(isnull(params)) return SendClientMessage(playerid, 0xFFFF00AA, "Usage: /ann [announcement]");
   
    SendClientMessageToAll(0xFFFF00AA, params);
    return 1;
}

CMD:startfs(playerid, params[]) {
    // Replace 'IsPlayerAdmin(playerid)' with a check for your scripts admin levels.
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFF00AA, "You are not an admin or do not retain the sufficient power to execute this command.");

    if(isnull(params)) return SendClientMessage(playerid, 0xFFFF00AA, "Usage: /startfs [filterscript]");

    new
        szCommand[128]; // Arbitrary size as I'm unsure of the size of your FS names...
       
    format(szCommand, sizeof(szCommand), "loadfs %s", params);
    SendRconCommand(szCommand);
    return 1;
}
Snipa's example won't work - he's parsing the FS name to an integer which just won't work. Here's two (efficient) examples for both of the commands as you requested. You'll need the isnull function.
Reply
#7

Thank you!

Both are working. Now I'll duplicate it so I have "stopfs" and "restartfs"

Thanks!
Reply
#8

Sorry for double post. I need some quick help.

I have the stock for SendClientMessageToAdmins - it works all good.
pawn Код:
stock SendClientMessageToAdmins(color, params[]) {
    for(new i = 0; i < MAX_PLAYERS; i++) {
        if(IsPlayerConnected(i) && GetPVarInt(i, "Level") >= 1) {
            SendClientMessage(i, color, params);
        }
    }
    return 1;
}
Now I'm trying to do this: When someone /startfs <filterscriptname> -> the script itself works, it's just the part of "SendClientMessageToAdmins" that kind of bugs me

pawn Код:
CMD:startfs(playerid, params[]) {
    // Replace 'IsPlayerAdmin(playerid)' with a check for your scripts admin levels.
    if( GetPVarInt( playerid, "Level" ) < 3) return SendClientMessage(playerid, 0xFFFF00AA, "You are not an admin or do not retain the sufficient power to execute this command.");

    if(isnull(params)) return SendClientMessage(playerid, 0xFFFF00AA, "Usage: /startfs [filterscript]");

    new
        szCommand[128]; // Arbitrary size as I'm unsure of the size of your FS names...

    format(szCommand, sizeof(szCommand), "loadfs %s", params);
    SendRconCommand(szCommand);
    new string[128];
    format(string,128,"Ressource '%s' has been started.",params);
    SendClientMessageToAdmins(RED,string);
    return 1;
}
It gives it
Код:
C:\Documents and Settings\Anthony Dupont\Bureau\KrazyParadise\filterscripts\regandadminsystem.pwn(830) : error 035: argument type mismatch (argument 1)
Line 830 is
pawn Код:
SendClientMessageToAdmins(RED,string);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)