Raised This Month: $51 Target: $400
 12% 

Urban Dictionary plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ugleh
Member
Join Date: Oct 2009
Old 09-17-2010 , 00:07   Urban Dictionary plugin
Reply With Quote #1

I want this to be a private plugin so don't post this in the mods section, but if you can post the plugin in this forum that would be great.

Id like it so when someone types"!ud word"

it will say in that chat area.

Word: Spy
Definition: French man in a suit and ski mask, who runs around backstabbing people and ****ing your mother
Example: "Now listen up boy, or pornography starring your mother will be the second worst thing that happens to you today" -Spy

It should grab each part using this site
http://ugleh.com/ud.php?term=spy

I don't know if its possible because I never made a plugin, but id also like a 2 minute cool down after each use so its not spammed.

The content for each section on the site is each split by " ::split::: ".

It uses \n in the php for new lines when needed, if you view source on the term=spy you would see the line breaks in places it needs it.
Ugleh is offline
Alex.
SourceMod Donor
Join Date: Sep 2010
Location: England
Old 09-17-2010 , 12:44   Re: Urban Dictionary plugin
Reply With Quote #2

Sure, I'll give it a go... Once I figure out how to send an HTTP request and put the response into a string.

Last edited by Alex.; 09-17-2010 at 13:08.
Alex. is offline
Ugleh
Member
Join Date: Oct 2009
Old 09-17-2010 , 13:49   Re: Urban Dictionary plugin
Reply With Quote #3

lol I wish i knew how to too

What coding language is the plugins created in?
Ugleh is offline
Alex.
SourceMod Donor
Join Date: Sep 2010
Location: England
Old 09-17-2010 , 14:10   Re: Urban Dictionary plugin
Reply With Quote #4

Pawn.
Alex. is offline
DieTeetasse
Senior Member
Join Date: Jul 2009
Old 09-17-2010 , 14:52   Re: Urban Dictionary plugin
Reply With Quote #5

For HTTP Request you can use this extension:
http://forums.alliedmods.net/showthread.php?t=67640 (Socket 3.0.1)
__________________
DieTeetasse is offline
Alex.
SourceMod Donor
Join Date: Sep 2010
Location: England
Old 09-17-2010 , 14:58   Re: Urban Dictionary plugin
Reply With Quote #6

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <socket>

public Plugin:myinfo 
{
    
name "Urban Dictionary",
    
author "Alex",
    
description "Queries Urban Dictionary when someone uses the !ud command in chat.",
    
version "0.1",
    
url ""
}

public 
OnPluginStart() {
    
RegConsoleCmd("sm_ud"Command_UrbanDictionary);
}

public 
Action:Command_UrbanDictionary(clientargs)
{
    new 
String:Query[100];
    
GetCmdArg(1Querysizeof(Query));
    new 
String:Query1[100] = "%s.htm";
    
Format(Query1sizeof(Query1), Query);
    
    
// create a new tcp socket
    
new Handle:socket SocketCreate(SOCKET_TCPOnSocketError);
    
// open a file handle for writing the result
    
new Handle:hFile OpenFile("dl.htm""wb");
    
// pass the file handle to the callbacks
    
SocketSetArg(sockethFile);
    
// connect the socket
    
SocketConnect(socketOnSocketConnectedOnSocketReceiveOnSocketDisconnected"www.sourcemod.net"80)
}

public 
OnSocketConnected(Handle:socketany:arg) {
    
// socket is connected, send the http request

    
decl String:requestStr[100];
    
Format(requestStrsizeof(requestStr), "GET /%s HTTP/1.0\r\nHost: %s\r\nConnection: close\r\n\r\n""index.php""www.sourcemod.net");
    
SocketSend(socketrequestStr);
}

public 
OnSocketReceive(Handle:socketString:receiveData[], const dataSizeany:hFile) {
    
// receive another chunk and write it to <modfolder>/dl.htm
    // we could strip the http response header here, but for example's sake we'll leave it in

    
WriteFileString(hFilereceiveDatafalse);
}

public 
OnSocketDisconnected(Handle:socketany:hFile) {
    
// Connection: close advises the webserver to close the connection when the transfer is finished
    // we're done here

    
CloseHandle(hFile);
    
CloseHandle(socket);
}

public 
OnSocketError(Handle:socket, const errorType, const errorNumany:hFile) {
    
// a socket error occured

    
LogError("socket error %d (errno %d)"errorTypeerrorNum);
    
CloseHandle(hFile);
    
CloseHandle(socket);

I guess it's a start.
Alex. is offline
Ugleh
Member
Join Date: Oct 2009
Old 09-17-2010 , 21:00   Re: Urban Dictionary plugin
Reply With Quote #7

I dont know what to do next 0_0
Ugleh 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 00:11.


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