Raised This Month: $ Target: $400
 0% 

Problem with registering a command.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nadavafuta
Junior Member
Join Date: Oct 2008
Old 04-16-2009 , 11:47   Problem with registering a command.
Reply With Quote #1

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?
nadavafuta is offline
Empowers
BANNED
Join Date: Feb 2009
Location: Ukraine
Old 04-16-2009 , 11:52   Re: Problem with registering a command.
Reply With Quote #2

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
Empowers is offline
Send a message via ICQ to Empowers
nadavafuta
Junior Member
Join Date: Oct 2008
Old 04-16-2009 , 11:55   Re: Problem with registering a command.
Reply With Quote #3

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?
nadavafuta is offline
Empowers
BANNED
Join Date: Feb 2009
Location: Ukraine
Old 04-16-2009 , 12:11   Re: Problem with registering a command.
Reply With Quote #4

Quote:
Originally Posted by nadavafuta View Post
What else can I do?
make Global var
Empowers is offline
Send a message via ICQ to Empowers
nadavafuta
Junior Member
Join Date: Oct 2008
Old 04-16-2009 , 12:13   Re: Problem with registering a command.
Reply With Quote #5

how does it work?
I define it with the same name?
bNotify?
and set it to true?
nadavafuta is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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