Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Elite User TheSpidey's Avatar
    Reputation
    365
    Join Date
    Jan 2008
    Posts
    2,201
    CoreCoins
    0

    Trade Feedbacks

    Status
    n/a
    Positive
    0 (0%)
    Negative
    0 (0%)

    [C++] Friend Porter



    Donate to Remove Ads, Get ShoutBawx - Elite Forum Access
    Friend Porter

    Description:
    This gossip script lets players teleport to other players for a set amount of gold. When they use this item, a text box shows up, in which they input the name of the player they wish to port to. Then, if the rules allow it, they will port to his location.

    This is the script you've seen in countless repacks and servers.

    Code:
    /*
     * Friend Porter
     * Copyright (C) 2008 Spidey <http://www.aspiredev.org/>
     *
     * This program is free software: you can redistribute it and/or modify
     * it under the terms of the GNU Affero General Public License as published by
     * the Free Software Foundation, either version 3 of the License, or
     * any later version.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU Affero General Public License for more details.
     *
     * You should have received a copy of the GNU Affero General Public License
     * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     *
     */
    
    #include "StdAfx.h"
    #include "Setup.h"
    
    // This determines the cost of the port in copper
    #define FRIENDCOST 100000
    // The ID of the item used
    #define FRIENDPORTID 61000
    
    #define FP_ERR(s)\
    			Plr->BroadcastMessage(s);\
    			Plr->Gossip_Complete();\
    			return;
    
    class SCRIPT_DECL FriendGrab : public GossipScript
    {
    public:
    	void GossipHello(Object * pObject, Player* Plr, bool AutoSend);
    	void GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code);
    	void GossipEnd(Object * pObject, Player* Plr);
    	void Destroy()
    	{
    		delete this;
    	}
    };
    
    void FriendGrab::GossipHello(Object * pObject, Player* Plr, bool AutoSend)
    {
    	if(Plr->GetUInt32Value(PLAYER_FIELD_COINAGE) < FRIENDCOST)
    	{
    		Plr->BroadcastMessage("You don't have enough gold to teleport to another player.");
    		return;
    	}
    	GossipMenu *Menu;
        objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);
    	Menu->AddItem(1, "Teleport to friend", 1, 1);
    	//Note:
    	// When menus have only one item, the one item gets auto-picked;
    	// The text "Teleport to friend" will not show up ingame unless you add at least one other item.
    	// Instead, the item will automatically pop the code request window.
    	
        if(AutoSend)
            Menu->SendTo(Plr);
    }
    
    void FriendGrab::GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
    {
        switch(IntId)
        {
    		case 0:
    		{
    			GossipHello(pObject, Plr, true);
    		}break;
    		case 1:
    		{
    			if(!Code)
    				return;
    				
    			if(Plr->GetUInt32Value(PLAYER_FIELD_COINAGE) < FRIENDCOST)
    				return;
    
    			Player * pTarget = objmgr.GetPlayer(Code, false);
    			if(!pTarget)
    				FP_ERR("Player does not exist or is offline.");
    			
    			if(pTarget->GetSession()->HasGMPermissions())
    				FP_ERR("Player does not exist or is offline."); //As to not expose GMs
    			
    			if(Plr->CombatStatus.IsInCombat())
    				FP_ERR("You cannot teleport while in combat.");
    			
    			if(Plr->HasFlag(PLAYER_FLAGS, PLAYER_FLAG_FREE_FOR_ALL_PVP))
    				FP_ERR("You can't port while in a PvP zone.");
    			
    			if(pTarget->GetTeam() != Plr->GetTeam())
    				FP_ERR("Player is from the opposing faction.");
    
    			if(pTarget->CombatStatus.IsInCombat())
    				FP_ERR("Your friend is in combat, you cannot teleport to him now.");
    
    			if(pTarget->HasFlag(PLAYER_FLAGS, PLAYER_FLAG_FREE_FOR_ALL_PVP))
    				FP_ERR("You can't port to a player in a PvP zone.");
    			
    			uint32 pMap = pTarget->GetMapId();
    			if(pMap != 0 && pMap != 1 && pMap != 530) //Assume that all other maps are instances
    				FP_ERR("Cannot port to a player inside an instance");
    			
    			//if we reached so far, the player can port
    			Plr->SetUInt32Value(PLAYER_FIELD_COINAGE, Plr->GetUInt32Value(PLAYER_FIELD_COINAGE)-FRIENDCOST);
    			float pX = pTarget->GetPositionX();
    			float pY = pTarget->GetPositionY();
    			float pZ = pTarget->GetPositionZ();
    			float pO = pTarget->GetOrientation();
    			Plr->Gossip_Complete();
    			pTarget->BroadcastMessage("%s is porting to your location.", Plr->GetName());
    			Plr->EventTeleport(pMap, pX, pY, pZ);
    			Plr->SetOrientation(pO);
    		}break;
        }
    };
    
    void FriendGrab::GossipEnd(Object * pObject, Player* Plr)
    {
    	GossipScript::GossipEnd(pObject, Plr);
    }
    
    void SetupFriendPorter(ScriptMgr * mgr)
    {
    	GossipScript * gs = (GossipScript*) new FriendGrab();
    	mgr->register_item_gossip_script(FRIENDPORTID, gs);
    }

  2. #2
    Innovation & Emulation My CoreCoins User Title

    stoneharry's Avatar
    Reputation
    1340
    Join Date
    Sep 2007
    Location
    Great Britain
    Posts
    4,065
    CoreCoins
    176

    Trade Feedbacks

    Status
    n/a
    Positive
    0 (0%)
    Negative
    0 (0%)
    Just a couple of questions, if the friend is in a instance, you cant normaly teleport to them unless your in there group. Will it still charge you after failing to get in?
    Also can the other player stop the person appearing at there location if it's anoying them?
    Apart from that looks very nice I might use it, +Rep

    Edit: 24 hour cooldown Will rep tommoro
    Last edited by stoneharry; 11-01-2008 at 06:19 PM.

  3. #3
    Banned
    Reputation
    195
    Join Date
    Aug 2008
    Location
    Goldshire Inn
    Posts
    885
    CoreCoins
    0

    Trade Feedbacks

    Status
    n/a
    Positive
    0 (0%)
    Negative
    0 (0%)
    nice TheSpidey, would love to try it sometime.

  4. #4
    Elite User TheSpidey's Avatar
    Reputation
    365
    Join Date
    Jan 2008
    Posts
    2,201
    CoreCoins
    0

    Trade Feedbacks

    Status
    n/a
    Positive
    0 (0%)
    Negative
    0 (0%)
    Quote Originally Posted by stoneharry View Post
    Just a couple of questions, if the friend is in a instance, you cant normaly teleport to them unless your in there group. Will it still charge you after failing to get in?
    Also can the other player stop the person appearing at there location if it's anoying them?
    Apart from that looks very nice I might use it, +Rep

    Edit: 24 hour cooldown Will rep tommoro
    If, for any reason stated above, you're not able to teleport to your friend, you will not be charged.

    The target player cannot stop the teleporting player in this version.

  5. #5
    Contributor AzolexX's Avatar
    Reputation
    178
    Join Date
    May 2007
    Location
    Serbia
    Posts
    587
    CoreCoins
    7

    Trade Feedbacks

    Status
    n/a
    Positive
    0 (0%)
    Negative
    0 (0%)
    +REPx2 man Good job! BTW Unban me from irc lol. (hasbrowow)

    Find about scripting, programming and music! My blog: http://worldofsmth.wordpress.com!

  6. #6
    Sergeant Major EmuX's Avatar
    Reputation
    29
    Join Date
    Feb 2008
    Posts
    172
    CoreCoins
    0

    Trade Feedbacks

    Status
    n/a
    Positive
    0 (0%)
    Negative
    0 (0%)
    Didn't gastric make this?

  7. #7
    Elite User TheSpidey's Avatar
    Reputation
    365
    Join Date
    Jan 2008
    Posts
    2,201
    CoreCoins
    0

    Trade Feedbacks

    Status
    n/a
    Positive
    0 (0%)
    Negative
    0 (0%)
    Nope. I did

  8. #8
    Knight-Lieutenant
    Reputation
    19
    Join Date
    Jun 2008
    Location
    Boston,MA
    Posts
    375
    CoreCoins
    0

    Trade Feedbacks

    Status
    n/a
    Positive
    0 (0%)
    Negative
    0 (0%)
    what should the item be like can it be anything?

  9. #9
    New User

    Reputation
    2
    Join Date
    Nov 2008
    Posts
    25
    CoreCoins
    0

    Trade Feedbacks

    Status
    n/a
    Positive
    0 (0%)
    Negative
    0 (0%)
    Great release spidey! I'm sure this will help out alot of players on my server.

  10. #10
    Knight-Lieutenant
    Reputation
    19
    Join Date
    Jun 2008
    Location
    Boston,MA
    Posts
    375
    CoreCoins
    0

    Trade Feedbacks

    Status
    n/a
    Positive
    0 (0%)
    Negative
    0 (0%)
    Spidey what should the item be like? i know the id is 61000 and i made an item but its not working, and when i load the dll it loads.... Could you put the sql here for us?

  11. #11
    Master Sergeant
    Chuck Norris's Avatar
    Reputation
    32
    Join Date
    Oct 2007
    Posts
    134
    CoreCoins
    0

    Trade Feedbacks

    Status
    n/a
    Positive
    0 (0%)
    Negative
    0 (0%)
    Google won't search for Chuck Norris because it knows you don't find Chuck Norris, he finds you.

  12. #12
    Knight-Lieutenant
    Reputation
    19
    Join Date
    Jun 2008
    Location
    Boston,MA
    Posts
    375
    CoreCoins
    0

    Trade Feedbacks

    Status
    n/a
    Positive
    0 (0%)
    Negative
    0 (0%)
    What should the sql be? could you post it?

  13. #13
    New User

    Reputation
    1
    Join Date
    Jun 2008
    Posts
    13
    CoreCoins
    0

    Trade Feedbacks

    Status
    n/a
    Positive
    0 (0%)
    Negative
    0 (0%)
    edit now my Friend Porter work you are great
    Last edited by XXXJOGIXXX; 01-09-2009 at 04:19 PM.

  14. #14
    Knight-Lieutenant
    Reputation
    19
    Join Date
    Jun 2008
    Location
    Boston,MA
    Posts
    375
    CoreCoins
    0

    Trade Feedbacks

    Status
    n/a
    Positive
    0 (0%)
    Negative
    0 (0%)
    So my question still isnt answered! what should the sql be, because i add the item to my bag and it doesnt work. But the DLL loads

  15. #15
    Banned
    Reputation
    234
    Join Date
    Jun 2008
    Location
    Emulator Expert DK
    Posts
    660
    CoreCoins
    0

    Trade Feedbacks

    Status
    n/a
    Positive
    0 (0%)
    Negative
    0 (0%)
    insert into `items` values ('61000','15','0','-1','Friendport Token','Trade this Token to Teleport a friend at our Friendporter NPC','','','41565','2','0','0','0','0','-1','-1','1','0','0','0','0','0','0','0','0','0','100','0','0','0','0','0','0','0','0' ,'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0' ,'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0' ,'0','0','0','-1','0','-1','0','0','0','-1','0','-1','0','0','0','-1','0','-1','0','0','0','-1','0','-1','0','0','0','-1','0','-1','1','Trade this token for teleporting a friend','0','0','0','0','0','-1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','-1','0','0');

    Darksid, try this one

    Nice done spider +rep

 

 
Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -4. The time now is 02:30 PM. Powered by vBulletin® Version 4.2.0
Copyright © 2014 vBulletin Solutions, Inc. All rights reserved. Digital Point modules: Sphinx-based search