Command menu

User Tag List

Thread: Command

Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    BinaryX's Avatar Corporal
    Reputation
    1
    Join Date
    Sep 2010
    Posts
    24
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Command

    Code:
    bbool ChatHandler::HandleGivePointsCommand(const char * args, WorldSession * m_session)
    {
        if(!*args) return false;
    
    	Player* targetPlr = objmgr.GetPlayer(args[0]);
    	if(targetPlr) {
    	targetPlr->mPoints += (int32)args[1];
    	GreenSystemMessage(m_session, "Changed points to %s of player %s.", args[1], args[0]);
    	} else {
    	RedSystemMessage(m_session, "This user (%s) does not exist.", args[0] );
    	return true;
    	}
    	return true;
    	
    }
    Instant crash upon usage.
    Last edited by BinaryX; 09-18-2010 at 07:40 PM.

    Command
  2. #2
    Pharcide's Avatar Member
    Reputation
    18
    Join Date
    Jul 2009
    Posts
    28
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    %u is used on uints, try using %s instead. That's the only problem I see (You could also change (targetPlayer == NULL) to just (!targetPlayer))

  3. #3
    BinaryX's Avatar Corporal
    Reputation
    1
    Join Date
    Sep 2010
    Posts
    24
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks ...

    ---------- Post added at 02:09 AM ---------- Previous post was at 01:45 AM ----------

    Edited first post with new code, still the instant crashing.

  4. #4
    Pharcide's Avatar Member
    Reputation
    18
    Join Date
    Jul 2009
    Posts
    28
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    args is already a char array so you don't have to cast it, and you don't check to see if targetPlr isn't null. You also could get rid of targetPlayer and just use targetPlr. The only other thing I can see is you are dereferencing args in the null check instead of checking the pointer itself (If you're doing that on purpose ignore me)
    Last edited by Pharcide; 09-18-2010 at 07:26 PM.

  5. #5
    BinaryX's Avatar Corporal
    Reputation
    1
    Join Date
    Sep 2010
    Posts
    24
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Updated code again, same problem.

  6. #6
    Pharcide's Avatar Member
    Reputation
    18
    Join Date
    Jul 2009
    Posts
    28
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try changing (!*args) to (!args), I don't think that would cause a crash (unless returning false crashes the world), if that doesn't work I wouldn't think this section of code is the problem (Or I'm blind and missing something obvious)

  7. #7
    BinaryX's Avatar Corporal
    Reputation
    1
    Join Date
    Sep 2010
    Posts
    24
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Uhm i tried to enter a non existant character and it crashed instead of showing me the RedSystemMessage.
    Code:
    { "givepoints",          'z', &ChatHandler::HandleGivePointsCommand,       "",                                                                                                                  NULL, 0, 0, 0 },
    bool HandleGivePointsCommand(const char * args, WorldSession * m_session);
    Code:
    {CLIENT} Packet: (0x0095) CMSG_MESSAGECHAT PacketSize = 35 stamp = 21408656 accountid = 1
    |------------------------------------------------|----------------|
    |00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F |0123456789ABCDEF|
    |------------------------------------------------|----------------|
    |01 00 00 00 07 00 00 00 2E 63 68 61 72 61 63 74 |.........charact|
    |65 72 20 67 69 76 65 70 6F 69 6E 74 73 20 64 61 |er givepoints nonexistant|
    |20 31 00                                        | 1.             |
    -------------------------------------------------------------------

  8. #8
    Zymus's Avatar Active Member
    Reputation
    15
    Join Date
    Sep 2009
    Posts
    87
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:

    Code:
    bool ChatHandler::HandleGivePointsCommand(const char *args, WorldSession *m_session)
    {
    	if(!*args) return false;
    	Player* targetPlr = objmgr.GetPlayer(args[0]);
    	if(!targetPlr)
    	{
    		RedSystemMessage(m_session, "This user (%s) does not exist.", args[0]);
    		return false;
    	}
    	targetPlr->mPoints += (int32) args[1];
    	GreenSystemMessage(m_session, "Changed points to %s of player %s.", args[1], args[0]);
    	return true;
    }

  9. #9
    BinaryX's Avatar Corporal
    Reputation
    1
    Join Date
    Sep 2010
    Posts
    24
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Same result, wtf?

    ---------- Post added at 03:19 AM ---------- Previous post was at 03:05 AM ----------

    Crashdump: http://binaryx.nl/dump-arcemu-world....18-58-6176.rar

    ---------- Post added at 03:23 AM ---------- Previous post was at 03:19 AM ----------

    With the debugger attached this gets printed when the process crashes:
    Code:
    The thread 'Win32 Thread' (0x127c) has exited with code 0 (0x0).
    The thread 'Win32 Thread' (0x2710) has exited with code 0 (0x0).
    First-chance exception at 0x555714cf (msvcr100d.dll) in arcemu-world.exe: 0xC0000005: Access violation reading location 0x0000004c.
    'arcemu-world.exe': Loaded 'C:\Windows\System32\powrprof.dll', Cannot find or open the PDB file
    'arcemu-world.exe': Loaded 'C:\Windows\System32\setupapi.dll', Cannot find or open the PDB file
    'arcemu-world.exe': Loaded 'C:\Windows\System32\cfgmgr32.dll', Cannot find or open the PDB file
    'arcemu-world.exe': Loaded 'C:\Windows\System32\oleaut32.dll', Cannot find or open the PDB file
    'arcemu-world.exe': Loaded 'C:\Windows\System32\ole32.dll', Cannot find or open the PDB file
    'arcemu-world.exe': Loaded 'C:\Windows\System32\devobj.dll', Cannot find or open the PDB file
    'arcemu-world.exe': Unloaded 'C:\Windows\System32\powrprof.dll'
    'arcemu-world.exe': Unloaded 'C:\Windows\System32\setupapi.dll'
    'arcemu-world.exe': Unloaded 'C:\Windows\System32\devobj.dll'
    'arcemu-world.exe': Unloaded 'C:\Windows\System32\oleaut32.dll'
    'arcemu-world.exe': Unloaded 'C:\Windows\System32\ole32.dll'
    'arcemu-world.exe': Unloaded 'C:\Windows\System32\cfgmgr32.dll'
    The thread 'Win32 Thread' (0x18cc) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x1c70) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x1acc) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x14c0) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x18a0) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x7dc) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x1814) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x1c9c) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x1870) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x2634) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x11c0) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x261c) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x79c) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x1e84) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x21e8) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x1fd8) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0xdac) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x1eb8) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x208c) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x20c4) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x210c) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x14e8) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x2480) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x1c8c) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x2570) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0xd14) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x9e4) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x2548) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0xd58) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x17ac) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x9f4) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x27e8) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x1788) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x10d0) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x1ae4) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x1350) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x1ea8) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x844) has exited with code 1 (0x1).
    The thread 'Win32 Thread' (0x1cfc) has exited with code 1 (0x1).
    The program '[9708] arcemu-world.exe: Native' has exited with code 1 (0x1).

  10. #10
    Zymus's Avatar Active Member
    Reputation
    15
    Join Date
    Sep 2009
    Posts
    87
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First-chance exception at 0x555714cf (msvcr100d.dll) in arcemu-world.exe: 0xC0000005: Access violation reading location 0x0000004c

  11. #11
    BinaryX's Avatar Corporal
    Reputation
    1
    Join Date
    Sep 2010
    Posts
    24
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah? what am i supposed to do, i already tried replacing the dll in both the system32 dir and server dir.
    When i just do a SystemMessage in the command, it works fine and doesnt crash so the problem is somewhere in the code.
    Last edited by BinaryX; 09-19-2010 at 04:26 AM.

  12. #12
    Dynashock's Avatar Contributor

    Reputation
    176
    Join Date
    Nov 2007
    Posts
    203
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ehm, args is a c-style string (thus an array) and contains every letter of the arguments in a new element. args[0] won't return the player name but rather the first letter of the player name.

    I'd recommend using sscanf() instead, like:
    Code:
    char pName[20];
    int32 points;
    
    if (sscanf(args, "%s, %d", pName, &points) < 2)
        return false;
    Player * pPlayer = objmgr.GetPlayer((const char*)pName);
    if (pPlayer)
    {
         // do stuff
    }
    Ignorance is bliss.

  13. #13
    BinaryX's Avatar Corporal
    Reputation
    1
    Join Date
    Sep 2010
    Posts
    24
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, now it tells me incorrect syntax and i assume that is because it returns false.
    So sscanf is not returning an value greater than 1.

    ---------- Post added at 12:00 PM ---------- Previous post was at 11:56 AM ----------

    I changed it to:
    Code:
    	if (sscanf(args, "%s, %d", pName, &points) < 1)
    And now the server crashed again.

    ---------- Post added at 12:07 PM ---------- Previous post was at 12:00 PM ----------

    Ok after more debugging, the second argument which is supposed to be points (int32) returns a negative character such as: -8371513.
    This happens everytime even if i enter 5 or 10.

    ---------- Post added at 01:34 PM ---------- Previous post was at 12:07 PM ----------

    bump ..

  14. #14
    Dynashock's Avatar Contributor

    Reputation
    176
    Join Date
    Nov 2007
    Posts
    203
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try changing "%s, %d" to "%s %d" and declaring int32 as int32 = 0; to make sure it's initialized even if sscanf didn't return something to it.
    Ignorance is bliss.

  15. #15
    BinaryX's Avatar Corporal
    Reputation
    1
    Join Date
    Sep 2010
    Posts
    24
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Instant crash, what the ****?
    Code:
    bool ChatHandler::HandleGivePointsCommand(const char *args, WorldSession *m_session)
    {
    	if(!*args) return false;
    
    	char pName[20];
    	int32 points = 0;
    
    	if (sscanf(args, "%s %d", pName, &points) < 1)
    		return false;
    
    	Player * pPlayer = objmgr.GetPlayer(pName);
    
    	if (!pPlayer)
    	{
    		RedSystemMessage(m_session, "This user (%s) does not exist.", pName);
    		return false;
    	}
    	pPlayer->mPoints += points;
    	GreenSystemMessage(m_session, "Changed points to %s of player %s.", points, pName);
    	return true;
    }

Page 1 of 2 12 LastLast

Similar Threads

  1. Whats the command to level up ranks?
    By sabend in forum World of Warcraft General
    Replies: 2
    Last Post: 11-24-2006, 06:45 AM
  2. add a radio command to your server?
    By WoWLegend in forum World of Warcraft General
    Replies: 2
    Last Post: 10-29-2006, 04:43 AM
  3. slash commands
    By alex2630 in forum World of Warcraft Guides
    Replies: 0
    Last Post: 10-25-2006, 12:47 PM
  4. 5 Priest Raiding Commandments
    By Squirllz in forum World of Warcraft Guides
    Replies: 1
    Last Post: 10-11-2006, 07:43 PM
  5. [Guide] Command List
    By oninuva in forum World of Warcraft Guides
    Replies: 5
    Last Post: 05-17-2006, 08:28 PM
All times are GMT -5. The time now is 06:13 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search