#Why is this not working?

1 messages · Page 1 of 1 (latest)

pale kindle
#
  attacker is a player
  victim is an entity
  attacker is holding diamond sword
  name of attacker's tool is {sacrificialdagger}

  set {_attackerYaw} to yaw of attacker
  set {_victimYaw} to yaw of victim
  set {_yawDiff} to {_attackerYaw} - {_victimYaw}
  set {_yawDiff} to abs({_yawDiff})

  if {_yawDiff} < 90:
    if {backstab::%attacker%} is set:
      set {_cool} to difference between {backstab::%attacker%} and now
      if {_cool} < 30:
        set {_remaining} to round(({@backstab-cooldown} - {_cool}) / 1 second)
        send "&cBackstab is on cooldown (%{_remaining}%s)" to attacker
        stop

    # Backstab logic (respects armor)
    add 50 to {oblation::%attacker%}
    damage victim by 2.5
    set {frozen::%victim%} to true
    send "&dYou backstabbed %victim%!" to attacker
    play sound "entity.player.attack.crit" with volume 1 and pitch 2 at victim
    execute console command "particle minecraft:heart %victim's location% 0.3 0.3 0.3 0.05 5 force"

    wait 5 seconds
    delete {frozen::%uuid of victim%}

    set {backstab::%attacker%} to now

  else if {_yawDiff} < 180:
    if {backstab::%attacker%} is set:
      set {_cool} to difference between {backstab::%attacker%} and now
      if {_cool} < 20:
        set {_remaining} to round(({@frontstab-cooldown} - {_cool}) / 1 second)
        send "&cBackstab is on cooldown (%{_remaining}%s)" to attacker
        stop

    # Backstab logic (respects armor)
    add 25 to {oblation::%attacker%}
    apply weakness 2 to victim for 15 seconds
    apply slowness 2 to victim for 15 seconds

    set {frontstab::%attacker%} to now```

There are NO errors its just not working
ebon haven
#

What exaxtly isnt working?

pale kindle
#

all of it

ebon haven
#

Debug it

#

And find out exactly

pale kindle
#

the backstab isnt freezing or working

#

same with frontstab

ebon haven
#

Is this code ai by Chance?

pale kindle
#

what makes you thin that

#

think

#

its me copying code from other things..?

ebon haven
#

Victim is an entity

#

The comments

pale kindle
#

thats me copying code from other things

#

i can fix them

#

also is it not normal to randomly add comments

ebon haven
pale kindle
#

i do that...

ebon haven
#

Well

pale kindle
#

if it makes me victimized ill stop

ebon haven
#

Debug it

#

And if you find what doesnt work

#

And you dont know how to fix it

#

Then you should come back to this

mild copperBOT
#

Senternal.jpeg suggests that you read this embed

Debug
What is debugging?

Debugging is the process of finding and fixing bugs/issues/errors within your code. For a more detailed explanation on proper debugging check out sovdee's page

Variables

Since you don't see the value of variables it can be easy to assume that everything is working properly even though that might not be the case. Variables and arguments in functions and commands might change throughout your code in unexpected ways. It is a good idea to broadcast your variables at different points in your code to confirm that the value is what you expect it to be.

on chat:
    broadcast {chats::%player's uuid%}
    add 1 to {chats::%player's uuid%}
    broadcast {chats::%player's uuid%}```
In this example we broadcast the variable to check its value before and after we add to it to make sure the value goes up. If the variable was set to a string (`set {chats::%player's uuid%} to "3"`) then we would be able to see that the value did not go up, alerting us of the issue.
Conditions

If your code does no seem to be doing anything it is a good idea to establish which parts of your code are being executed, especially when using conditions. To accomplish this, add a broadcast after each part of line of your code with a descriptive message.

on right click:
    broadcast "player clicked"
    if player's tool = iron sword:
        broadcast "player's tool was iron sword"
        set player's tool to diamond sword```
In this example, we would only see the `player clicked` message if the player was holding an apple, alerting us that the code stopped after the first condition.
NBT

If you are debugging nbt you can use send pretty nbt of nbt of player's tool with split to make it more readable.

#

It is recommended that you don't use AI agents for multiple reasons @pale kindle:


2) Blindly trusting code from any source is a bad idea, especially on production servers. Even if the code that was generated appears to work, you have no clue what vulnerabilities it introduces or fails to protect against.

3) Using AI to write your code takes away from your learning and doesn't challenge you to develop problem solving skills.```
While AI can be used as a tool, it is necessary to understand what it is doing and check any code it creates. Since this is a learning community, we want to support your personal growth. As a result, we don't allow generated content in our help channels ([Rule 8](<#welcome-to-skunity message>))
pale kindle
#

wdym ai?

#

im not using ai

ebon haven
#

It looks highly ai Generated i must admit

pale kindle
#

im not using ai

#

omml

whole grove
#

"Backstab logic (respects armor)"

"victim is an entity"
attacker is holding diamond sword
name of attacker's tool is {sacrificialdagger}

mild copperBOT
ebon haven
#

Read this instead of using ai

whole grove
#

^^

#

using ai is aginst rules.

ebon haven
#

And you dont learn anything using it

pale kindle
ebon haven
#

Stop saying excuses

#

You wont get banned for using ai code, except if you do it repeatadly

pale kindle
#

im not using excuses im genuilly saying what i did

whole grove
#

& ur freeze isnt working cus theeres no functionality 💀

ebon haven
#

Maybe je has a on move

#

That chexks if its frozen

whole grove
#

prolly

ebon haven
#

If he has an on player move then the code is prolly ai too tho✌️

#

Least laggy event oat

pale kindle
#

there is

#
  loop all players:
    if {frozen::%loop-player%} is set:
      if loop-player's location is not {previous-location::%loop-player%}:
        teleport loop-player to {previous-location::%loop-player%}
        send action bar "&cYou are stunned and cannot move!" to loop-player
      set {previous-location::%loop-player%} to loop-player's location```
ebon haven
#

Why are you setting a global variable

#

This can be done much better using local variables

pale kindle
#

i was probally planning to use it in other skripts

#

at that time