Need help!!
Hi guys,I am interested in developing a plugin for cs 1.6..but I don't know where to start.I have a good knowledge of c language.so can you guys give me the link for the same.
Thanks in advance:):wink: |
Re: Need help!!
|
Re: Need help!!
Thank you bro for replying.will read that thread... Will posts my doubt's here...if u don't mind. :):wink:
|
Re: Need help!!
I'll wait. Hopefully I can help you as I'm also still learning.
|
Re: Need help!!
public cmd_hp(id, level, cid)
{ if (!cmd_access(id, level, cid, 3)) return PLUGIN_HANDLED new Arg1[24] new Arg2[4] //Get the command arguments from the console read_argv(1, Arg1, 23) read_argv(2, Arg2, 3) //Convert the health from a string to a number new Health = str_to_num(Arg2) //Is the first character the @ symbol? if (Arg1[0] == '@') { new Team = 0 //Check which team was specified. //Note that we start from [1], this is okay // it just means the @ isn't included if (equali(Arg1[1], "CT")) { Team = 2 } else if (equali(Arg1[1], "T")) { Team = 1 } new players[32], num //This function will fill the players[32] variable // with valid player ids. num will contain the number // of players that are valid. get_players(players, num) new i for (i=0; i<num; i++) { if (!Team) { //Set this player's health set_user_health(players[i], Health) } else { if (get_user_team(players[i]) == Team) { set_user_health(players[i], Health) } } } } else { //finds a player id that matches the partial name given //the 1 means that it will not target the player if he // has immunity access new player = cmd_target(id, Arg1, 1) if (!player) { //this will print a message to the user who tried the command //The format for this command is called "format()" style, // where the first string formats the message according // to any number of following parameters. // %s means a string // %d or %i means an integer // %f means a float // so "Hello %s, I am %d years old" will // require a string and integer to follow console_print(id, "Sorry, player %s could not be found or targetted!", Arg1) return PLUGIN_HANDLED } else { set_user_health(player, Health) } } return PLUGIN_HANDLED } i was reading the intro to amx scripting thread ..and i have a couple of doubts : 1.what is the use/meaning of this read_argv(1, Arg1, 23) read_argv(2, Arg2, 3) 2.why we have to Convert the health from a string to a number? can you please tell me what is use/meaning of the following statements if (Arg1[0] == '@') { new Team = 0 //Check which team was specified. //Note that we start from [1], this is okay // it just means the @ isn't included if (equali(Arg1[1], "CT")) { Team = 2 } else if (equali(Arg1[1], "T")) { Team = 1 } new players[32], num //This function will fill the players[32] variable // with valid player ids. num will contain the number // of players that are valid. Thanks in advance |
Re: Need help!!
First of all, please use php tag to show your code:
PHP Code:
amx_freeHP zmd94 90: 1. zmd94 = is the first argument. 2. 90 = is the second argument For second question: why we need to convert the health from a string to a number? PHP Code:
Lastly: PHP Code:
1. If you write amx_freeHP @ 100 = It will give all players free 100 health. 2. If you write amx_freeHP @CT 100 = It will give all counter-terrorist free 100 health. 3. If you write amx_freeHP @T 100 = It will give all terrorist free 100 health. If I'm wrong, please correct me. ;) |
Re: Need help!!
Thanks for the reply mate :)
Just one more doubt:P What is the meaning of if(!team)? |
Re: Need help!!
Its mean, the team is not being specified whether T team or CT team.
|
Re: Need help!!
if(!var) is the same as if(var==0) and check if the given variable is 0(false). When dealing with teams it is unassigned team(not t, ct or spec). If you use cstrike module the const is CS_TEAM_UNASSIGNED which is 0. This is why it checks like that.
PHP Code:
PHP Code:
You will notice some differences between it and C: -no pointers -no types. Because everything is a integer cell we use tags for floats and booleans. A string is an array of cells. -etc PHP Code:
The last cell from an array must be the null item, defined as EOS in amxx.(end of string) If you try to store something in SomeArray[5] you can't. So the usable cells of an array are from 0 to sizeof -1(defined as charsmax(string)) To remove the tag from a variable use _: in front of it's name. It's also used for enumeration(enum) when you want to untag it. To check if the two variable tags match you can use tagof operator(read in pawn manual about it). |
Re: Need help!!
//This function will switch slots a and b inside any array passed to this function.
swap_slots(array[], a, b) { //Note, you need to temporarily hold one of the slots before swapping them //Otherwise, you can't swap both values! This is a classic problem. //If you have a and b, setting b equal to a eliminates the original value in b. new temp temp = array[b] array[b] = array[a] array[a] = temp } new myArray[2] myArray[0] = 5 myArray[1] = 6 swap_slots(myArray, 0, 1) //myArray[0] is 6, myArray[1] is 5 Please tell me the use of the above statements ...and why shld we switch slots a and b? Once again thanks for the replies u gave guys...:):fox: |
Re: Need help!!
Please use php tags around the code, it's hard to read as you wrote it. You should do it if you need in your plugin.
Not a fixed usage. It's the same as swapping two variables values PHP Code:
|
Re: Need help!!
I don't know that. Nice explanation, HamletEagle.
|
Re: Need help!!
Not a big deal, you save the first one value, you make the first one equal to the last one and then the last one equal to the value that you saved at first step. This is because when you do var = var2 you loose var value and doing var2 = var will make both of them to have the same value as it was in var2.
PHP Code:
|
Re: Need help!!
What ? I've already answered your question.
|
Re: Need help!!
thank you :)
|
Re: Need help!!
PHP Code:
PHP Code:
|
Re: Need help!!
|
Re: Need help!!
@zmd94 how to get a players score i mean.... i want an if statement like this
PHP Code:
|
Re: Need help!!
|
Re: Need help!!
Call it a native, since most of the functions that we use are called natives(if they come from another plugin or module).
You should search on the forum before asking simple questions, I mean, you will find the answer easier. |
| All times are GMT -4. The time now is 02:49. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.