• 🏆 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!

[JASS] fixing it so it only works for saving player

Status
Not open for further replies.
Does anyone know how to do a identify player check so it doesn't create a load code .txt file for everyone?
JASS:
function CreateTextFile takes nothing returns nothing
     local integer p = GetPlayerId(GetTriggerPlayer())+1
     local string heroName = GetUnitName(udg_Hero)
     local integer heroLevel = GetHeroLevel(udg_Hero)
     
     call PreloadGenClear()
     call PreloadGenStart()
     
     // The line below creates the log
     // Right now, this is:
     //      Hero: (hero name)
     //      Level: (hero level)
     //      Code: -load XXXX
     call Preload("\r\n\t\t\t\tHero: " + heroName + "\r\n\t\t\t\t" + "Level: " + I2S(heroLevel) + "\t\t\r\n\t\t\t\t" + "Code: -load " + udg_NPS_Password + "\r\n\n\t\t    ")
     
     // The line below creates the file at the specified location
     // Right now, this is:
     //      "Warcraft III\FolderName\(hero name) - (hero level)"
     call PreloadGenEnd("FolderName\\" + heroName + " - " + I2S(heroLevel) + ".txt")
endfunction

  • Custom script: call CreateTextFile()
 
Try this.

JASS:
function CreateTextFileForPlayer takes player pl returns nothing
     local integer p = GetPlayerId(pl) + 1
     local string heroName = GetUnitName(udg_Hero)
     local integer heroLevel = GetHeroLevel(udg_Hero)

     // Right now, this is:
     //      Hero: (hero name)
     //      Level: (hero level)
     //      Code: -load XXXX
     local string fileData = "\r\n\t\t\t\tHero: " + heroName + "\r\n\t\t\t\t" + "Level: " + I2S(heroLevel) + "\t\t\r\n\t\t\t\t" + "Code: -load " + udg_NPS_Password + "\r\n\n\t\t    "

     // Right now, this is:
     //      "Warcraft III\FolderName\(hero name) - (hero level)"
     local string fileName = "FolderName\\" + heroName + " - " + I2S(heroLevel) + ".txt"
     
     if GetLocalPlayer() == pl then
          call PreloadGenClear()
          call PreloadGenStart()

          call Preload(fileData)
          call PreloadGenEnd(fileName)
     endif
endfunction

This will keep the string table in sync for all players.

You would call it like this:

  • Custom script: call CreateTextFileForPlayer(GetTriggerPlayer())
 
Status
Not open for further replies.
Top