• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] Item Bound to Player Name?

Status
Not open for further replies.

ZXD

ZXD

Level 2
Joined
Dec 11, 2007
Messages
11
I was wondering how to make an item, to belong only to a certain player.

I tried this:

Code:
-Events
A unit aquires an item.
-Conditions
(Item type of (item being manipulated)) equal to Sword of XXX
-Actions
If (All conditions are true) then do (Then Actions) else do (Else Actions)
  -If Conditions
    (Owner of(Hero Manipulating Item)) not equal to xxx [Variable Name: xxx .Variable type: Player .Initial Value: none]
  -Then Actions
    Game - Display to (All players) the text: This Item can be cant be used by you.
     Hero - Drop (Item being manipulated) from (Hero manipulating item)
  -Else
Do nothing

So as result i cant pick the item up at all, despite having player name as xxx

What did i do wrong?
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
I got you problem,,(i think, and it does NOT use a variable)
It is a Substring,,
Substrings use only a part of a string,,
example: Substring(Yixx,2,3) means the first letter of the substring will be the second (2) and the last letter will be the third (3).. So the substring will be 'ix'
Substring(Harry Potter,5,10) will start at the fifth letter, and end at the tenth. Substring(Harry Potter,5,10) = y Pott

So, you want the name of the player to be the same as the 'name' of the unit. so: Sword of Yixx. You want Yixx to be the name of the player also,
Substring((Item name of (Item being maipulated)),10, length of (Item name of (Item being manipulated)))
Here is the trigger i set up for you:

  • Untitled Trigger 001
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Name of (Owner of (Triggering unit))) Not equal to (Substring((Name of (Item being manipulated)), 10, (Length of (Name of (Item being manipulated)))))
        • Then - Actions
          • Game - Display to (All players) the text: You cant pick up th...
          • Hero - Drop (Item being manipulated) from (Triggering unit)
        • Else - Actions
P.S. Next time, set your trigger between
  • Tags =) It is easier to read
  • P.P.S. This trigger is not universal, it can be used for any item at which the name starts at the 10th letter. If you have an item that is NOT name-bound. set it in a condition to False!
 

ZXD

ZXD

Level 2
Joined
Dec 11, 2007
Messages
11
I am sorry , but thats not quite what i meant ^^ , or maybe its me understanding wrong.

I was thinking just making the item to read the Player Name (Account) name, and if it doesnt match, to drop the item. Like in that Master Crafters Map.

I used variable because i remembered last time i worked with similar thing, and area where a unit could only enter if his account player name matches with the variable, so thats why i used variable. The method you use i quite complicated at first looks. Why to use the letters? Can i make it so that its not a letter , but simply the account/player name?

example: Substring(Yixx,2,3) means the first letter of the substring will be the second (2) and the last letter will be the third (3).. So the substring will be 'ix'

if the first Letter is the second, and the last is the third, wouldnt it be Yx then?

o and il use the trigger tags next time ^^
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
example: Substring(Yixx,2,3) means the first letter of the substring will be the second (2)
and the last letter will be the third (3).. So the substring will be 'ix'

if the first Letter is the second, and the last is the third, wouldnt it be Yx then?

First letter of the SUBSTRING,, that means you take a part of a string,, little confusing, you right.
let me tell it different.

Substring(A-Thingy,2,4) means you take the second letter of 'A-Thingy' and the fourth letter of 'A-Thingy'
and every letter in between, this is the 'new string',,

  • Set StringVar = Substring(Thing,2,4)
  • Game - Text message StringVar
  • -------- The game will show the text: 'hin' --------
Get the thing about substrings now?

Now i got a question for you,,
What is the 'xxx' variable set to? (is it a string?)
 

ZXD

ZXD

Level 2
Joined
Dec 11, 2007
Messages
11
First letter of the SUBSTRING,, that means you take a part of a string,, little confusing, you right.
let me tell it different.

Substring(A-Thingy,2,4) means you take the second letter of 'A-Thingy' and the fourth letter of 'A-Thingy'
and every letter in between, this is the 'new string',,

  • Set StringVar = Substring(Thing,2,4)
  • Game - Text message StringVar
  • -------- The game will show the text: 'hin' --------
Get the thing about substrings now?

Now i got a question for you,,
What is the 'xxx' variable set to? (is it a string?)

xxx Variable is set to Player with no array or inital value.


i think i get it with substring. so if the Initial String is say, Hominghead, and i take 2 and 7 the new substring will be Ming am i right?
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
xxx Variable is set to Player with no array or inital value.


i think i get it with substring. so if the Initial String is say, Hominghead, and i take 2 and 7 the new substring will be Ming am i right?

Almost ^^
It will start AT the 2nd letter, not AFTER the 2nd letter.
Also for the last letter. the 7th letter is also included in the string.
So Substring(Hominghead,2,7) would be: Omingh
If you want: Ming, it should be: Substring(Hominghead,3,6)

Does this cover your problem? Or should i still help you with the trigger?
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
ok, you right ^^ there is not many use in player name,,
but for people who want to make special abilitys, or special items available only when They are in the game, it is usefull,,

But still,, this wasnt that useless, cause now he knows about substrings ^^
 

ZXD

ZXD

Level 2
Joined
Dec 11, 2007
Messages
11
I udnerstood the substring part, il test it now and report if i still ahve issues, thank you for your help ^^


Edit: Nvm i figured its in "string"
 
Last edited:
Level 16
Joined
Oct 12, 2008
Messages
1,570
I udnerstood the substring part, il test it now and report if i still ahve issues, thank you for your help ^^


Edit: i cant find the part
  • (Name of (Owner of (Triggering unit))) Not equal to (Substring((Name of (Item being manipulated)), 10, (Length of (Name of (Item being manipulated)))))
Where does that Name start off?

It is a condition,,
String Comparison
 

ZXD

ZXD

Level 2
Joined
Dec 11, 2007
Messages
11
Ok it works. Thanks a giant Bunch :3

^,..,^

I jsut had some small issues at begning, i didnt know its Case Sensitive.

Thanks again for helping me ^,..,^
 
Status
Not open for further replies.
Top