Solved Getting player name-specific things to happen

Question that is answered or resolved.

mishadude

New member
Hi everyone. I'm trying to understand how to write scripts using the getplayerproperty (name)

Can you give me an example of how to write a script for "if the player's name is Mike, then the enemy named AngryDude will appear"

Can this script work only in the player's file, or also in a level file?
 
great question.

the only thing that i can tell you is that there is this text objects that appear on some modules

nightslashers has them, when you face bosses, a text dialogue will appear with your character's unique dialog.

if im not mistaken this text entities can summon spawns, just make the text entity w/invisible frames & make it very brief.
you can add the spwn command in between animation frames
(study nightslasher's carriage  stage, the boss spawns enemies)

you will have to study how they work & the script they use, but i'm pretty sure they can be modified for that purpose, they can trigger music, enemies, and probably even webm video, or a series of video frames.

the only draback is that they are coordiante dependent, but for that there is a script in the script index thread that shows you how to spawn an entity independently from the screen position....

if you manage to modify it, try to share it please, i am busy with a couple of "bulky" features that i want to get out of the way...
 
warning: this events seem to apply to player 1 only as far as i know

the next level thing would be to apply them to a multiplayer context like a certain combo of characters triggering a different enemy, warp point, or cutscene
 
mishadude said:
Hi everyone. I'm trying to understand how to write scripts using the getplayerproperty (name)

Can you give me an example of how to write a script for "if the player's name is Mike, then the enemy named AngryDude will appear"

Can this script work only in the player's file, or also in a level file?

There's no player property called Name IIRC. You can get that as regular entity's property. That means, you get the entity handle of player then get name of that entity

To spawn specific enemy (or anything), you can do that in player's file or in level's file . The former could get more complicated than it should be so I'll skip that

Here's example on how to do it in level's text:
Code:
spawn	AngryDude
@script
void main()
{
  void P1 = getplayerproperty(0, "entity");
  char P1Name = getentityproperty(P1,"defaultname");

  if(P1Name != "Mike"){
    void self = getlocalvar("self");

    killentity(self);
  }
}
@end_script
flip	1
coords	-50 210
at	200

This spawn originally will spawn AngryDude with defined coords at 200. However the script will remove him if player 1 isn't Mike
The script doesn't work like "if player 1 is Mike, then AngryDude will appear" but instead "if player 1 isn't Mike, then AngryDude will not appear". Different method but same result :)
I offer this method cause it's simpler and easier to edit

It can be modified to check player 2's name instead or to check both player's name to find Mike if needed
 
Bloodbane said:
"if player 1 isn't Mike, then AngryDude will not appear"

More like if player 1 isn't Mike, then AngryDude will commit suicide ;D

Seriously, though, thank you so much. Can you also please help me nail down exactly how to get the game to find out that Mike's name is Mike? Does this script have to be in Mike's spawn animation?
 
No, you don't need to add script in Mike or any entity's animations

Code:
  void P1 = getplayerproperty(0, "entity");
  char P1Name = getentityproperty(P1,"defaultname");

P1 will get entity handle of player 1, then P1Name will get that entity's default name

One thing you need to know is that it is case sensitive so if Mike's name in his text is mike, MIKE, MiKe or mIKE, the script will consider not Mike
 
Back
Top Bottom