Snowball War
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Snowball War

Started by Mozzilla?, 11 November, 2006, 01:44:05

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Mozzilla?

With winter nearly upon us I thought it was time to add the ability for HubOwners that have that profile in their hub to be able to join in the fun of chucking snowballs at all of their hubs staff and members, so here it is.

Hope you don't mind me messing with your script Mutor?

--Snowball War 1.0b LUA 5.1
--
--by Mutor  10/08/05
--
--Requested by H?LL?L?L??nG?L
--
-- Not unlike stab bot and similiar, show your love for other hubbers
-- with this nonsensical winter time sport of kings.
--
--		+Changes from 1.0
--			+Added user accuracy in score listing
--			+Added a few more responses
--
--		Added by Mozzilla? - 11 November 2006
--			Extra SnowProfile - [6] = Owner
--
--User Settings----------------------------------------------------------------------------------------------------------------
--
--//-- Botname pulled from the hub
SnowBot = "Snowball-Fight"
--//-- Command Prefix
Prefix = "!"
--//-- Throw a snowball
SnowCmd = "sb"
--//-- Get scores
ScoresCmd = "ss"
--//-- Menu name pulled form hub, uses hub name for menu
SnowMenu = frmHub:GetHubName()
--//-- Custom submenu
SnowSubMenu ="Snowball Fight"
--//-- Filename for user data
SnowFile="SnowTable.dat"
--//--Set your profiles permissions here.
--profile_idx, Commands/Menus enabled [0=no 1=yes], "Profile Name"
SnowProfiles = {
[-1] = {1,"Unregistered User"},
[0] = {1,"Master"},
[1] = {1,"Operator"},
[2] = {1,"Vip"},
[3] = {1,"Registered User"},
[4] = {1,"Moderator"},
[5] = {1,"NetFounder"},
[6] = {1,"Owner"},
}
--//-- Set your hit/miss responses here
Hit = {
"Oh man, user1 just blasted user2 right in the mush.",
"user1 launches and.... Ouch, user2 thats gonna leave a mark!",
"user2 excalims 'HEY, user1 No iceballs! You'll put someone's eye out'.",
"user1 wings user2 , a mere flesh wound.",
"user1 bounces a hard packed one off user2's head. Oooooh, Thats gotta hurt.",
"Forgoing the whole 'throwing' technique, user1 walks right up and mashes one right in  user2's kisser",
"For no apparent reason, user1 steps behind user2 and plants an icy one in the spine",
"user1 AKA:'The Rifleman' nearly breaks user2's arm with a tremendous shot.",
"Recieving a humiliating shot in the ass from user1, user2 screams 'Oh its on!' and reaches for a round.",
"'Oh no you didn't', yells user1 and beans user2 in the eye!",
"user1 picks up an oversized snowball and drops it on user2's head.",
"'OK its not funny user1, I cant see' says user2",
"user2, unable to move in the 20 layers of clothing is trapped like an upturned turtle. user1 moves in for the kill.",
"In a decidely vicious attack, user1 sends a line drive square into user2's er.. umm... 'nether region'.",
"New comer user2 takes a fastball to the chops from user1. Thats got to be dissapointing to the young upstart.",
"Fans cheer widly as user1 lands a deadly accurate slushball into the open collar of user2",
}

Miss = {
"user2 asks 'Are you trowin ad me user1?, I said, 'Are you trowin ad me!?'",
"user1 fires and misses user2 and summarily blames the low quality French made snowballs",
"user1 tossing widly, misses user2 by a mile",
"user2 escapes a viscious head shot from user1 and seeks asylum in the igloo.",
"user2 runs like the wind and avoids the dreaded 'yellow snowball'.",
"All laugh as user1 throws a powder ball at user2 that never reaches its mark.",
"user2 is spared as user1's inexperience in the art of snowball making is displayed to all.",
"Blinded by an incoming round, user1 throws way long. user2 just giggles.",
"Although user1 launches a power shot right on its mark, user2's' fleet footedness affords a narrow escape.",
"user2 exclaims 'HAHA! You throw like a girl user1'",
"user2 dives behind an SUV and evades a barage launched by user1",
"user2 wisely escapes the hit drom user 1 by quickly droping into a 'Snow Angel' defense posture.",
"user2 double pump fakes and spins left, user1 is livid with the display.",
"Moving as a divine mist, user2 disolves to nothingness just before user1's round impacts.",
"user1's myopia will cost him dearly in the ratings as user2 is missed entirely.",
"After 6 weeks on the DL, fan fav user1 fires a steamer. Broadly missing user2, fans wonder if "..
"the torn shoulder is truly healed.",
}
--
--End User Settings-------------------------------------------------------------------------------------------------------------

Throw = {1,1,0,1,1,0,1,0,1,0,1,1,1}

function Main()
	if SnowBot ~= frmHub:GetHubBotName() then
		frmHub:RegBot(SnowBot, 1, "Winter Fun", "")
	end
	if loadfile(SnowFile) ~= nil then
		dofile(SnowFile)
	else
		local startdate,starttime =os.date("%B %d %Y"),os.date("%X")
		SnowTable ={}
		SnowTable["start"]={startdate,starttime}
		Save_File(SnowFile,SnowTable,"SnowTable")
	end
end


function OnExit()
Save_File(SnowFile,SnowTable,"SnowTable")
	if SnowBot ~= frmHub:GetHubBotName() then
		frmHub:UnregBot(SnowBot)
	end
end

function NewUserConnected(user, data)
	if SnowProfiles[user.iProfile][1] == 1 then
		Commands(user)
		user:SendData(SnowBot, SnowProfiles[user.iProfile][2].."'s Snowball fight commands enabled. Right click hub tab or user list for command menu.")
	end
end

OpConnected = NewUserConnected

ChatArrival = function(user, data)
local s,e,pre,cmd = string.find(data, "^%b<>%s+(%p)(%w+)")
local s,e,nick = string.find(data, "^%b<>%s+%p%w+%s(%S+)|$")
	if pre and pre==Prefix then
		if cmd and cmd==ScoresCmd then
			local Scores = "\r\n\r\n\tSnowball Fight Scores:\r\n\t"..string.rep("=",90).."\r\r\n"
			for i,v in pairs(SnowTable) do
				if i ~= "start" then
					local diff1 = (45 - string.len(i))
					local diff2 = (5 - string.len(v[1]))
					local diff3 = (15 - string.len(v[2]))
					local spacer1 = string.rep(" ", diff1)
					local spacer2 = string.rep(" ", diff2)
					local spacer3 = string.rep(" ", diff3)
					local pct = 100 - (v[2] / (v[1] + v[2])) * (100 / 1 )
					pct = string.format("%.2f %%",pct)
					Scores = Scores.."\t\t  "..i..spacer1.."\tHits: "..v[1]..spacer2.."\tMisses: "..v[2]..spacer3.."\tAccuracy: "..pct.."  \r\r\n"
				end
			end
				user:SendData(SnowBot, Scores.."\t"..string.rep("=",90).."\r\n\tEnd of Listing\r\n\r\n")
				return 1
		elseif cmd and cmd==SnowCmd then
			if SnowProfiles[user.iProfile] and SnowProfiles[user.iProfile][1] == 1 then
				if nick then
					local usrnick = GetItemByName(nick)
					if not usrnick then
						local reply = "User "..nick.." Not found. Best to set your sights on one who is online."
						user:SendData(reply)
						return 1
					end
					if not SnowTable[user.sName] then
							SnowTable[user.sName]={0,0}
					end
					local toss = Throw[math.random(1, table.maxn(Throw))]
					if toss ~= 0 then
						SnowTable[user.sName][1] = SnowTable[user.sName][1] + 1
						local result = Miss[math.random(1, table.maxn(Miss))]
						result = string.gsub(result,"user1", user.sName)
						result = string.gsub(result,"user2", usrnick.sName)
						SendToAll(SnowBot,result)
					else
						SnowTable[user.sName][2] = SnowTable[user.sName][2] + 1
						local result = Hit[math.random(1, table.maxn(Hit))]
						result = string.gsub(result,"user1", user.sName)
						result = string.gsub(result,"user2", usrnick.sName)
						SendToAll(SnowBot,result)
					end
					result = nil
					Save_File(SnowFile,SnowTable,"SnowTable")
					return 1
				else
					user:SendData("\r\n\r\n\tSyntax Error, Syntax = "..Prefix..SnowCmd.." <Nick>\r\n")
					--return 1
				end
			else
				user:SendData("\r\n\r\n\tSorry "..user.sName.." the command ' "..Prefix..SnowCmd..
				" ' is disabled for "..SnowProfiles[user.iProfile][2].."'s\r\n")
				return 1
			end
		end
	end
end

function Commands(user)
	--user:SendData("$UserCommand 255 7")	--clear the menu first
	user:SendData("$UserCommand 1 1 " ..SnowMenu.."\\"..SnowSubMenu.."\\Toss a snowball at.. $<%[mynick]> "..Prefix..SnowCmd.." %[line:Nick]&#124;|")
	user:SendData("$UserCommand 1 2 " ..SnowMenu.."\\"..SnowSubMenu.."\\Toss a snowball at.. $<%[mynick]> "..Prefix..SnowCmd.." %[nick]&#124;|")
	user:SendData("$UserCommand 1 3 " ..SnowMenu.."\\"..SnowSubMenu.."\\Get scores $<%[mynick]> "..Prefix..ScoresCmd.."&#124;|")
end

Save_Serialize = function(tTable, sTableName, hFile, sTab)
	sTab = sTab or "";
	hFile:write(sTab..sTableName.." = {\n" );
	for key, value in pairs(tTable) do
		local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
		if(type(value) == "table") then
			Save_Serialize(value, sKey, hFile, sTab.."\t");
		else
			local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
			hFile:write( sTab.."\t"..sKey.." = "..sValue);
		end
		hFile:write( ",\n");
	end
	hFile:write( sTab.."}");
end

Save_File = function(file,table , tablename )
	local hFile = io.open (file , "w")
	Save_Serialize(table, tablename, hFile);
	hFile:close()
end


Enjoy.

Newfie

well done Mozzilla , the game is a hit in the hub ,thanks bud    :D

Naithif

#2
Aren't thanks should go to the right person regarding this script?

Stormbringer

QuoteAren't thanks should go to the right person regarding this script?

It's done....

--Snowball War 1.0b LUA 5.1
--
--by Mutor  10/08/05

One more time you don't read....


Naithif

#4
Quote from: Stormbringer on 22 November, 2006, 23:53:10
It's done....

--Snowball War 1.0b LUA 5.1
--
--by Mutor  10/08/05

One more time you don't read....



Yes, one more time you can't ;)
I was talking about thanks not credits :P

What's documented as source and thanking what to who is 2 different things
Example:
You can thank Mutor for the script and Mozzilla? for the 1 line change in it

Cêñoßy†ê

#5
Version i use in my hub  ;D

--Snowball War 1.0g3 LUA 5
--
--by Mutor  10/08/05
--
--Requested by H?LL?L?L??nG?L
--
-- Not unlike stab bot and similiar, show your love for other hubbers
-- with this nonsensical winter time sport of kings.
--
--		+Changes from 1.0
--			+Added user accuracy in score listing
--			+Added a few more responses
--
--		+Changes from 1.0b 11/08/05
--			+"Declaration of war statement" request by H?LL?L?L??nG?L
--
--		+Changes from 1.0c 11/11/05
--			+Added WaitTime, user cannot throw again until time elapsed.
--			+User cannot score on themselves, a hit point weill be deducted for each offense
--
--		+Changes from 1.0d 12/06/05
--			+Bugfix in scoring, when user 'Hits' are equal or less than 0 [division by zero]
--			+Bugfix in scoring, hit/miss 12/12/05	--Thanks Ubikk for report
--			-Removed space from default botname, User & Bot names cannot contain a space [missed that]
--
--
--		+Changes from 1.0e 12/21/05
--			+Added WoW style rankings		Request by Ubikk / Syphrone-NL
--			+Added 'Liberty' toggle(hide)	Request by Ubikk
--			+Changed Scoring format/function
--
--
--		+Changes from 1.0f 12/21/05
--			+Added upgrade options							Request by Ubikk
--			+Changed scoring when score on higher rank		Request by Ubikk
--			+Changed hit/miss probability with upgrades		Request by Ubikk
--			+ Added mem flush & Owner Profile [6] by C??o?y??
Powered By Leviathan™ 2nd Generation v. 1.9

Mozzilla?

Quote from: Newfie on 20 November, 2006, 21:44:54
well done Mozzilla , the game is a hit in the hub ,thanks bud    :D

Thanks Newfie, but all credit should goto Mutor really, all i done was add one line of text so Owners didn't miss out on the fun lol

Regarding changes I make to scripts:

If I make any changes or additions to scripts and I post them here or on any other board i never remove the original credits, thats stealing in my eyes and it ain't fair to take the credit for somebody elses hard work and dedication.

And lastly I'll be swapping the Snowball Script i have in my hub atthe moment for the one that C??o?y??  is using as it has rankings etc.


Newfie

oops , sorry mutor ,, thanks for the great script,  i was sayin thanks to mozzilla cause it was the one  grabbed and should have credited you as well.   :-[

Stuffy

Hello, sorry for my bad english *g
I have load the modificated wargame, with the owner profile added. It works greatly, but users can't shoot the owner. Can you tell me, where i can set it to shoot the owner too.
Thx for answer

CrazyGuy

Quote from: Stuffy on 23 November, 2006, 21:49:08
Hello, sorry for my bad english *g
I have load the modificated wargame, with the owner profile added. It works greatly, but users can't shoot the owner. Can you tell me, where i can set it to shoot the owner too.
Thx for answer

local toss = Throw[math.random(1, table.maxn(Throw))]


Throw = {1,1,0,1,1,0,1,0,1,0,1,1,1}


Wether the result is a Hit or a Miss is picked random by choosing a math.random from table Throw.
So hitting an Owner should be just as possible as hitting any1 else.
Increasing the number of 1's in table Throw, will increase Hit probability.


Stuffy

Hi, thx for answer.
I have edit your modifications, but i have forget you to inform....
i have different profiles in my hub.
my profiles are:
[-1] = --Unreg
  • = --Owner
    [1] = --Master
    [2] = --SU
    [3] = --Op
    [4] = --KVIP
    [5] = --VIP
    [6] = --Reg

    the modifications not work for me.
    Can you explain me where i must edit this.
    thank you

Stuffy

#11
Hi,
i can see the RC-Menu but when i use the command !sb ownernick it cames only the command in mainchat.

My Profiles i had included in this script exact as you
and the changes from CrazyGuy included.

Owner see the RC-Menu and all users too, but no profile can shoot to the owner.

Very Thanks for Help me.

I Hope you understand my terrible english  ::)

amenay

If someone attempts to buy an upgrade they already have it still deducts the hits.  I just added this line to add the points in the situation that they do have the upgrade already.

Changed this @276:

else
									user:SendData(SnowBot,"\r\n\t"..SnowTable[user.sName][4].." "..user.sName.." you already"..
									"have the Upgrade "..upgrade..".")
									return 1
								end


To this:

else
									SnowTable[user.sName][1] = SnowTable[user.sName][1] + cost
									user:SendData(SnowBot,"\r\n\r\n\t"..SnowTable[user.sName][4].." "..user.sName.." you already"..
									" have the Upgrade "..upgrade..".")
									return 1
								end

SMF spam blocked by CleanTalk