Raised This Month: $51 Target: $400
 12% 

[SOLVED]is it right so?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 05-30-2011 , 08:41   [SOLVED]is it right so?
Reply With Quote #1

PHP Code:
public Cmd_Say(id)
{
    static 
say_args[64]
    
read_args(say_argscharsmax(say_args))
    
remove_quotes(say_args)

    if(
say_args[0] != '/')
    {
        return 
PLUGIN_CONTINUE
    
}
    if(
equali(say_args"/stop") || equali(say_args"/reset") )
    {
        if(
task_exists(id))
        {
            
remove_task(id)
        }
        
users_time[id] = 0.0
        user_is_in_time
[id] = 0
        users_fail
[id] = 0
        ColorChat
(id,NORMAL,"^04%s ^01: You stopped successfully your Timer!",tag)
        
        new 
ent = -1
        
while((ent find_ent_by_class(ent,"trigger_teleport")))
        {
            new 
target[32]
            
peventpev_targettarget31)

            if(
equal(target,"start_point"))
            {
                new 
Float:vTele[3]                
                
get_brush_entity_origin(entvTele)
                
client_print(0,print_chat,"Entity : %f - %f - %f",vTele[0],vTele[1],vTele[2])
                if(
is_user_alive(id))
                {
                    
set_pev(id,pev_origin,vTele)
                    
strip_user_weapons(id)
                    
give_item(id,"weapon_knife")
                }
            }
        }
    }
    return 
PLUGIN_CONTINUE

or is there a better way to do it?
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 05-30-2011 , 09:44   Re: is it right so?
Reply With Quote #2

- You don't need to check task_exists.
- You don't need to search for entities if player is not alive (right?)
- You can just make players touch the teleport instead of setting their origin (fake_touch)
- You can just register commands isntead of manually checking in "say" hook
__________________
xPaw is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 05-30-2011 , 10:31   Re: is it right so?
Reply With Quote #3

Quote:
Originally Posted by xPaw View Post
- You don't need to check task_exists.
- You don't need to search for entities if player is not alive (right?)
- You can just make players touch the teleport instead of setting their origin (fake_touch)
- You can just register commands isntead of manually checking in "say" hook
thanks.
i will do it with fake touch and remove the if.
and yop your right. i have to check if my user is alive. my bad.

i have to add more commands. thats why i hook the say cmd.
there willbe more say cmds.

thanks again.
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-30-2011 , 11:54   Re: is it right so?
Reply With Quote #4

Quote:
Originally Posted by One View Post
i have to add more commands. thats why i hook the say cmd.
there willbe more say cmds.
Amount of commands is not a good reason, if you don't need something dynamic, use register_clcmd.

By dynamic i mean /stop + args.
And if you need it, it's still better to let other cmds with register_clcmd, let all checks be made by amxx is more efficient.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 05-30-2011 , 12:14   Re: [SOLVED]is it right so?
Reply With Quote #5

oki :-D
i just tought its better to spamm the code with many register_clcmds.
thanks connor.
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
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 01:33.


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