SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 04/04/2016, 08:34 PM   #1
Loinal
Gangsta
 
Loinal's Avatar
 
Join Date: Feb 2016
Posts: 817
Reputation: 9
Default TopRich

iam trying to make /toprich command in my gamemode but i cant need help
Loinal is offline   Reply With Quote
Old 04/04/2016, 08:42 PM   #2
Golden96
Little Clucker
 
Golden96's Avatar
 
Join Date: Mar 2016
Posts: 31
Reputation: 0
Default Re: TopRich

What's wrong with it?
Golden96 is offline   Reply With Quote
Old 04/04/2016, 10:30 PM   #3
Barnwell
Banned
 
Join Date: May 2014
Location: England
Posts: 549
Reputation: 40
Post Re: TopRich

If you can't
i make one for you

pawn Code:
CMD:richlist(playerid, params[])//509
{
    if(IsPlayerConnected(playerid))
    {
        SCM(playerid, COLOR_GRAD3, "Rich Users online:");
        new string[128];
        foreach(Player, i)
        {
            if(IsPlayerConnected(i))
            {
                if(GetPlayerCash(i) >= 100000 || PlayerInfo[i][pAccount] >= 100000)
                {
                    format(string, sizeof(string), "%s (%d) - In Hand: $%d | In Bank: $%d", GPN(i), i, GetPlayerCash(i), PlayerInfo[i][pAccount]);
                    SCM(playerid, COLOR_GRAD1, string);
                }
            }
        }
    }
    return 1;
}
Barnwell is offline   Reply With Quote
Old 04/04/2016, 10:32 PM   #4
Barnwell
Banned
 
Join Date: May 2014
Location: England
Posts: 549
Reputation: 40
Default Re: TopRich

and add that
pawn Code:
enum pInfo
{
pAccount
};
Or if you already have paccount or something like that
you will change paccount example: pmoney like that
DONT FORGET!!!
Barnwell is offline   Reply With Quote
Old 05/04/2016, 03:24 AM   #5
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,243
Reputation: 525
Default Re: TopRich

Quote:
Originally Posted by Loinal View Post
iam trying to make /toprich command in my gamemode but i cant need help
Remember, this is Scripting Help, not Scripting Requests...
Sew_Sumi is offline   Reply With Quote
Old 05/04/2016, 02:03 PM   #6
Barnwell
Banned
 
Join Date: May 2014
Location: England
Posts: 549
Reputation: 40
Default Re: TopRich

I know, But im helping him
Barnwell is offline   Reply With Quote
Old 05/04/2016, 03:53 PM   #7
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,243
Reputation: 525
Default Re: TopRich

Quote:
Originally Posted by Barnwell View Post
I know, But im helping him
You may think you are, but you're not...


And the statement was to him, directly, about the fact that this is a common occurence...


"Oh I'm just trying to make XXX command for my server, and I can't get this working, can someone help me"

"Sure, Pastes up command"

"Can't get it working"

"Try this"

"Nope, still not working, Anyone please, I need this for my server"

"Hope this works"

"Nope doesn't"


This is what the threads generally end up as.

And, furthermore, there are rules about these sections, one of which, is not posting up untested code, another of which is not to post up topics like these without code, and best of all, that this section isn't for requests, but help.


And this, isn't help. They're not learning, and you are simply pasting up attempts.
Sew_Sumi is offline   Reply With Quote
Old 05/04/2016, 03:55 PM   #8
SyS
High-roller
 
SyS's Avatar
 
Join Date: Oct 2015
Posts: 1,939
Reputation: 504
Default Re: TopRich

Quote:
Originally Posted by Sew_Sumi View Post
You may think you are, but you're not...


And the statement was to him, directly, about the fact that this is a common occurence...


"Oh I'm just trying to make XXX command for my server, and I can't get this working, can someone help me"

"Sure, Pastes up command"

"Can't get it working"

"Try this"

"Nope, still not working, Anyone please, I need this for my server"

"Hope this works"

"Nope doesn't"


This is what the threads generally end up as.

And, furthermore, there are rules about these sections, one of which, is not posting up untested code, another of which is not to post up topics like these without code, and best of all, that this section isn't for requests, but help.


And this, isn't help. They're not learning, and you are simply pasting up attempts.
Absolutely right i agree with him.People should know the basics before doing anything
SyS is offline   Reply With Quote
Old 05/04/2016, 04:16 PM   #9
OmegaKiller72
Big Clucker
 
Join Date: Sep 2013
Location: Ukraine
Posts: 92
Reputation: 0
Default Re: TopRich

Quote:
Originally Posted by Barnwell View Post
If you can't
i make one for you

pawn Code:
CMD:richlist(playerid, params[])//509
{
    if(IsPlayerConnected(playerid))
    {
        SCM(playerid, COLOR_GRAD3, "Rich Users online:");
        new string[128];
        foreach(Player, i)
        {
            if(IsPlayerConnected(i))
            {
                if(GetPlayerCash(i) >= 100000 || PlayerInfo[i][pAccount] >= 100000)
                {
                    format(string, sizeof(string), "%s (%d) - In Hand: $%d | In Bank: $%d", GPN(i), i, GetPlayerCash(i), PlayerInfo[i][pAccount]);
                    SCM(playerid, COLOR_GRAD1, string);
                }
            }
        }
    }
    return 1;
}
Where is your looping throw all connected players?
OmegaKiller72 is offline   Reply With Quote
Old 05/04/2016, 04:26 PM   #10
AndySedeyn
High-roller
 
AndySedeyn's Avatar
 
Join Date: Feb 2014
Location: Belgium
Posts: 1,207
Reputation: 681
Default Re: TopRich

Quote:
Originally Posted by Sew_Sumi View Post
You may think you are, but you're not...


And the statement was to him, directly, about the fact that this is a common occurence...


"Oh I'm just trying to make XXX command for my server, and I can't get this working, can someone help me"

"Sure, Pastes up command"

"Can't get it working"

"Try this"

"Nope, still not working, Anyone please, I need this for my server"

"Hope this works"

"Nope doesn't"


This is what the threads generally end up as.

And, furthermore, there are rules about these sections, one of which, is not posting up untested code, another of which is not to post up topics like these without code, and best of all, that this section isn't for requests, but help.


And this, isn't help. They're not learning, and you are simply pasting up attempts.
The sad reality of this section. Most of the people who post in these help topics do it hoping they'd get fast reputation by spoon-feeding (outdated/incorrect) code.

Sometimes spoon-feeding correct code is the best option to go with, though. The reason I say that is because roughly 70% of the topics created in this section are made by people that need things fast and don't care if you're trying to teach them something -- they don't have the time to do it themselves so they seek out a fast solution. And if you do spend some time replying with an explanatory reply, they dismiss it and wait for someone to post the code they need.

Unfortunately, nothing we can do.

Quote:
Originally Posted by Barnwell View Post
If you can't
i make one for you

pawn Code:
CMD:richlist(playerid, params[])//509
{
    if(IsPlayerConnected(playerid))
    {
        SCM(playerid, COLOR_GRAD3, "Rich Users online:");
        new string[128];
        foreach(Player, i)
        {
            if(IsPlayerConnected(i))
            {
                if(GetPlayerCash(i) >= 100000 || PlayerInfo[i][pAccount] >= 100000)
                {
                    format(string, sizeof(string), "%s (%d) - In Hand: $%d | In Bank: $%d", GPN(i), i, GetPlayerCash(i), PlayerInfo[i][pAccount]);
                    SCM(playerid, COLOR_GRAD1, string);
                }
            }
        }
    }
    return 1;
}
O.T.: your code isn't entirely correct. It's not possible for playerid to log off within milliseconds of executing the command making the first IsPlayerConnected redundant.

Furthermore, your foreach syntax is outdated and the IsPlayerConnected check under it is also redundant since foreach does something like that internally:
PHP Code:
foreach(new Player
I only recently learned this, but params is unused so you can leave it out:
PHP Code:
CMD:richlist(playerid
This makes it easier to return the command if ever needed:
PHP Code:
return cmd_richlist(playerid); 
While if you were to have the params parameter in it, you have to include that as an argument too (even though it's not used):
PHP Code:
return cmd_richlist(playerid" "); // unsure if "" works 
AndySedeyn is offline   Reply With Quote
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



All times are GMT. The time now is 11:39 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.