give xp plugin error

Coding Help/Re-API Supported
Post Reply
czirimbolo
Veteran Member
Veteran Member
Poland
Posts: 598
Joined: 7 years ago
Contact:

give xp plugin error

#1

Post by czirimbolo » 4 years ago

@Raheem can you help me?

L 01/20/2020 - 19:46:16: [AMXX] Displaying debug trace (plugin "ze_give_xp.amxx", version "1.0")
L 01/20/2020 - 19:46:16: [AMXX] Run time error 10: native error (native "ze_set_user_xp")
L 01/20/2020 - 19:46:16: [AMXX] [0] ze_give_xp.sma::Cmd_GiveXP (line 35)
  1. #include <zombie_escape>
  2. #include <ze_levels>
  3.  
  4. #define ACCESS ADMIN_RCON
  5.  
  6. public plugin_init ()
  7. {
  8.     register_plugin("[ZE] Give XP", "1.0", "?")
  9.     register_clcmd("ze_givexp", "Cmd_GiveXP", ACCESS, "- ze_givexp <name> <amount>")
  10. }
  11.  
  12. public Cmd_GiveXP(id)
  13. {
  14.     if (!(get_user_flags(id) & ACCESS))
  15.     {
  16.         client_print(id, print_console, "You have no access to that command")
  17.         return PLUGIN_HANDLED
  18.     }
  19.    
  20.     new szName[32], szAmount[10]
  21.    
  22.     read_argv (1, szName, charsmax (szName))
  23.     read_argv (2, szAmount, charsmax (szAmount))
  24.    
  25.     new iTargetIndex = get_user_index(szName)
  26.    
  27.     if (!iTargetIndex)
  28.     {
  29.         client_print(id, print_console, "[ZE] Player not found!")
  30.         return PLUGIN_HANDLED
  31.     }
  32.    
  33.     new iXPAmout = str_to_num (szAmount)
  34.    
  35.     ze_set_user_xp(iTargetIndex, ze_get_user_xp(iTargetIndex) + iXPAmout)
  36.     return PLUGIN_HANDLED
  37. }
Image

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#2

Post by Raheem » 4 years ago

Check if the targeted user connected or not:
    1. #include <zombie_escape>
    2. #include <ze_levels>
    3.  
    4. #define ACCESS ADMIN_RCON
    5.  
    6. public plugin_init ()
    7. {
    8.     register_plugin("[ZE] Give XP", "1.0", "?")
    9.     register_clcmd("ze_givexp", "Cmd_GiveXP", ACCESS, "- ze_givexp <name> <amount>")
    10. }
    11.  
    12. public Cmd_GiveXP(id)
    13. {
    14.     if (!(get_user_flags(id) & ACCESS))
    15.     {
    16.         client_print(id, print_console, "You have no access to that command")
    17.         return PLUGIN_HANDLED
    18.     }
    19.    
    20.     new szName[32], szAmount[10]
    21.    
    22.     read_argv (1, szName, charsmax (szName))
    23.     read_argv (2, szAmount, charsmax (szAmount))
    24.    
    25.     new iTargetIndex = get_user_index(szName)
    26.    
    27.     if (!is_user_connected(iTargetIndex))
    28.         return PLUGIN_HANDLED
    29.    
    30.     if (!iTargetIndex)
    31.     {
    32.         client_print(id, print_console, "[ZE] Player not found!")
    33.         return PLUGIN_HANDLED
    34.     }
    35.    
    36.     new iXPAmout = str_to_num (szAmount)
    37.    
    38.     ze_set_user_xp(iTargetIndex, ze_get_user_xp(iTargetIndex) + iXPAmout)
    39.     return PLUGIN_HANDLED
    40. }
He who fails to plan is planning to fail

BandiT
Member
Member
Romania
Posts: 59
Joined: 4 years ago
Contact:

#3

Post by BandiT » 4 years ago

The plugin is working good, nice job

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 6 guests