Raised This Month: $ Target: $400
 0% 

Master Reset


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Waleed
Senior Member
Join Date: May 2012
Location: Pakistan
Old 06-21-2012 , 14:37   Master Reset
Reply With Quote #1

Hey there,
I added a small "reset" and "master reset" function in my plugin that resets user deaths and frags,
Reset system is working,Changing the deaths and frags to zero;

PHP Code:
public cmd_reset(id)
{
    
cs_set_user_deaths(id0)
    
set_user_frags(id0)


But,"Master Reset" is not working;

PHP Code:
public cmd_mreset(id)
{
    
cs_set_user_deaths(00
    
set_user_frags(00)


I thought that changing the index to zero means every player but its not working and giving console errors

  • L 06/21/2012 - 23:158: [CSTRIKE] Player out of range (0)
  • L 06/21/2012 - 23:158: [AMXX] Run time error 10: native error (native "cs_set_user_deaths")

I know these errors are because of that O zero index,But I don't know how to do trigger it for all players.
Note: Master Reset will be used by admins,I will add admins checks later on.
__________________
Working On:
  1. Gameplay 1 - 0% [PAUSED]
Waleed is offline
Send a message via Skype™ to Waleed
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-21-2012 , 14:38   Re: Master Reset
Reply With Quote #2

Use get_players with flag "h" and loop though the list.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-21-2012 , 14:40   Re: Master Reset
Reply With Quote #3

loop through the players. not using id as 0.

Because you're learning...i throw you a bone. get_players(players, num, "h")
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
Waleed
Senior Member
Join Date: May 2012
Location: Pakistan
Old 06-21-2012 , 14:49   Re: Master Reset
Reply With Quote #4

I searched wiki about get_players,
Tell me why to use num?
and "h" will skip HLTV,What is HLTV why to skip it?

By the way,I haven't done looping yet since beginning(by myself),Can you explain me?
I have read tutorials about it,But need little more about looping.
I know,I am asking allot about these,I am sure you will help,Thanks!
__________________
Working On:
  1. Gameplay 1 - 0% [PAUSED]
Waleed is offline
Send a message via Skype™ to Waleed
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-21-2012 , 15:10   Re: Master Reset
Reply With Quote #5

Haven't we already told you to read the documentation?

http://www.amxmodx.org/doc/index.htm...g%2Fprimer.htm
Learn before you ask again. We get grouchy when you ask stupid, remedial, basic questions.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
pokemonmaster
princess milk
Join Date: Nov 2010
Location: Somewhere in this world
Old 06-21-2012 , 15:31   Re: Master Reset
Reply With Quote #6

Here is an example of looping (from my experience xD):
PHP Code:
public cmd_mreset(id)
{
    new 
players[32], count
    get_players
(playerscounth)

    for(new 
ii<counti++)
    {
        
cs_set_user_deaths(i0)  
        
set_user_frags(i0)          // This as I know needs the fun include
    
}


Last edited by pokemonmaster; 06-21-2012 at 15:34.
pokemonmaster is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-21-2012 , 15:35   Re: Master Reset
Reply With Quote #7

Quote:
Originally Posted by pokemonmaster View Post
Here is an example of looping (from my experience xD):
PHP Code:
public cmd_mreset(id) {

          new 
players[32], count
          get_players
(playerscounth)

          for(new 
ii<counti++) {
                     
cs_set_user_deaths(i0)  
                     
set_user_frags(i0)          // This as I know needs the fun include
                     
}

two things wrong.
1. h needs to be in quotes. its passed as a string
2. i is an index of the players array (you're iterating through it), not playerID. players is an array of valid playerIDs.

EDIT: did you guys read the wiki at all!? It tells you THIS EXACT CODE on the page. GO!
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 06-21-2012 at 15:39.
Liverwiz is offline
pokemonmaster
princess milk
Join Date: Nov 2010
Location: Somewhere in this world
Old 06-21-2012 , 15:54   Re: Master Reset
Reply With Quote #8

Quote:
Originally Posted by Liverwiz
two things wrong.
1. h needs to be in quotes. its passed as a string
So that's why it was giving me errors. LOL

Quote:
Originally Posted by Liverwiz
2. i is an index of the players array (you're iterating through it), not playerID. players is an array of valid playerIDs.
So the correct one will be this?
PHP Code:
public cmd_mreset(id)
{
    new 
players[32], count
    get_players
(playerscount"h")

    for(new 
ii<counti++)
    {
        
cs_set_user_deaths(players[i], 0)  
        
set_user_frags(players[i], 0)
    }


Last edited by pokemonmaster; 06-21-2012 at 15:56.
pokemonmaster is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-21-2012 , 16:00   Re: Master Reset
Reply With Quote #9

Quote:
Originally Posted by pokemonmaster View Post
So the correct one will be this?
PHP Code:
public cmd_mreset(id)
{
    new 
players[32], count
    get_players
(playerscount"h")

    for(new 
ii<counti++)
    {
        
cs_set_user_deaths(players[i], 0)  
        
set_user_frags(players[i], 0)
    }

yes.
and to make it even faster....
Code:
new player = players[i]
and use player instead of players[i]
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-21-2012 , 16:01   Re: Master Reset
Reply With Quote #10

Quote:
Originally Posted by Liverwiz View Post
yes.
and to make it even faster....
Code:
new player = players[i]
and use player instead of players[i]
Be sure the variable is created outside the loop and assigned to the player id inside the loop.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 06:14.


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