Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8513547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:36:07+00:00 2026-06-11T04:36:07+00:00

Pretty straight forward question, I’ve just forgotten the correct coding to do it. I

  • 0

Pretty straight forward question, I’ve just forgotten the correct coding to do it. I have a void set up and I want it to run when I click a button.

Void I want executed:

    public void giveWeapon(int clientIndex, string weaponName)
    {

        uint guns = getWeaponId(weaponName);

        XDRPCExecutionOptions options = new XDRPCExecutionOptions(XDRPCMode.Title, 0x822728F8);  //Updated
        XDRPCArgumentInfo<uint> info = new XDRPCArgumentInfo<uint>(getPlayerState(clientIndex));
        XDRPCArgumentInfo<uint> info2 = new XDRPCArgumentInfo<uint>((uint)guns);
        XDRPCArgumentInfo<uint> info3 = new XDRPCArgumentInfo<uint>((uint)0);
        uint errorCode = xbCon.ExecuteRPC<uint>(options, new XDRPCArgumentInfo[] { info, info2, info3 });
        iprintln("gave weapon: " + (guns.ToString()));
        giveAmmo(clientIndex, guns);
        //switchToWeapon(clientIndex, 46);

    }

And I just want it to run on button click:

    private void button14_Click(object sender, EventArgs e)
    {
     // Call void here

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:36:09+00:00Added an answer on June 11, 2026 at 4:36 am

    void is a keyword indicating that your function giveWeapon does not return a value. So your correct question would be: “How can I call a function?”

    The answer:

    private void button14_Click(object sender, EventArgs e)
    {
        int clientIndex = 5; // use correct value
        string weaponName = "Bazooka"; // use correct value
        giveWeapon(clientIndex, weaponName);
    }
    

    if giveWeapon is defined in a different class, you’d need to create an instance and call the method on that instance, i.e.:

    ContainingClass instance = new ContainingClass();
    instance.giveWeapon(clientIndex, weaponName);
    

    As a side note, your code readability would benefit a lot from using implicitly typed local variables:

    public void giveWeapon(int clientIndex, string weaponName)
    {
        uint guns = getWeaponId(weaponName);
    
        var options = new XDRPCExecutionOptions(XDRPCMode.Title, 0x822728F8);  //Updated
        var info = new XDRPCArgumentInfo<uint>(getPlayerState(clientIndex));
        var info2 = new XDRPCArgumentInfo<uint>(guns); // guns is already uint, why cast?
        var info3 = new XDRPCArgumentInfo<uint>(0); // same goes for 0
        uint errorCode = xbCon.ExecuteRPC<uint>(options, new XDRPCArgumentInfo[] { info, info2, info3 });
        iprintln("gave weapon: " + guns); // ToString is redundant
        giveAmmo(clientIndex, guns);
        //switchToWeapon(clientIndex, 46);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Pretty straight forward question, I have a GtkEntry widget that I want to set
This question is pretty straight forward, I literally just want to stream video of
this may sound pretty straight forward, but still I want to post this question
So! My question is pretty straight forward, I have a website (Build in ASP.NET
It's a pretty straight forward question. I have my main window in a WPF
Hey, thanks in advance for the help. I have another pretty straight forward question.
Pretty straight forward question: I have page--front.tpl and page.tpl template pages in use in
I've got a pretty straight forward question regarding viewing text in Firefox. My application
This is pretty straight forward. EDIT: Updated question and added fourth echo. Here is
Well, first of all sorry about this question it must be pretty straight forward

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.