AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problem with registering a command. (https://forums.alliedmods.net/showthread.php?t=90303)

nadavafuta 04-16-2009 11:47

Problem with registering a command.
 
I have this function:
Code:

public deleteAllBlocks(id, bool:bNotify)
{
    //make sure player has access to this command
    if (get_user_flags(id) & BM_ADMIN_LEVEL)
    {
        new bool:bDeleted;
        new blockCount = 0;
        new ent = -1;
       
        //find all blocks in the map
        while ((ent = find_ent_by_class(ent, gszBlockClassname)))
        {
            //delete the block
            bDeleted = deleteBlock(ent);
           
            //if block was successfully deleted
            if (bDeleted)
            {
                //increment counter for how many blocks have been deleted
                ++blockCount;
            }
        }
       
        //if some blocks were deleted
        if (blockCount > 0)
        {
            //get players name
            new szName[32];
            get_user_name(id, szName, 32);
           
            //iterate through all players
            for (new i = 1; i <= 32; ++i)
            {
                //make sure nobody is grabbing a block because they've all been deleted!
                gGrabbed[id] = 0;
               
                //make sure player is connected
                if (is_user_connected(i))
                {
                    //notify all admins that the player deleted all the blocks
                    if (bNotify && get_user_flags(i) & BM_ADMIN_LEVEL)
                    {
                        client_print(i, print_chat, "%s'%s' deleted all the blocks from the map. Total blocks: %d", gszPrefix, szName, blockCount);
                    }
                }
            }
        }
    }
}

And I registed it like that:
Code:

register_concmd("amx_bmdelete", "deleteAllBlocks", BM_ADMIN_LEVEL, "This will delete all of the blocks, and only the blocks.");
Now, It does what it is supposed to do, except for the notifying part -
I was guessing what I need to do is change the registration of the command to:
Code:

register_concmd("amx_bmdelete", "deleteAllBlocks(id, true)", BM_ADMIN_LEVEL, "This will delete all of the blocks, and only the blocks.");
so that the if sentence will get bNotify as true,
but It won't let it.

What do I need to do?

Empowers 04-16-2009 11:52

Re: Problem with registering a command.
 
U can't pass parameters thorought cmd funtions:

PHP Code:

register_concmd("amx_bmdelete""deleteAllBlocks"BM_ADMIN_LEVEL"This will delete all of the blocks, and only the blocks."); 

PHP Code:

public deleteAllBlocks(id


nadavafuta 04-16-2009 11:55

Re: Problem with registering a command.
 
But without bNotify, it will notify everytime it is deleted, I don't want it to be notified in here:
Quote:

//if a player is loading then first delete all the old blocks, teleports and timers
if (id > 0 && id <= 32)
{
deleteAllBlocks(id, false);
deleteAllTeleports(id, false);
deleteAllTimers(id, false);
}
What else can I do?

Empowers 04-16-2009 12:11

Re: Problem with registering a command.
 
Quote:

Originally Posted by nadavafuta (Post 806871)
What else can I do?

make Global var

nadavafuta 04-16-2009 12:13

Re: Problem with registering a command.
 
how does it work?
I define it with the same name?
bNotify?
and set it to true?


All times are GMT -4. The time now is 02:18.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.