• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

SharpCraft Extensions - Optional Features for your Map (B.NET Ready)

Status
Not open for further replies.
Note: The easiest way to start developing with SharpCraft is to download my JNGP Package



This is a plugin which you can import into your map that will allow some custom features. It works in B.NET and it's completely optional.

All you need to do is import the attached file into your map with the following path:

"plugins\SharpCraftExtensions.dll"

Then you will have access to B.NET ready features as long someone is running SharpCraft. You can access the commands through gamecache and the Cheat function. This way we don't have to add any custom natives and the map will still work with the vanilla game, and online.

Currently there is only one custom command implemented.
  1. HTTP
An example of calling this command would look like this:

JASS:
call StoreString(SharpCraftCache, "ARG", "0", "HTTP")
call StoreString(SharpCraftCache, "ARG", "1", "URL = www.google.com") // download websie
call StoreString(SharpCraftCache, "ARG", "2", "END")
call Cheat("RunSharpCraftCommand")
call TriggerSleepAction(2)
call Cheat("StoreLastResults HTTP")
call BJDebugMsg(GetStoredString(SharpCraftCache, "HTTP", "0")) // display result of website
To make things easier, you can copy these vJass libraries over to your map.
  1. SharpCraft Extensions - These will allow you to detect which players in the map have SharpCraft running.
  2. HttpRequest - This will make dealing with HTTP requests very simple.

Here is an example usage of the HTTP library.


JASS:
scope HttpExample initializer Init

     private function OnDownloadString takes nothing returns boolean
        local HttpRequest req = GetEventHttpRequest() // or HttpRequest.last()
 
        call BJDebugMsg(GetPlayerName(req.player) + " downloaded \"" + req.response + "\"")
 
        call req.destroy()
 
        return false
    endfunction
 
 
    private function OnMapStart takes nothing returns boolean
        local HttpRequest http = HttpRequest.create(FindPlayerWithSharpCraft(), "www.hiveworkshop.com/attachments/hello-txt.248392/")
 
        if (http.player == null) then
            call BJDebugMsg(SCOPE_PREFIX + "No players have SharpCraft installed.")
            return false
        endif
 
        set http.callback = Filter(function OnDownloadString)
 
        call BJDebugMsg("Downloading " + http.url)
 
        call http.start()
 
        return false
    endfunction

    //===========================================================================
    private function Init takes nothing returns nothing
        call OnSharpCraftInit(function OnMapStart)
    endfunction

endscope
 

Attachments

  • SharpCraftExtensions.zip
    4.6 KB · Views: 56
  • source.zip
    2 KB · Views: 54
Last edited:
Status
Not open for further replies.
Top