Raised This Month: $ Target: $400
 0% 

possible to do these?


Post New Thread Reply   
 
Thread Tools Display Modes
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 12-13-2007 , 08:28   Re: possible to do these?
Reply With Quote #11

Quote:
Originally Posted by purple_pixie View Post
Because there's still an awful lot about this I don't know.
Yeah, lol, i've saw that too, i've used read_data(...) to change a model, and was not working properly, and get_user_weapon(...) solved the problem.
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 12-13-2007 , 08:39   Re: possible to do these?
Reply With Quote #12

I also like showing the sneaky technique of using your return value variable as a byref dummy argument.

The return value *has* to be set *after* all the routine code is done. So if you pass it in byref, you know that whatever happens to it will be overwritten by setting it to the return value.
purple_pixie is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 12-13-2007 , 10:22   Re: possible to do these?
Reply With Quote #13

I'd like to throw in my two cents. Checkmarks, thankfully there are some extremely nice and generous people on these forums that took the time to answer your questions. However, I feel it was wasted (somewhat). Everything you asked and they answered is already available in a multitude of plugins. What you should've done is looked/searched for plugins that accomplish your goal, see how they accomplished what you want, and apply it. And THEN, if you have problems/don't understand it come to scripting help for advice.

-Zenith
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Checkmarks
BANNED
Join Date: Sep 2007
Location: kentucky
Old 12-13-2007 , 14:59   Re: possible to do these?
Reply With Quote #14

Thanks
------
ok, i really dont understand this pixie:
" What you should do, is to have an array of player classes.

Then when they do the class menu, change that player's entry in the array.

Then on spawn, check their class from the array and do the give_item there.

EDIT: And a couple other things ...

You "on_touch" event is inside plugin_init, it seems.
And it should be "public on_touch" since it is called by CS, and not your plugin.

I know I posted "on_touch" but I forgot to make it public."
but thanks for your help yesterday, i'll just keep looking for the answers..
Checkmarks is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 12-14-2007 , 04:45   Re: possible to do these?
Reply With Quote #15

Do you by any chance have no experience with scripting or programming before AMX?

I can't think quite how to explain that lot to you ...

But I'll try.

Quote:
You "on_touch" event is inside plugin_init, it seems.
And it should be "public on_touch" since it is called by CS, and not your plugin.
You understand how you have opening / closing braces?

e.g. here is a function:

function_name(arg1)
{

}


Anything between the braces - { } - is part of that function.
You can't then start describing another function while still inside it.
Code:
public plugin_init() { ...     on_touch(id,ent)    {   ...    } }
Should look like:
Code:
public plugin_init() { ... } public on_touch(id,ent) {   ... }
Putting "public" in front of a function means that it can be called by Counter Strike.
(Well, called by AMXX ... I say CS because CS causes it to be called, really)

"plugin_init" doesn't just happen: CS says "it's plugin_init time, does anyone have a function called that", and calls them all.
on_touch gets called by CS because you tell it to (with register_forward)
Functions that are only called by bits from other functions need not be public.


As for the first bit, that's slightly more complicated.
Do you know what arrays are?

You know how you can have a global variable (one that exists all the time) ?
So you could do this:

Code:
new player_class ; public plugin_init() { ... } ...
There player_class will be a permanent variable - it exists outside of any function. It is everywhere.
But sadly, it is only one variable, and can only hold one value.
So that's great if you only have 1 player, but fairly suck if you have more.

What you need is a "group" of variables - one for each player.
This is called an "array":

Code:
new player_class[33]
It can hold 33 values:
player_class[0] ... player_class[32].

So if "id" were set to a player id (1-32), then player_class[id] gets the class of that player.

When a player chooses a class (player "id" chooses class "newclass") :
Code:
player_class[id] = newclass

And in the spawn event (after stripping weapons) you do this bit:

Code:
      switch(key)          {         case 1:            {               set_user_health(id,get_pcvar_num(bondhp)) ...
But as:
Code:
      switch(player_class[id])          {         case 1:            {               set_user_health(id,get_pcvar_num(bondhp)) ...

Last edited by purple_pixie; 12-14-2007 at 05:07.
purple_pixie is offline
Checkmarks
BANNED
Join Date: Sep 2007
Location: kentucky
Old 12-14-2007 , 14:53   Re: possible to do these?
Reply With Quote #16

some of that like the brackets I know, and some I didn't
and no, I've been coding for about 2 weeks now.
Checkmarks is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 12-15-2007 , 07:46   Re: possible to do these?
Reply With Quote #17

Do what Zenith77 said. It WILL help you get around different coding techniques. Also try http://www.amxmodx.org/funcwiki.php and http://forums.alliedmods.net/forumdisplay.php?f=83
_Master_ 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 11:12.


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