PlayerDataFor does weird stuff when used with global variables #301


  • Defect
Open
  • Caley19_ created this issue Jul 11, 2021

    Hey, have this complex code which needs to work with %PlayerDataFor%... to make it do stuff correctly.

    Junk of said code:

    ...
    - '$Script$%elseif%$arg1==slot1<and>$iteminhand==tovar$arg1.item<and>tovar$arg1.amount==$amount_iteminhand'
    - '$broadcasttext$$hex%#66A0FF%Hráč $player splnil objednávku pre rozvoz tovaru.'
    - '$Script$%PlayerData%points+1'
    - '$RUN_CONSOLE$eco give $player tovar$arg1.reward'
    - '$Script$%PlayerDataFor%job.global_player%tovarslot1.send=tovar$arg1.item tovar$arg1.amount'
    - '%PlayerOptions%setItemInHand: AIR:0'
    - '$Script$%Variable%tovar$arg1.owner=0'
    - '$Script$%Variable%job.global_reward=$tovar$arg1.reward, +1 Herný bod'
    ...

    Basically, everything works fine (even the $arg1 in the middle of a global variable in first line works fine lol), but this line right here drives me crazy, I'm raging over here, can't figure out how to fix this:
    - '$Script$%PlayerDataFor%job.global_player%tovarslot1.send=tovar$arg1.item tovar$arg1.amount'

     

    notes:

    - job.global_player is a global variable that holds player's name,

    - tovarslot1.send is another global variable that holds the name of a PlayerData variable (sounds weird, but I need to dinamically switch between different playerdata variables)

    The problem is, every time I run this thing, the whole "PlayerDataFor" placeholder just don't work and instead of changing selected PlayerData variable of the player stored in job.global_player, it changes MY PlayerData variables.

    Any idea why PlayerDataFor wont work in this case? Or at least some workaround maybe? Feel like I'm gonna rewrite thise whole thing again...
    Thanks for any feedback.

  • Caley19_ added a tag Defect Jul 11, 2021
  • Caley19_ edited description Jul 11, 2021
  • Caley19_ posted a comment Jul 24, 2021

    Solved the issue by replacing:
    - '$Script$%PlayerDataFor%job.global_player%tovarslot1.send=tovar$arg1.item tovar$arg1.amount'
    with:
    - '$RUN_CONSOLE$mycmd-playerdata set tovarslot1.owner tovarslot1.send tovarslot1.item tovarslot1.amount'

    if anyone ever happen to bump into the same issue as I had with PlayerDataFor, this solution works and let's you use all crazy variables as part of values, as seen in my command above. The downside is that your console runs another aditional command.


To post a comment, please login or register a new account.