Guild housing: Me and a friend of mine made a game, and we scripted this. Would this work for tmw?
*edit* also to use this you need to have a map set up with a templete, i could tell you more about this if you want to know.
- All maps between map 200 and map 250 are playerhouses.
- A player can buy a playerhouse by going inside a house and pressing /playerhouse buy, after that there name will be on a little sign in the corner of the map.
- After that, a playerer can "build" a house pressing /playerhouse build. This will cost 5000 coins. When they enter the command, they'll be warped to a map where they can chose how they want the house to look (a template so to speak), and if they like it they step on the most left bottom tile, and it will get copied to the house they bought.
- When they have a house build, or before that, they can use /playerhouse item, to place a item (table/chair, w/e) on the map.
- They can use /playerhouse clearitems to clear all the items on the map.
Player Commands:
/playerhouse buy - will buy the current map as playerhouse (if you have a house permit, and if it is for sale).
/playerhouse build - will build a template house into your playerhouse.
/playerhouse item - places an item on your current location
/playerhouse clearitems - will clear all items you placed (recopy template)
Code: Select all
Case "/playerhouse build"
If GetPlayerMap(index) > 250 or GetPlayerMap(index) <200> 250 or GetPlayerMap(index) <200> 0 Then
If GetPlayerMap(index) > 199 and GetPlayerMap(index) < 251 Then
Call ClearHouse(index, GetPlayerMap(index))
Else
Call PlayerMsg(index, "You have to be in a playerhouse to do this!", 12)
End If
Else
Call PlayerMsg(index, "You have to be a GM to use this command!", 12)
End If
Exit Sub
Case "/playerhouse open"
locationtemp = GetVar("house.ini", GetPlayerLogin(index) & GetPlayerCharNum(index), "owns")
If GetVar("house.ini", "maps", "" & locationtemp & "owner") = GetPlayerLogin(index) & GetPlayerCharNum(index) Then
Call PutVar("house.ini", "open", "" & locationtemp, "1")
Call PlayerMsg(index, "Your house has opened entrance!", 10)
Else
Call PlayerMsg(index, "You do not own a house!", 12)
End If
Exit Sub
Case "/playerhouse close"
locationtemp = GetVar("house.ini", GetPlayerLogin(index) & GetPlayerCharNum(index), "owns")
If GetVar("house.ini", "maps", "" & locationtemp & "owner") = GetPlayerLogin(index) & GetPlayerCharNum(index) Then
Call PutVar("house.ini", "open", "" & locationtemp, "0")
Call PlayerMsg(index, "Your house has closed entrance!", 10)
Else
Call PlayerMsg(index, "You do not own a house!", 12)
End If
Exit Sub
Case "/playerhouse clearitems"
locationtemp = GetVar("house.ini", GetPlayerLogin(index) & GetPlayerCharNum(index), "owns")
If GetVar("house.ini", "maps", "" & locationtemp & "owner") = GetPlayerLogin(index) & GetPlayerCharNum(index) Then
x = GetVar("house.ini", GetPlayerLogin(index) & GetPlayerCharNum(index), "template")
Call CopyMap(index, x, locationtemp)
Call SetTile(GetPlayerMap(index), 18, 13, 10, 2, 4, 7)
Call SetSign(GetPlayerMap(index), 18, 13,"PlayerHouse","Owner: " & GetPlayerName(index),"Number: " & locationtemp -
200)
Else
Call PlayerMsg(index, "You do not own a house!", 12)
End If
Exit Sub
Code: Select all
Sub CopyMap(index, mapin, mapout)
Dim x
Dim y
Dim percent
Dim editx
Dim edity
Dim editset
x = 0
y = 0
percent = 0
Call PlayerMsg(index, percent & "% - Please wait while the system builds your house - Building GROUND!", 10)
Do While Y < 15
Do While x < 20
editx = GetTileX(mapin, x, y, 0)
edity = GetTileY(mapin, x, y, 0)
editset = GetTileSet(mapin, x, y, 0)
Call SetTile(mapout, x, y, editx, edity, editset, 0)
x = x + 1
loop
x = 0
y = y + 1
percent = Int(percent + (100/40))
loop
x = 0
y = 0
percent = 20
Call PlayerMsg(index, percent & "% - Please wait while the system builds your house - Building ATRIBUTES!", 10)
Do While Y < 15
Do While x < 20
editx = GetAttribute(mapin, x, y)
If editx = 1 or editx = 4 Then
Call SetAttribute(mapout,x,y,editx,0,0,0,"","","")
ElseIf editx = 2 Then
Call SetAttribute(mapout,x,y,2,258,9,12,"","","")
ElseIf editx = 14 Then
Call SetSign(GetPlayerMap(index), 18, 13,"PlayerHouse","Owner:","none")
Else
Call SetAttribute(mapout,x,y,0,0,0,0,"","","")
End If
x = x + 1
loop
x = 0
y = y + 1
loop
x = 0
y = 0
percent = 40
Call PlayerMsg(index, percent & "% - Please wait while the system builds your house - Building WALLS!", 10)
Do While Y < 15
Do While x < 20
editx = GetTileX(mapin, x, y, 1)
edity = GetTileY(mapin, x, y, 1)
editset = GetTileSet(mapin, x, y, 1)
Call SetTile(mapout, x, y, editx, edity, editset, 1)
x = x + 1
loop
x = 0
y = y + 1
percent = Int(percent + (100/60))
loop
x = 0
y = 0
percent = 60
Call PlayerMsg(index, percent & "% - Please wait while the system builds your house - Building WALLS!", 10)
Do While Y < 15
Do While x < 20
editx = GetTileX(mapin, x, y, 3)
edity = GetTileY(mapin, x, y, 3)
editset = GetTileSet(mapin, x, y, 3)
Call SetTile(mapout, x, y, editx, edity, editset, 3)
x = x + 1
loop
x = 0
y = y + 1
percent = Int(percent + (100/60))
loop
x = 0
y = 0
percent = 80
Call PlayerMsg(index, percent & "% - Please wait while the system builds your house - Building ROOF!", 10)
Do While Y < 15
Do While x < 20
editx = GetTileX(mapin, x, y, 5)
edity = GetTileY(mapin, x, y, 5)
editset = GetTileSet(mapin, x, y, 5)
Call SetTile(mapout, x, y, editx, edity, editset, 5)
x = x + 1
loop
x = 0
y = y + 1
percent = Int(percent + (100/60))
loop
Call PlayerMsg(index, "100% - House has been succesfully build!", 10)
End Sub
Sub ResetHouse(index)
Dim loopvar
Dim map
loopvar = 200
Do While loopvar < 251
Call PutVar("house.ini", "maps", "" & loopvar & "", "0")
Call PutVar("house.ini", "maps", "" & loopvar & "owner", "0")
loopvar = loopvar + 1
loop
map = 200
Do While map <251> 0 Then
If pmap > 0 Then
Call PlayerMsg(index, "You already own a house!", 12)
Exit Sub
End If
End If
If GetPlayerMap(index) <200> 250 Then
Call PlayerMsg(index, "This house is not for sale!", 12)
Exit Sub
End If
If GetVar("house.ini", "maps", GetPlayerMap(index)) = "1" Then
Call PlayerMsg(index, "Somebody else already owns this house!", 12)
Exit Sub
End If
If itemslot = 0 Then
Call PlayerMsg(index, "You do not have a house permit!", 12)
Exit Sub
End If
Call SetPlayerInvItemNum(index, itemslot, 0)
Call SendInventoryUpdate(index, itemslot)
Call PutVar("house.ini", GetPlayerLogin(index) & GetPlayerCharNum(index), "owns", GetPlayerMap(index))
Call PutVar("house.ini", "maps", GetPlayerMap(index), "1")
Call PutVar("house.ini", "maps", "" & GetPlayerMap(index) & "owner", GetPlayerLogin(index) & GetPlayerCharNum(index))
Call PlayerMsg(index, "You now own this house!", 10)
Call SetTile(GetPlayerMap(index), 18, 13, 10, 2, 4, 7)
Call SetSign(GetPlayerMap(index), 18, 13,"PlayerHouse","Owner: " & GetPlayerName(index), "Number: " & GetPlayerMap(index) -
200)
Call PutVar("house.ini", GetPlayerLogin(index) & GetPlayerCharNum(index), "template", "500")
End Sub
Sub BuildHouse(index)
Dim map
Dim pmc
Dim pmap
Dim item
Dim itemslot
Dim itemvalue
Dim valueneed
map = GetVar("house.ini", GetPlayerLogin(index) & GetPlayerCharNum(index), "owns")
pmap = GetVar("house.ini", GetPlayerLogin(index) & GetPlayerCharNum(index), "owns")
pmc = GetVar("house.ini", "maps", map & "owner")
If pmc = GetPlayerLogin(index) & GetPlayerCharNum(index) Then
item = 1
itemslot = GetPlayerInvItemSlot(index, item)
If itemslot = 0 Then
Call PlayerMsg(index, "You do not have any money!", 12)
Exit Sub
End If
itemvalue = GetPlayerInvItemValue(index, itemslot)
valueneed = 5000
If itemvalue <valueneed> valueneed Then
Call SetPlayerInvItemValue(index, itemslot, itemvalue - valueneed)
Call SendInventoryUpdate(index, itemslot)
End If
map = GetPlayerMap(index)
Call PutVar("house.ini", GetPlayerLogin(index) & GetPlayerCharNum(index), "template", GetPlayerMap(index))
Call PlayerWarp(index, pmap, 8, 8)
Call CopyMap(index, map, pmap)
Call SetTile(GetPlayerMap(index), 18, 13, 10, 2, 4, 7)
Call SetSign(GetPlayerMap(index), 18, 13,"PlayerHouse","Owner: " & GetPlayerName(index),"Number: " & pmap - 200)
Else
Call PlayerMsg(index, "You do not own a house!", 12)
Call PlayerWarp(index, 258, 13, 10)
Exit Sub
End If
End Sub
Sub ClearHouse(index, map)
Call CopyMap(index, 500, map)
Call SetTile(map, 18, 13, 10, 2, 4, 7)
Call SetSign(map, 18, 13,"PlayerHouse","Owner: none","Number: " & map - 200)
Call PutVar("house.ini", "maps", "" & map, "0")
Call PutVar("house.ini", "maps", "" & map & "owner", "0")
End Sub
Function AllowPlayerIn(index, map)
AllowPlayerIn = True
If map > 250 or map < 200 Then
AllowPlayerIn = True
Exit Function
End If
If GetVar("house.ini", "open", "" & map) = "0" Then
AllowPlayerIn = False
End If
If GetVar("house.ini", "maps", "" & map) = "0" Then
AllowPlayerIn = True
End If
End Function
Sub ItemHouse(index)
Dim pmap
Dim map
Dim x
Dim y
Dim editx
Dim edity
Dim editset
Dim mapx
Dim mapy
x = GetPlayerX(index)
y = GetPlayerY(index)
mapx = Int(GetVar("tempvars.ini", "playerhouse", GetPlayerName(index) & "x"))
mapy = Int(GetVar("tempvars.ini", "playerhouse", GetPlayerName(index) & "y"))
pmap = Int(GetVar("house.ini", GetPlayerLogin(index) & GetPlayerCharNum(index), "owns"))
map = Int(GetPlayerMap(index))
editx = GetTileX(map, x, y, 3)
edity = GetTileY(map, x, y, 3)
editset = GetTileSet(map, x, y, 3)
If editx = 0 and edity = 0 and editset = 0 Then
editx = GetTileX(map, x, y, 5)
edity = GetTileY(map, x, y, 5)
editset = GetTileSet(map, x, y, 5)
Call PlayerWarp(index, pmap, mapx, mapy)
Call SetTile(pmap, mapx, mapy, editx, edity, editset, 5)
Else
Call SetAttribute(pmap,mapx,mapy,1,0,0,0,"","","")
Call SetTile(pmap, mapx, mapy, editx, edity, editset, 3)
Call PlayerWarp(index, pmap, mapx, mapy)
End If
End Sub
Code: Select all
Case 17
Call BuildHouse(index)
Exit Sub
Case 18
x = Int(GetPlayerX(index))
y = Int(GetPlayerY(index))
If x = 1 Then
y = y - 2
value = Int(240 + y)
Else
y = y - 2
y = y * 3
x = x - 4
value = 200 + x + y
value = Int(value)
End if
If AllowPlayerIn(index, value) = True Then
Call PlayerWarp(index, value, 19, 14)
Exit Sub
Else
Call PlayerMsg(index, "This house has closed entrance!", 12)
Call MapMsg(value, GetPlayerName(index) & " is trying to enter!", 12)
Exit Sub
End If
Case 19
Call ItemHouse(index)
Exit Sub
Code: Select all
Sub SetBlock(map, X, Y)
Call SetAttribute(map,X,Y,1,0,0,0,"","","")
End Sub
Sub SetWarp(map, X, Y, warpmap, warpx, warpy)
Call SetAttribute(map,X,Y,2,warpmap,warpx,warpy,"","","")
End Sub
Sub SetHeal(map, X, Y)
Call SetAttribute(map,X,Y,7,0,0,0,"","","")
End Sub
Sub SetKill(map, X, Y)
Call SetAttribute(map,X,Y,8,0,0,0,"","","")
End Sub
Sub SetItem(map, X, Y, item, value)
Call SetAttribute(map,X,Y,3,item,value,0,"","","")
End Sub
Sub SetNPCAvoid(map, X, Y)
Call SetAttribute(map,X,Y,4,0,0,0,"","","")
End Sub
Sub SetKey(map, X, Y, key, take)
Call SetAttribute(map,X,Y,5,key,take,0,"","","")
End Sub
Sub SetKeyOpen(map, X, Y, keyx, keyy, message)
Call SetAttribute(map,X,Y,6,keyx,keyy,0,message,"","")
End Sub
Sub SetShop(map, X, Y,shop)
Call SetAttribute(map,X,Y,9,shop,0,0,"","","")
End Sub
Sub SetClassBlock(map, X, Y,allow1,allow2,allow3)
Call SetAttribute(map,X,Y,10,allow,allow2,allow3,"","","")
End Sub
Sub SetArena(map, X, Y,amap,ax,ay)
Call SetAttribute(map,X,Y,11,amap,ax,ay,"","","")
End Sub
Sub SetSound(map, X, Y,filename)
Call SetAttribute(map,X,Y,12,0,0,0,filename,"","")
End Sub
Sub SetSpriteChange(map, X, Y,sprite,item,cost)
Call SetAttribute(map,X,Y,13,sprite,item,cost,"","","")
End Sub
Sub SetSign(map, X, Y,line1,line2,line3)
Call SetAttribute(map,X,Y,14,0,0,0,line1,line2,line3)
End Sub
Sub SetDoor(map, X, Y)
Call SetAttribute(map,X,Y,15,0,0,0,"","","")
End Sub
Sub SetNotice(map, X, Y, title, text, filename)
Call SetAttribute(map,X,Y,16,0,0,0,title,text,filename)
End Sub
Sub SetChest(map, X, Y)
Call SetAttribute(map,X,Y,17,0,0,0,"","","")
End Sub
Sub SetScripted(map, X, Y, script)
Call SetAttribute(map,X,Y,18,script,0,0,"","","")
End Sub
Sub SetBank(map, X, Y)
Call SetAttribute(map,X,Y,23,0,0,0,"","","")
End Sub
Sub SetHouse(map, X, Y,item,cost)
Call SetAttribute(map,X,Y,21,item,cost,0,"","","")
End Sub
Code: Select all
Dim Portal
Dim mapnum
Dim x
Dim y
Dim i
Dim TextSay
Dim n
Dim m
Dim C
Dim locationtemp
Dim playernametemp
Dim invitemslot
Dim invemptyslot
Dim value
Dim map