This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Executed a command on the chat in specific areas.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Misterpown
Senior Member
Join Date: Jan 2011
Old 06-05-2013 , 17:09   Executed a command on the chat in specific areas.
Reply With Quote #1

As stated in the title, I would like that when a player approaches a specific coordinated, the command !bank was said for the player.

For example:
X: 475.773590
Y: 2037.401611
Z: 7.968750
If the player approaches its coordinates, the command !bank that said in the chat.

Thank you for your help
Misterpown is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 06-05-2013 , 17:14   Re: Executed a command on the chat in specific areas.
Reply With Quote #2

The best way I can think of is to create a non-solid brush entity, and then hook it with SDKHook_StartTouch.
ddhoward is offline
Misterpown
Senior Member
Join Date: Jan 2011
Old 06-05-2013 , 17:20   Re: Executed a command on the chat in specific areas.
Reply With Quote #3

Thank for your fast reply.

I want config a lot entity : trigger_multiple named ATM
This is possible through your solution? Because I do not really understand how it works :/
Misterpown is offline
API
Veteran Member
Join Date: May 2006
Old 06-05-2013 , 17:49   Re: Executed a command on the chat in specific areas.
Reply With Quote #4

Why not do a little math? This is practically built in for you!

I'm not going to give you copy and paste code, but I can certainly get you close!

Code:
public Action:OnSayCommand(client) {
... first check if they said !bank ...

... and if they did say !bank, execute this ...

    new Float:bankPos[3] = {475.773590, 2037.401611, 7.968750};
    new Float:clientPos[3];

    GetClientAbsOrigin(client, clientPos);

    // Now that we have the position of the client and the position of the "bank", let's get the distance between
    new Float:distance = GetVectorDistance(bankPos, clientPos);

    if(distance < 100) {
        ... they are less than 100 units away, they are close enough! ...
    }
}
EDIT: If I misunderstood, you might need a timer / OnGameFrame instead. You could accomplish a "trigger" using this method.
__________________

Last edited by API; 06-05-2013 at 17:50.
API is offline
Send a message via AIM to API
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 06-05-2013 , 19:45   Re: Executed a command on the chat in specific areas.
Reply With Quote #5

To clarify, the plugin should not be checking if the player typed !bank. He wants to have FakeClientCommand(client, "say !bank") run upon the person entering a given area.

And yeah, if you use something akin to pimpinjuice's method, you need to specify some sort of event that checks to see if a person is within that range. (Such as a looping timer or OnGameFrame) You also need to ensure that the command is not run multiple times; clients may be kicked for spamming chat otherwise.
ddhoward is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 06-05-2013 , 20:52   Re: Executed a command on the chat in specific areas.
Reply With Quote #6

You could just as easily check coordinate zones in a loop. Ontouch fires extremely rapidly... Just store time of command in a time variable and compare to gametime or enginetime inyiur timer loop so you do not execute too frequently.

Ex:
If(clientinzone && clienttime < time)
{
Runcommand

Clienttime = time + delay
}

Fakeclientcommands wont kick you for spam.. And you send it via sm_command if you have to use fakeclientcommand, not say.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.

Last edited by friagram; 06-05-2013 at 20:53.
friagram 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 14:32.


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