Raised This Month: $12 Target: $400
 3% 

How do I fix - functio should return an explicit value??


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jgbc3d
Junior Member
Join Date: Apr 2011
Old 06-25-2023 , 17:34   How do I fix - functio should return an explicit value??
Reply With Quote #1

Hello people, how are you doing, I am having this error when compiling this code, what I leave here is only part of that code, not all of it. It shows me the following message "function "PlayerActivate" should return an explicit value". I want to emphasize that I don't know programming, I'm just trying to adjust and group codes to do something that works for me, I would like to know if it is possible, could you help me with this?

PHP Code:
public void OnPluginStart()
{
    
HookEvent("player_activate"PlayerActivateEventHookMode_Post);
}

public 
Action PlayerActivate(Event event, const char[] namebool dontBroadcast)
{
    
int userid event.GetInt("userid");
    
int client GetClientOfUserId(userid);
    if (
client && client <= MaxClients && !IsFakeClient(client) && GetClientTeam(client) == 2)
    {
        
SetConVarInt(FindConVar("sb_move"), 1);
    }
    else {}

jgbc3d is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 06-25-2023 , 20:00   Re: How do I fix - functio should return an explicit value??
Reply With Quote #2

you should add "return Plugin_Handled;" before the latest "}"

the message is self-explanatory, when you code something

public <X> <MyFunctionName>
if <X> is not "void" then you should "return <X value>" in places where your code exits the method/function.

Some reference info:

https://docs.oracle.com/javase/tutor...turnvalue.html
__________________

Last edited by Marttt; 06-25-2023 at 20:05.
Marttt is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:35.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode