Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZR_GetClassByName always return -1 #39

Open
ronglucky opened this issue Mar 26, 2022 · 1 comment
Open

ZR_GetClassByName always return -1 #39

ronglucky opened this issue Mar 26, 2022 · 1 comment

Comments

@ronglucky
Copy link

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
Copy link

ghost commented Jul 7, 2022

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");
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant