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

How to get all the player a weapon?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Doggg
Member
Join Date: Jun 2018
Old 07-10-2019 , 12:21   How to get all the player a weapon?
Reply With Quote #1

Hey, I want to make a command thats giving every client in the server deagle with one bullet. i have 0 idea how to begin this code, i looked at the api but didnt really get it (what is the deagle id?, how to set ammo to one bullet?)
i did this far :
i thought to do a for loop that will run through all players in the server and set it for them, but i have no idea how to get the players in server, and what should i do in the for. i mean like client[i]? idk..
Code:
public Action deagle(int client, int args)
{
	
  EquipPlayerWeapon(client,"CSWeapon_DEAGLE");
  
}

Last edited by Doggg; 07-10-2019 at 12:23.
Doggg is offline
Whai
Senior Member
Join Date: Jul 2018
Old 07-10-2019 , 12:44   Re: How to get all the player a weapon?
Reply With Quote #2

On the second parameter of "EquipPlayerWeapon", it has to be an integer.

You wrote the second parameter in string type (don't know if my sentence is understandable), the < "" > mean a string, so it is better to write
Code:
EquipPlayerWeapon(client,CSWeapon_DEAGLE);
(don't know if it works, I have never worked on CS plugins)

To make a loop to get all players, you do :
PHP Code:
for(int i 1<= MaxClientsi++) // Starting at 1 because the index 0 is reserved to the console/world
{
      if(
IsClientInGame(i)) // for ignoring players connecting/not connected.
            
EquipPlayerWeapon(iCSWeapon_DEAGLE);

__________________
Whai is offline
Doggg
Member
Join Date: Jun 2018
Old 07-10-2019 , 13:10   Re: How to get all the player a weapon?
Reply With Quote #3

Quote:
Originally Posted by Whai View Post
On the second parameter of "EquipPlayerWeapon", it has to be an integer.

You wrote the second parameter in string type (don't know if my sentence is understandable), the < "" > mean a string, so it is better to write
Code:
EquipPlayerWeapon(client,CSWeapon_DEAGLE);
(don't know if it works, I have never worked on CS plugins)

To make a loop to get all players, you do :
PHP Code:
for(int i 1<= MaxClientsi++) // Starting at 1 because the index 0 is reserved to the console/world
{
      if(
IsClientInGame(i)) // for ignoring players connecting/not connected.
            
EquipPlayerWeapon(iCSWeapon_DEAGLE);

yeah i understood the string thing, Thanks xD.
I thought about doing this method but it looked a bit not effective (i mean i thought there is some command that gives you the online players in the server and then you should run on the client list 1 by 1.
can you help me set the deagle ammo to one? i have no idea how to do this.
Doggg is offline
Whai
Senior Member
Join Date: Jul 2018
Old 07-10-2019 , 13:30   Re: How to get all the player a weapon?
Reply With Quote #4

Quote:
Originally Posted by Doggg View Post
yeah i understood the string thing, Thanks xD.
I think I should shut my mouth when I take people for a dummy (not mean to do). Sorry.

Quote:
Originally Posted by Doggg View Post
can you help me set the deagle ammo to one? i have no idea how to do this.
If you mean to give ammo, here is GivePlayerAmmo
write the amount of ammo high (it will stop at the max ammo).

Else, if you mean to set the max ammo, then I do not know : I just do tf2 plugin and it is different to set ammo in tf2 than others games
__________________
Whai is offline
Doggg
Member
Join Date: Jun 2018
Old 07-10-2019 , 13:43   Re: How to get all the player a weapon?
Reply With Quote #5

Quote:
Originally Posted by Whai View Post
I think I should shut my mouth when I take people for a dummy (not mean to do). Sorry.



If you mean to give ammo, here is GivePlayerAmmo
write the amount of ammo high (it will stop at the max ammo).

Else, if you mean to set the max ammo, then I do not know : I just do tf2 plugin and it is different to set ammo in tf2 than others games
Oh ok, Thanks, I am trying to find a way to set ammo in CSGO. and about the dummy thing that ok, This will help me understand something that i just dont know yet xD.
Doggg is offline
Doggg
Member
Join Date: Jun 2018
Old 07-10-2019 , 13:51   Re: How to get all the player a weapon?
Reply With Quote #6

Anybody knows how to set up weapons ammo in CSGO??
Doggg is offline
Whai
Senior Member
Join Date: Jul 2018
Old 07-10-2019 , 16:07   Re: How to get all the player a weapon?
Reply With Quote #7

I forgot to say you have to put "IsPlayerAlive" with the condition "IsClientInGame"
__________________
Whai is offline
Doggg
Member
Join Date: Jun 2018
Old 07-10-2019 , 19:41   Re: How to get all the player a weapon?
Reply With Quote #8

Quote:
Originally Posted by Whai View Post
I forgot to say you have to put "IsPlayerAlive" with the condition "IsClientInGame"
so like
Code:
if(IsClientInGame(i) && IsPlayerAlive(i))
{
code..
}
Doggg is offline
Whai
Senior Member
Join Date: Jul 2018
Old 07-10-2019 , 19:52   Re: How to get all the player a weapon?
Reply With Quote #9

Sorri, I totally forgot : I made a mystake. You have to put the IsPlayerAlive after the IsClientInGame, else it will do errors on your server console
__________________
Whai is offline
Doggg
Member
Join Date: Jun 2018
Old 07-11-2019 , 06:35   Re: How to get all the player a weapon?
Reply With Quote #10

Quote:
Originally Posted by Whai View Post
Sorri, I totally forgot : I made a mystake. You have to put the IsPlayerAlive after the IsClientInGame, else it will do errors on your server console
can you show me how you mean to write it? if and inside more if? or just switch the places? how?
Doggg 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 00:33.


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