Franc1sco / sm-zombiereloaded-3-Franug-Edition

Improved version of zombiereloaded plugin with support for CS:GO and CS:S
https://forums.alliedmods.net/showthread.php?t=277597
GNU General Public License v3.0
41 stars 35 forks source link

ZR_GetClassByName always return -1 #39

Open ronglucky opened 2 years ago

ronglucky commented 2 years ago

I have test plugin to check the function unknown-1 And in my playerclasses.txt unknown-2 i did try both

ZR_GetClassByName("christmas");

and

ZR_GetClassByName("pl_christmas");

but the result always No which the function always return -1

ghost commented 2 years ago

I tested it here and it worked. But I didn't use "OnPluginStart" . Because in this phase "Server Start" the classes have not yet been loaded or depending on the number of classes there may be a delay in loading them, indicating that they do not exist. Try with hooks after "OnConfigsExecuted or OnMapStart" or add a timer.

public void OnPluginStart()
{
    CreateTimer(10.0, OnPluginStartPost);
}

public Action OnPluginStartPost(Handle Time)
{
    if(ZR_GetClassByName("christmas") != -1) //exist
    PrintToServer("christmas - Yes");
    else PrintToServer("christmas - No");

    if(ZR_GetClassByName("test_nochristmas") != -1) //no exist
    PrintToServer("christmas - Yes");
    else PrintToServer("christmas - No");
}