Ayuto / EventScripts-Emulator

A Source.Python plugin that is able to run EventScripts addons.
16 stars 9 forks source link

playerget primary & secondary #28

Closed ManifestManah closed 5 years ago

ManifestManah commented 5 years ago

When trying to obtain the data stored in the variable using the command playerget primary or playerget secondary then the variable will always return 0.

Running the latest emulator, latest version of source-python and was tested on a server only running source-python and the emulator.

Code used for testing this:

block load
{
    es_xset secondary_variable 0
    es_xset primary_variable 0
}

event player_spawn
{
    es_delayed 1 playerget secondary secondary_variable event_var(userid)
    es_delayed 1 playerget primary primary_variable event_var(userid)
    es_delayed 1.5 es_msg server_var(wcs_z3) is the primary weapon 
    es_delayed 1.5 es_msg server_var(wcs_z4) is the secondary weapon
}

playerget primary   secondary

Ayuto commented 5 years ago

There are two issues with your test code:

  1. You retrieve the weapon in secondary_variable and primary_variable, but you print wcs_z3 and wcs_z4
  2. You have to use es playerget instead of just playerget, because you need to expand the event var.

Nevertheless, you are right! It's not working and I will investigate this. Btw. you can ease the test code a little bit (no need to add extra complexity by using es_delayed and using an event that doesn't fire on demand. I usually use player_say or player_jump to trigger test code):

block load
{
    es_xset primary_variable 0
}

event player_jump
{
    es playerget primary primary_variable event_var(userid)
    es_msg server_var(primary_variable) is the primary weapon
}