Raised This Month: $ Target: $400
 0% 

Ice Skating!


Post New Thread Reply   
 
Thread Tools Display Modes
M249-M4A1
I <3 Mac
Join Date: May 2005
Location: Not interested
Old 10-03-2007 , 17:38   Re: Ice Skating!
Reply With Quote #21

Quote:
Originally Posted by Elite_Fallen_Angel View Post
I am taking little baby steps

Right now I am trying to figure out how to find the origin of each player and play a sound if that origin changes.

I know I will need an array and stuff but it's trying to figure out the coordinates (Origin) that's getting me...Sorry, I will take this to the scripting help section.
Here's a sample plugin on how to get a player's origin:

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Get Origin Sample"
#define VERSION "1.0"
#define AUTHOR "M249-M4A1"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_concmd("amx_origin""GetOrigin"0)
}

public 
GetOrigin(id) {
    new 
origin[3]
    
get_user_origin(idorigin)
    
    
client_print(idprint_chat"[AMXX] Your origin: %i, %i, %i"origin[0], origin[1], origin[2])

origin[3] is an array which holds 3 values, and get_user_origin fills up those 3 spaces with xyz coordinates. The elements start filling up the array origin at element 0 (origin[0]) and continue up to element 2. origin[3] contains 3 elements: 0, 1, and 2.

Maybe you know this already, but that should get you going somewhere!
__________________
M249-M4A1 is offline
Old 10-03-2007, 18:12
Elite_Fallen_Angel
This message has been deleted by Elite_Fallen_Angel.
Elite_Fallen_Angel
Member
Join Date: Dec 2006
Location: HELL.....AkA, Texas
Old 10-04-2007 , 00:36   Re: Ice Skating!
Reply With Quote #22

Well, I am having a hard time having it loop the origin checking then playing the sound if it's a different origin.

This is what I came up with and I am quite sure it's not the right way at all. Any guidance?


Code:
public plugin_precache() 
{
    precache_sound("misc/iceskate.wav")    
}
Precached the sound clip

Code:
if(arg1[0]=='1')
    {
        client_print(0,print_chat, "Get your jackets! It's Icy out there!")
        server_cmd("sv_accelerate 80;edgefriction .5;sv_friction 1;mp_footsteps 0")
        set_task(3.0,"GetOrigin",id,"",0,"b")
        
    }
    
    else
    {
        server_cmd("sv_accelerate 10;edgefriction 2;sv_friction 4;mp_footsteps 1")
        server_exec()
    }
I have it call the GetOrigin method as a looping task every 1.0 second

Code:
public GetOrigin(id)
{
    new players[32], PlayerCount, playerz[32]
    get_players(players, PlayerCount, "h")
    new origin[3]
    new i, x    
    
    if(x==0)
    {    
        for (i=0; i<PlayerCount; i++)
        {
            get_user_origin(players[i], origin)
        }
        x=1
    }
    else
    {
        for (i=0; i<PlayerCount; i++)
        {
            get_user_origin(playerz[i], origin)
        
            if(playerz[i]!=players[i])
            {
                emit_sound(players[i],CHAN_VOICE, "misc/iceskate.wav", 0.8, ATTN_NORM, 0, PITCH_NORM)
            }
        }
        x=0
    }
}
Then I have an inefficient loop within a loop to alternate between two different arrays. The arrays switch roles in holding current origins and previous origins.

If the previous array does not equal the new array then it emits a skating sound because there was movement.

So far the logic seems to make sense to me but it won't work. The sound downloads but doesn't play when moving.

Any suggestions for more efficient and working code?
__________________
amXXX The new generation......



Last edited by Elite_Fallen_Angel; 10-04-2007 at 01:14. Reason: Terminology correction
Elite_Fallen_Angel is offline
Send a message via AIM to Elite_Fallen_Angel Send a message via Yahoo to Elite_Fallen_Angel
XNaRu7oX
Senior Member
Join Date: Jan 2007
Location: LA, CA, USA
Old 10-04-2007 , 01:03   Re: Ice Skating!
Reply With Quote #23

I got a great idea to make it seem more realistic. Make it so you bounce of walls/vertical surfaces.
XNaRu7oX is offline
Elite_Fallen_Angel
Member
Join Date: Dec 2006
Location: HELL.....AkA, Texas
Old 10-04-2007 , 01:07   Re: Ice Skating!
Reply With Quote #24

Hmm, I did not know you bounced off walls at a skating rink? The idea was to imitate skating on ice.

I suppose I could make a CVAR that enables bouncy walls?

First thing first, I need to get the darn sound working.
__________________
amXXX The new generation......


Elite_Fallen_Angel is offline
Send a message via AIM to Elite_Fallen_Angel Send a message via Yahoo to Elite_Fallen_Angel
Lord_Destros
Veteran Member
Join Date: Jul 2004
Location: With stupid.
Old 10-04-2007 , 01:24   Re: Ice Skating!
Reply With Quote #25

There should be no parameter for that function for the way you currently set it up (you never used id).

For "get_players" you probably want to pass the a flag as well (skip dead players). Keep in mind that when you create "i" and "x" the values are reset to 0 hence your else statement is never executed. Your loop doesn't really do anything; it gets the origin and replaces the old values every iteration. Also, if getOrigin is called frequently, make your arrays static.

Lastly, "playerz[i]!=players[i]" compares player IDs, not origin's.
__________________
Quote:
Originally Posted by Twilight Suzuka
Don't worry m'lord. The turtles day will come.
Lord_Destros is offline
Send a message via AIM to Lord_Destros
Elite_Fallen_Angel
Member
Join Date: Dec 2006
Location: HELL.....AkA, Texas
Old 10-04-2007 , 01:30   Re: Ice Skating!
Reply With Quote #26

Ok , I fixed everything. I didn't think about the x variable resetting itself :/

How can I have the arrays compare origin of the index rather then player ID?
__________________
amXXX The new generation......


Elite_Fallen_Angel is offline
Send a message via AIM to Elite_Fallen_Angel Send a message via Yahoo to Elite_Fallen_Angel
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 10-04-2007 , 07:51   Re: Ice Skating!
Reply With Quote #27

Like so:
Code:
new frame // "x" in yours new player_origin1[33][3] ; new player_origin2[33][3]; public GetOrigin(id) {     new players[32], PlayerCount ;     get_players(players, PlayerCount, "ah")         static i         if(frame==0)     {             for (i=0; i<PlayerCount; i++)         {             get_user_origin(players[i], player_origin1[id])         }     }     else     {         for (i=0; i<PlayerCount; i++)         {             get_user_origin(players[i], player_origin2[id])                     if ( ! ( player_origin1[id][0] == player_origin2[id][0]         &&  player_origin1[id][1] == player_origin2[id][1] )         //&&  player_origin1[id][2] == player_origin2[id][2] ) )                 // we don't care if they moved up or down             {                 emit_sound(players[i],CHAN_VOICE, "misc/iceskate.wav", 0.8, ATTN_NORM, 0, PITCH_NORM)             }         }     }     frame = !frame }

Essentially.

Last edited by purple_pixie; 10-04-2007 at 11:08.
purple_pixie is offline
Lord_Destros
Veteran Member
Join Date: Jul 2004
Location: With stupid.
Old 10-04-2007 , 08:28   Re: Ice Skating!
Reply With Quote #28

Yeah, except player_origin1 and player_origin2 have an extra 3 cells attached to them and you shouldn't compare a users z-axis change (for the slight chance they fell straight down or are jumping.)
__________________
Quote:
Originally Posted by Twilight Suzuka
Don't worry m'lord. The turtles day will come.

Last edited by Lord_Destros; 10-04-2007 at 08:30.
Lord_Destros is offline
Send a message via AIM to Lord_Destros
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 10-04-2007 , 11:07   Re: Ice Skating!
Reply With Quote #29

33 is perfectly valid.

Whilst there may well be no player 0, I really can't be arsed to -1 from id every time.
It's just something I've gotten used to and I don't intend to change.

If you can notice 6 extra cells being used ...

But quite right - the z-axis is irrelevant.

Although if you really want to, naturally you can replace every instance of [id] with [id-1] and 33 with 32.

Last edited by purple_pixie; 10-04-2007 at 11:10.
purple_pixie is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 10-04-2007 , 12:03   Re: Ice Skating!
Reply With Quote #30

Code:
    if(arg1[0]=='1')     {         client_print(0,print_chat, "Get your jackets! It's Icy out there!")         server_cmd("sv_accelerate 80;edgefriction .5;sv_friction 1;mp_footsteps 0")         set_task(3.0,"GetOrigin",id,"",0,"b")             }         else     {         server_cmd("sv_accelerate 10;edgefriction 2;sv_friction 4;mp_footsteps 1")     }     server_exec()

Fixed. I would add more, but I'm at school right now (I say this because these code fixes I'm showing are extremely trivial :/).
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 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 08:28.


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