Raised This Month: $32 Target: $400
 8% 

Solved I need Author's to have a look?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Darkwob
BANNED
Join Date: Oct 2018
Old 05-15-2021 , 07:35   I need Author's to have a look?
Reply With Quote #1

I want to make Changes to an Add-on I have, but I can't do it. A command in the plugin changes your team if you type the !join command again when you join a team. I want to block it and print a message on the screen with a print hint text, but I couldn't do it. I get errors when I want to compile.

this is code
PHP Code:
    if(JoinRandomTeam == true) {
    
PrintHintText("You've already entered the %i team. don't change team"client);
    } 
this error
HTML Code:
/home/groups/sourcemod/upload_tmp/phprRNcHi.sp(180) : error 130: cannot coerce functions to values
/home/groups/sourcemod/upload_tmp/phprRNcHi.sp(181) : error 035: argument type mismatch (argument 1)
This is all source code
PHP Code:
public Action:JoinRandomTeam(clientargs) {

    if (
client <= || client MaxClients || !IsClientInGame(client)) {
        return 
Plugin_Handled;
    }

    new 
team GetClientTeam(client);
    if(
team 1) {
        
PrintHintText(client"You've already entered the %i team already. don't change team"team);
        return 
Plugin_Handled;
    }

    
LogActivity(client"JoinRandomTeam");

    
GetMaxValues();

    
// See how much space is left on the teams
    
new survslots MAX_SURVIVORS TeamCount(TEAM_SURVIVOR);
    new 
infslots MAX_INFECTED TeamCount(TEAM_INFECTED);

    if (
survslots infslots)
    {
        
PerformSwitch(clientclientTEAM_SURVIVORfalse);
        return 
Plugin_Handled;
    }

    if (
infslots survslots)
    {
        
PerformSwitch(clientclientTEAM_INFECTEDfalse);
        return 
Plugin_Handled;
    }

    
// Equal slots if we got here
    
if (survslots == 0)
    {
        
PrintToChat(client"There are no open team slots to join.");
        return 
Plugin_Handled;
    }

    new 
rndteam CreateRandomInt(2,3)

    
PerformSwitch(clientclientrndteamfalse);

    return 
Plugin_Handled;



Last edited by Darkwob; 05-16-2021 at 08:25.
Darkwob is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 05-15-2021 , 12:23   Re: I need Author's to have a look?
Reply With Quote #2

Okay there are a few things wrong with what you added:

1. "JoinRandomTeam" is a function. You cannot check if it returns true or false.
2. You are checking inside OnPluginStart() which only fires once the plugin loads, so it will not check each time a player uses the command.
3. You are passing the wrong parameters to PrintHintText().

To get what you need, you must remove that whole section and instead put this inside JoinRandomTeam at the very top:
PHP Code:
if (client <= || client MaxClients || !IsClientInGame(client)) {
    return 
Plugin_Handled;
}

new 
team GetClientTeam(client);
if(
team 1) {
    
PrintHintText(client"You've already entered the %i team already. don't change team"team);
    return 
Plugin_Handled;

It should look like this:
PHP Code:
public Action:JoinRandomTeam(clientargs) {

    if (
client <= || client MaxClients || !IsClientInGame(client)) {
        return 
Plugin_Handled;
    }

    new 
team GetClientTeam(client);
    if(
team 1) {
        
PrintHintText(client"You've already entered the %i team already. don't change team"team);
        return 
Plugin_Handled;
    }

    
LogActivity(client"JoinRandomTeam");

    
GetMaxValues();

    
// See how much space is left on the teams
    
new survslots MAX_SURVIVORS TeamCount(TEAM_SURVIVOR);
    new 
infslots MAX_INFECTED TeamCount(TEAM_INFECTED);

    if (
survslots infslots)
    {
        
PerformSwitch(clientclientTEAM_SURVIVORfalse);
        return 
Plugin_Handled;
    }

    if (
infslots survslots)
    {
        
PerformSwitch(clientclientTEAM_INFECTEDfalse);
        return 
Plugin_Handled;
    }

    
// Equal slots if we got here
    
if (survslots == 0)
    {
        
PrintToChat(client"There are no open team slots to join.");
        return 
Plugin_Handled;
    }

    new 
rndteam CreateRandomInt(2,3)

    
PerformSwitch(clientclientrndteamfalse);

    return 
Plugin_Handled;


__________________
Psyk0tik is offline
Darkwob
BANNED
Join Date: Oct 2018
Old 05-15-2021 , 15:27   Re: I need Author's to have a look?
Reply With Quote #3

Quote:
Originally Posted by Crasher_3637 View Post
Okay there are a few things wrong with what you added:

1. "JoinRandomTeam" is a function. You cannot check if it returns true or false.
2. You are checking inside OnPluginStart() which only fires once the plugin loads, so it will not check each time a player uses the command.
3. You are passing the wrong parameters to PrintHintText().

To get what you need, you must remove that whole section and instead put this inside JoinRandomTeam at the very top:
PHP Code:
if (client <= || client MaxClients || !IsClientInGame(client)) {
    return 
Plugin_Handled;
}

new 
team GetClientTeam(client);
if(
team 1) {
    
PrintHintText(client"You've already entered the %i team already. don't change team"team);
    return 
Plugin_Handled;

It should look like this:
PHP Code:
public Action:JoinRandomTeam(clientargs) {

    if (
client <= || client MaxClients || !IsClientInGame(client)) {
        return 
Plugin_Handled;
    }

    new 
team GetClientTeam(client);
    if(
team 1) {
        
PrintHintText(client"You've already entered the %i team already. don't change team"team);
        return 
Plugin_Handled;
    }

    
LogActivity(client"JoinRandomTeam");

    
GetMaxValues();

    
// See how much space is left on the teams
    
new survslots MAX_SURVIVORS TeamCount(TEAM_SURVIVOR);
    new 
infslots MAX_INFECTED TeamCount(TEAM_INFECTED);

    if (
survslots infslots)
    {
        
PerformSwitch(clientclientTEAM_SURVIVORfalse);
        return 
Plugin_Handled;
    }

    if (
infslots survslots)
    {
        
PerformSwitch(clientclientTEAM_INFECTEDfalse);
        return 
Plugin_Handled;
    }

    
// Equal slots if we got here
    
if (survslots == 0)
    {
        
PrintToChat(client"There are no open team slots to join.");
        return 
Plugin_Handled;
    }

    new 
rndteam CreateRandomInt(2,3)

    
PerformSwitch(clientclientrndteamfalse);

    return 
Plugin_Handled;


Thank you for the answer. I saw my mistake and you enlighten me
Darkwob is offline
Darkwob
BANNED
Join Date: Oct 2018
Old 05-15-2021 , 15:57   Re: I need Author's to have a look?
Reply With Quote #4

It shows the teams as a numerical value in the message it gives out. How can I do this as a Survivor or an infected? I searched the forum but could not find it.

like this
You've already entered the 2 team already. don't change team

trying to do
You've already entered the Survivor team already. don't change team
or
You've already entered the İnfected team already. don't change team

Can you help with that?
Darkwob is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 05-15-2021 , 16:08   Re: I need Author's to have a look?
Reply With Quote #5

Quote:
Originally Posted by Darkwob View Post
It shows the teams as a numerical value in the message it gives out. How can I do this as a Survivor or an infected? I searched the forum but could not find it.

like this
You've already entered the 2 team already. don't change team

trying to do
You've already entered the Survivor team already. don't change team
or
You've already entered the İnfected team already. don't change team

Can you help with that?
PHP Code:
new team GetClientTeam(client);
if(
team 1) {
    new 
String:teamName[32];
    
FormatEx(teamNamesizeof(teamName), "%s", (team == 2) ? "Survivor" "Infected");
    
PrintHintText(client"You've already entered the %s team. don't change team"teamName);
    return 
Plugin_Handled;

__________________

Last edited by Psyk0tik; 05-15-2021 at 16:08.
Psyk0tik is offline
Darkwob
BANNED
Join Date: Oct 2018
Old 05-15-2021 , 17:12   Re: I need Author's to have a look?
Reply With Quote #6

Quote:
Originally Posted by Crasher_3637 View Post
PHP Code:
new team GetClientTeam(client);
if(
team 1) {
    new 
String:teamName[32];
    
FormatEx(teamNamesizeof(teamName), "%s", (team == 2) ? "Survivor" "Infected");
    
PrintHintText(client"You've already entered the %s team. don't change team"teamName);
    return 
Plugin_Handled;

working bro. thanks for everything
Darkwob is offline
Reply


Thread Tools
Display Modes

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 19:49.


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