- Joined
- Jun 23, 2007
- Messages
- 4,066
I'm making a proper release package for people who want to add optional extensions to their map through SharpCraft.
Currently the optional feature is HTTP access. I created a demo which will automatically load your character from a web server, and save to it, as long as at least 1 player has SharpCraft in the map.
You can try the demo attached below.
Libraries:
Currently the optional feature is HTTP access. I created a demo which will automatically load your character from a web server, and save to it, as long as at least 1 player has SharpCraft in the map.
You can try the demo attached below.
Libraries:
Here's a basic example on how to make SharpCraft an optional feature for your map. This works in Battle.Net and only requires 1 player to have SharpCraft running.
For demonstration I created a basic HTTP implementation. This lets you do simple GET/POST requests to websites.
With this you could do things like store and retrieve player data online, but there are much more possibilities.
For demonstration I created a basic HTTP implementation. This lets you do simple GET/POST requests to websites.
With this you could do things like store and retrieve player data online, but there are much more possibilities.
JASS:
scope HttpExample initializer Init
globals
gamecache SharpCraftCache
endglobals
function HasSharpCraft takes nothing returns boolean
return GetStoredBoolean(SharpCraftCache, "SC", "0")
endfunction
private function OnReceiveString takes nothing returns boolean
local SyncData data = GetSyncedData()
call BJDebugMsg(GetPlayerName(data.from) + " downloaded \"" + data.readString(0) + "\"")
call data.destroy()
return false
endfunction
private function OnMapStart takes nothing returns nothing
local string response = ""
local SyncData data
call StoreString(SharpCraftCache, "ARG", "0", "HTTP")
call StoreString(SharpCraftCache, "ARG", "1", "http://185.92.220.118/mmo/status.php")
call StoreString(SharpCraftCache, "ARG", "2", "END")
call Cheat("RunSharpCraftCommand")
call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Downloading website...")
call TriggerSleepAction(2.5)
call Cheat("StoreLastResults HTTP")
set response = GetStoredString(SharpCraftCache, "HTTP", "0")
set data = SyncData.create(Player(0))
call data.addString(response, 64)
call data.addEventListener(function OnReceiveString)
call data.start()
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEvent(t, 0.00, false)
call TriggerAddAction(t, function OnMapStart)
set SharpCraftCache=InitGameCache("sc.w3v")
call Cheat("SharpCraftInit")
if (not HasSharpCraft()) then
call InitGameCache("sc.w3v")
endif
endfunction
endscope
Attachments
Last edited: