Approved Set Player Level

Gameplay Addons
User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

Re: Set Player Level

#11

Post by Raheem » 3 Months Ago

tmv wrote:
3 Months Ago
When you enter a comment without a name and amount, this message will be appears

Code: Select all

[ZE] Invalid Player id (7)
[AMXX] Displaying debug trace (plugin "ze_set_player_level.amxx", version "1.0")
[AMXX] Run time error 10: native error (native "ze_set_user_level")
[AMXX]    [0] ze_set_player_level.sma::Cmd_SetLevel (line 35)
I forget to check if user connected or not, that's why this error thrown, fixed here:
    1. #include <zombie_escape>
    2. #include <ze_levels>
    3.  
    4. #define ACCESS ADMIN_RCON
    5.  
    6. public plugin_init ()
    7. {
    8.     register_plugin("[ZE] Set Player Level", "1.0", "Raheem")
    9.     register_clcmd("ze_setlevel", "Cmd_SetLevel", ACCESS, "- ze_setlevel <name> <amount>")
    10. }
    11.  
    12. public Cmd_SetLevel(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 iLevel = str_to_num (szAmount)
    37.    
    38.     ze_set_user_level(iTargetIndex, iLevel)
    39.  
    40.     return PLUGIN_HANDLED
    41. }
You don't know? Learn and you will know.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests