Sending everyone 1 item?

Status
Not open for further replies.
Joined
Oct 28, 2010
Messages
888
Reaction score
115
Hi guys, on my server today something sprung to mind.

How would I send an item, say Fireworks to every character on the server.

I just want to know how I would go about doing that sort of thing, maybe it is in the Lua functions in-game? Or maybe its to do with the database? I don't know.

If someone has the Answers please let me know.

Thanks a lot guys! :D
 
Look at spikenbror's BillingAPI. Make it work to whatever you want to do it with.

From the top of my head:

PHP:
<?php
// Include the API.
include("./api/procedural.php");

// Create a connection to MsSQL and select the character database.
$mssql_socket = mssql_connect("SQL Server", "Username", "Password", false);
mssql_select_db("CHARACTER_01_DBF", $mssql_socket);

// Create an array of items.
$adbill_objects = array();

//Get MsSQL account names of who's online
//Send an item to every character on account(If no other way to figure out /which/ character is on)?
//run a while() and insert a new element for each PLAYER ID
//$adbill_objects[] = billing_create_item(01, {PLAYER_ID}, {ITEM_ID}, {Quantity});

// Send items.
billing_send_items("127.0.0.1", $mssql_socket, $adbill_objects);

// Close MsSQL connection.
mssql_close($mssql_socket);
?>
 
Thanks for the reply's guys. I dont mind it being web-based or Client based just as long as I can do it haha. I've taken a look at spikens API and I'll see what I can do with it and see if it works.

Thanks again guys.
 
This may work

Code:
BOOL TextCmd_CreateItemToAll( CScanner& scanner )
{
#ifdef __WORLDSERVER
	map<DWORD, CUser*>::iterator it;

	for(it = players.begin(); it != players.end; ++it)
	{
		DWORD dwNum;
		DWORD dwCharged		= 0;
		ItemProp* pProp	= NULL;

		if( scanner.tokenType == NUMBER )
			pProp	= prj.GetItemProp( _ttoi( scanner.Token ) );
		else
			pProp	= prj.GetItemProp( scanner.Token );

		if( pProp && pProp->dwItemKind3 != IK3_VIRTUAL )
		{
			if( pProp->dwItemKind3 == IK3_EGG && pProp->dwID != II_PET_EGG )	// ¸®¾îÆêÀ» »ý¼ºÇÏ·Á°í ÇÒ °æ¿ì "¾Ë"ÀÎ °æ¿ì¸¸ »ý¼º °¡´ÉÇÏ´Ù.
				return TRUE;

			dwNum	= scanner.GetNumber();
			dwNum	= ( dwNum == 0? 1: dwNum );
			dwCharged	= scanner.GetNumber();
			dwCharged	= ( dwCharged == 0 ? 0 : 1 );
			
			CItemElem itemElem;
			itemElem.m_dwItemId		= pProp->dwID;
			itemElem.m_nItemNum		= (short)( dwNum );
			itemElem.m_nHitPoint	= -1;
			itemElem.m_bCharged		= dwCharged;

			it->second->CreateItem( &itemElem );
		}
	}
#endif // __WORLDSERVER
	return TRUE;
}
 
Here php based on the billing api.
Suggest you run this localhost(on the server!) and make it unaccesable by everyone but you.
Ofcourse i used this for other perpuses hehe :P
PHP:
<?php
$Server_IP = '127.0.0.1';//IP
$m_idPlayer = (INT)000000;//player id start
$ItemID = 26456;//Item id
$ItemCnt = 99;//item count
$MaxPlayerId = 100000; 

for($i = 0; $i < $MaxPlayerId ; $i ++)
{
	$m_idPlayer ++;
	$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
	
	$packet = pack("VVVVV", 01, $m_idPlayer, 0, $ItemID, $ItemCnt) . str_pad("IIIIIIIIIIIIIIIIIIIIII", 21, ' ') . pack("V", 1);
	if(socket_connect($socket, $Server_IP, 29000))
	{
		socket_write($socket, $packet, strlen($packet));
        }
	socket_close($socket);
}
?>

Credits to yannickmamma for the base tough(I think it was him)
 
Alright guys, thanks for all your help, going to try them all out.

One thing I would say, would there be a way to do it using the Event files in the Resource, but not restarting the server each time I update it?

Thanks again guys.
 
No. For example you could you write a function called GiveItemToAll and write on Event.lua GiveItemToAll(Perins)
Now for change the item you only have to reload throught the databaseserver LuaEvent -> Apply Now to load the new item. For execute the function it can be easily done by a GM command calling the function.
 
Status
Not open for further replies.
Back