AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved VIP Plugin (help) (https://forums.alliedmods.net/showthread.php?t=336036)

Furi 01-23-2022 14:59

VIP Plugin (help)
 
Hello!
Im a beginner who started to learn sourcepawn like 1 week ago. My first project was to make a working vip menu wich includes a menu where u can find options to use sm_votekick and sm_voteban, I studied a little bit and i wrote a menu script wich has both of the options but now i dont know what i need to add to make those commands on the list really work when they are used.

php code:
PHP Code:

#include <sourcemod>

#pragma semicolon 1
#pragma newdecls required

public void OnPluginStart() {
    
    
RegConsoleCmd("sm_vip"Command_VIP"Diplays a VIP menu");
}

public 
Action Command_VIP(int clientint args) {
    
Menu menu = new Menu(Menu_Callback);
    
menu.SetTitle("Vip Menu :)");
    
menu.AddItem("Votekick""Votekick"); 
    
menu.AddItem("Voteban""Voteban"); 
    
menu.Display(client30); 
    return 
Plugin_Handled;
}

public 
int Menu_Callback(Menu menuMenuAction actionint param1int param2
{
    switch (
action) {
        case 
MenuAction_Select:
        {
            
char item[32];
            
menu.GetItem(param2itemsizeof(item));
            
            if (
StrEqual(item"Votekick")) {
                
            }
            else if (
StrEqual(item"Voteban")) {
                
            }
        }
        case 
MenuAction_End:
        {
            
delete menu
        }
    }



I would appreciate any help to get this working!

Cruze 01-23-2022 16:04

Re: VIP Plugin (help)
 
PHP Code:

#include <sourcemod>

#pragma semicolon 1
#pragma newdecls required

public void OnPluginStart() {
    
    
RegAdminCmd("sm_vip"Command_VIPADMFLAG_RESERVATION"Diplays a VIP menu");
}

public 
Action Command_VIP(int clientint args) {
    
Menu menu = new Menu(Menu_Callback);
    
menu.SetTitle("Vip Menu :)");
    
menu.AddItem("Votekick""Votekick"); 
    
menu.AddItem("Voteban""Voteban"); 
    
menu.Display(client30); 
    return 
Plugin_Handled;
}

public 
int Menu_Callback(Menu menuMenuAction actionint param1int param2
{
    switch (
action) {
        case 
MenuAction_Select:
        {
            
char item[32];
            
menu.GetItem(param2itemsizeof(item));
            
            if (
StrEqual(item"Votekick")) {
                
ClientCommand(param1"sm_votekick");
            }
            else if (
StrEqual(item"Voteban")) {
                
ClientCommand(param1"sm_voteban");
            }
        }
        case 
MenuAction_End:
        {
            
delete menu
        }
    }



Furi 01-23-2022 16:31

Thanks man! Really Appreciate the help! it still gives undefined symbol "client" on lines 38 and 41, not sure whats wrong with that

PC Gamer 01-24-2022 00:41

Re: VIP Plugin (help)
 
Quote:

Originally Posted by Furi (Post 2769168)
Thanks man! Really Appreciate the help! it still gives undefined symbol "client" on lines 38 and 41, not sure whats wrong with that

Change this:
PHP Code:

            if (StrEqual(item"Votekick")) {
                
ClientCommand(client"sm_votekick");
            }
            else if (
StrEqual(item"Voteban")) {
                
ClientCommand(client"sm_voteban");
            } 

to read this:
PHP Code:

            if (StrEqual(item"Votekick")) {
                
ClientCommand(param1"sm_votekick");
            }
            else if (
StrEqual(item"Voteban")) {
                
ClientCommand(param1"sm_voteban");
            } 

When using menus the client becomes param1

Furi 01-24-2022 02:21

Re: VIP Plugin (help)
 
Thank you! i was thinking about that when i was reading the code and thinking but just didn't try it for some reason :D!

Cruze 01-24-2022 04:38

Re: VIP Plugin (help)
 
Quote:

Originally Posted by PC Gamer (Post 2769197)
Change this:
PHP Code:

            if (StrEqual(item"Votekick")) {
                
ClientCommand(client"sm_votekick");
            }
            else if (
StrEqual(item"Voteban")) {
                
ClientCommand(client"sm_voteban");
            } 

to read this:
PHP Code:

            if (StrEqual(item"Votekick")) {
                
ClientCommand(param1"sm_votekick");
            }
            else if (
StrEqual(item"Voteban")) {
                
ClientCommand(param1"sm_voteban");
            } 

When using menus the client becomes param1

Oh yeah, I didn't check that ._. Thanks for correcting that out


All times are GMT -4. The time now is 00:32.

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