User Tag List

Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 8 to 14 of 17

Thread: Command Timer

  1. #8
    Mad Scientist <span style='color: #008000'><span class='glow_006400'>slp13at420</span></span>'s Avatar



    Join Date
    Dec 2013
    Location
    Idaho
    Posts
    2,480
    XP
    20,134,655
    Level
    500
    Thanks
    1,086
    Thanked 329 Times in 211 Posts
    Ok , cooking something up.

    here is an example of a command function . this does work but I would integrate it into your VIP system. So I tried to mark off blocks that should belong some where better.

    Code:
    
    // This block belongs at the start of the script.
    // Frome HERE //
    struct VIPTimerElements
    {
    	uint64 test_time;
    };
    
    std::unordered_map<uint32, VIPTimerElements>VipTimers;
    // To HERE //
    
    	static bool HandleVIPTestCommand(ChatHandler* handler, const char* args)
    	{
    		Player* player = handler->GetSession()->GetPlayer();
    		uint32 account_id = handler->GetSession()->GetAccountId();
    
    		uint64 current_test_time = sWorld->GetGameTime(); // seconds
    		uint64 VIPTest_Cooldown = 30; // seconds // make this just a local variable for the function or make it a global variable that can be called from any script.
    
    	// this next block I will have marked off should be in an OnLogin event of a player function
    	// From HERE //
    		QueryResult timer_result = LoginDatabase.PQuery("SELECT `KickCooldown` FROM `auth`.`account_access` where `id`=%d;", account_id);
    
    			if (timer_result)
    			{
    				Field* field = timer_result->Fetch();
    				uint32 test_time = field[0].GetUInt64(); // Value in the DB (Currently what they have)
    
    				VIPTimerElements& timers_data = VipTimers[account_id];
    				// Save the DB values to the MyData object
    				timers_data.test_time = test_time;
    			}
    	// To HERE //
    	
    	// this block can be a stand alone function you can call from other functions `uint64 CheckTimer(ChatHandler* handler){};` or use it as part of the command function
    	// From HERE //
    			handler->PSendSysMessage("Times:%d, %d, %d.", current_test_time, VipTimers[account_id].test_time, VIPTest_Cooldown);
    
    			if ((current_test_time < (VipTimers[account_id].test_time + VIPTest_Cooldown)))			{
    				// This result means he has a cooldown and cannot use
    
    				handler->PSendSysMessage("Timer active.");
    				handler->PSendSysMessage("Time left:%d, %d.", current_test_time, (VipTimers[account_id].test_time + VIPTest_Cooldown));
    			}
    			else
    			{
    				// This result means he has no cooldown and is free to use
    				// so do stuff
    
    				handler->PSendSysMessage("Timer expired.");
    
    				VipTimers[account_id].test_time = current_test_time;
    
    				LoginDatabase.PExecute("UPDATE `account_access` SET `KickCooldown` = '%d' WHERE `id` = '%d';", VipTimers[account_id].test_time, account_id);
    			}
    	// To HERE //
    		return true;
    	}
    
    I wrote and tested it inside another script but renamed it to be more understandable for your VIP System.

    https://github.com/BlackWolfsDen/mis...heckerDemo.cpp
    Last edited by slp13at420; 09-15-2016 at 01:38 AM.
    Achievements:
    Shopper Got a Sticky! Member 1 year registered Level XL Level D
    Awards:
    Pot Head LOL Raffle Winner Top Tagger Donator Hangman Scripter Repacker Drunk Support Member of Staff Da Bomb!
    "Cuz PvP's better with a bag 'o' weed"
    !! King Spade !!

    -Guild Plot System-
    Grumbo'z Guild Warz


    -VIP System-
    Grumbo'z VIP System

  2. #9
    Original Poster
    Sexy Member
    Join Date
    Jun 2014
    Location
    United State
    Posts
    81
    XP
    9,503
    Level
    29
    Thanks
    11
    Thanked 5 Times in 5 Posts
    I spent countless hours fiddling with the code you gave me, sometimes it partially worked, sometimes it crashed, sometimes it gave errors.

    But in the end, doesn't this work too?


    The only thing is, I can't make it display the correct time variables.
    Also the PExecute Variable of "LoginDatabase.PExecute("UPDATE `account_access` SET `KickCooldown` = '%d' WHERE `id` = '%d';", cooldown, account_id);"
    I could be wrong with using "cooldown" instead, maybe it should be: "KickTimer[account_id].time" or "KickTimer[account_id].time - cooldown" ??

    There is so many combinations with these integers it drives my mind up a solid black wall.

    In-game result (helpful ?? ):
    *Screenshot was Approximately 2 minutes after using the command*
    Last edited by Visa; 09-15-2016 at 05:11 AM.

  3. #10
    Original Poster
    Sexy Member
    Join Date
    Jun 2014
    Location
    United State
    Posts
    81
    XP
    9,503
    Level
    29
    Thanks
    11
    Thanked 5 Times in 5 Posts
    http://pastebin.com/AqNd5PfR -- Full Script. --(Updated)--

    Current In-game Results:

    When KickCooldown column is 0: "Successful Kick :: Cooldown initated."
    When KickCooldown is 3600 or any number that is not 0: "Remaining Cooldown: 0s"

    Problem: The cooldown doesn't count down.. It stays the same number in the database.
    Problem: After you use the command, and manually set KickCooldown column back to 0 and try to use it again, it says "Remaining Cooldown: 0s" still.
    Last edited by Visa; 09-16-2016 at 08:51 PM.

  4. #11
    Mad Scientist <span style='color: #008000'><span class='glow_006400'>slp13at420</span></span>'s Avatar



    Join Date
    Dec 2013
    Location
    Idaho
    Posts
    2,480
    XP
    20,134,655
    Level
    500
    Thanks
    1,086
    Thanked 329 Times in 211 Posts
    Don't delete that pastebin. I will fix it Friday evening.
    Achievements:
    Shopper Got a Sticky! Member 1 year registered Level XL Level D
    Awards:
    Pot Head LOL Raffle Winner Top Tagger Donator Hangman Scripter Repacker Drunk Support Member of Staff Da Bomb!
    "Cuz PvP's better with a bag 'o' weed"
    !! King Spade !!

    -Guild Plot System-
    Grumbo'z Guild Warz


    -VIP System-
    Grumbo'z VIP System

  5. #12
    Mad Scientist <span style='color: #008000'><span class='glow_006400'>slp13at420</span></span>'s Avatar



    Join Date
    Dec 2013
    Location
    Idaho
    Posts
    2,480
    XP
    20,134,655
    Level
    500
    Thanks
    1,086
    Thanked 329 Times in 211 Posts
    https://github.com/BlackWolfsDen/mis...mmand_Demo.cpp

    This is setup so it loads the stored time from the sql db upon player login to an unordered_map.
    Then upon using the command it checks if that timer expired.
    then executes the rest depending on if the timer has expired.
    if the timer has expired then it will kick the target player and update the unordered_map and forwards data to a function to handle updating the sql db.
    when the player logs out it will erase that players unordered_map to free up ram.

    I also updated it with the `npc info` command you asked about.
    `.vip npc info` will display an npc's respawn time total and remaining.
    Last edited by slp13at420; 09-18-2016 at 04:15 PM.
    Achievements:
    Shopper Got a Sticky! Member 1 year registered Level XL Level D
    Awards:
    Pot Head LOL Raffle Winner Top Tagger Donator Hangman Scripter Repacker Drunk Support Member of Staff Da Bomb!
    "Cuz PvP's better with a bag 'o' weed"
    !! King Spade !!

    -Guild Plot System-
    Grumbo'z Guild Warz


    -VIP System-
    Grumbo'z VIP System

  6. #13
    Original Poster
    Sexy Member
    Join Date
    Jun 2014
    Location
    United State
    Posts
    81
    XP
    9,503
    Level
    29
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Everything is working perfectly. Thank you so so much

  7. The Following User Says Thank You to Visa For This Useful Post:


  8. #14
    Super Moderator <span style='color: #FFFF00'><span class='glow_000000'>Kaev</span></span>'s Avatar

    Join Date
    Jan 2014
    Location
    Germany
    Posts
    535
    XP
    2,925,321
    Level
    335
    Thanks
    76
    Thanked 102 Times in 70 Posts
    Just my opinion about such a function: Players can and will abuse such a function. Nearly losing in arena? Kick that asshat! He's ganking me while i'm leveling? Bye! I know he's in the middle of a hard raid boss? Would be a shame if he would get kicked..
    Even if you tell them that they will get banned for abusing this - They will abuse it sooner or later and fuck up someones day - which will end in one player less on your server each time. Never implement something like that, trust me.
    Achievements:
    Shopper Member 1 year registered Level XL Level C
    Awards:
    Raffle Winner Member of Staff Support LOL Drunk Donator


    Read the rules before posting.

    Do you have an unsolved issue? Give us more informations about your problem.

    Do you have problems with compiling or installing TrinityCore? Unknown96's Tutorial will help you.

    Visit our other helpful sites:
    EmuDevs SQL Generator

  9. The Following 2 Users Say Thank You to Kaev For This Useful Post:


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •