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

[REQ] /drugs


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MiKe4444
Member
Join Date: Nov 2009
Location: 127.0.0.1
Old 07-10-2010 , 14:21   [REQ] /drugs
Reply With Quote #1

Iam searching for thats plugin...
Admin say /drugs and he get screen shake (drugs)...
MiKe4444 is offline
Lure.d
BANNED
Join Date: Dec 2009
Location: Lithuania->USA
Old 07-10-2010 , 14:41   Re: [REQ] /drugs
Reply With Quote #2

Code:
#include <amxmodx>

new bool:g_has_drugs[ 33 ];

public plugin_init( )
{
    register_plugin( "Drugs", "1.0.0", "Lure.d" );
    
    register_clcmd( "say /drugs", "cmdDrugs" );
}

public client_putinserver( client )
    g_has_drugs[ client ] = false;

public client_disconnect( client )
    g_has_drugs[ client ] = false;

public cmdDrugs( client )
{
    if( !is_user_alive( client ) )
    {
        client_print( client, print_chat, "* You must be alive to use drugs." );
        return;
    }
    message_begin( MSG_ONE, get_user_msgid( "SetFOV" ), { 0, 0, 0 }, client );
    write_byte( g_has_drugs[ client ] ? 90 : 180 );
    message_end( );
    
    g_has_drugs[ client ] = g_has_drugs[ client ] ? false : true;
}  
For newbies:

Ok lets looks more individually at the code:
Code:
register_clcmd( "say /drugs", "cmdDrugs" );
1. This gets to call cmdDrugs function on each time player writes /drugs in chat.

Code:

public client_putinserver( client )
    g_has_drugs[  client ] = false;
2. We set that when player joins our server, he wouldn't get the drugs as we don't want him to

Code:
public cmdDrugs( client )
3. This is our function which is executed when /drugs is written in chat. See 1st example.

Code:
    if( !is_user_alive( client ) )
    {
        client_print( client, print_chat, "* You must be alive to use drugs." );
        return;
    }
4. We check if user is not alive and if so, we make a message telling drugs are only for alive player, and we end function with returning.

Code:
message_begin( MSG_ONE, get_user_msgid( "SetFOV" ), { 0, 0, 0 }, client );
5. We start sending a message to a single player, using message id - set fov, and letting it pass to our client.

Code:
write_byte( g_has_drugs[ client ] ? 90 : 180 );
6. We write a byte to the message we began to send. The value of it, is outputted in this way (if our player has drugs, we set it to 90( normal view), if he don't we want him to have drugs and set the fov to 180(drug-mode).

Code:
message_end( );
7. I think we can all read this and understand what this means. And no its not bananas... it means ending the message.

Code:
g_has_drugs[ client ] = g_has_drugs[ client ] ? false : true;
8. In the end we set if client has drugs. This line is to be read like this: client has drugs = if( client has drugs ) then we don't want him to, as he typed /drugs to reverse it all. If no - well lets show him the drug powaaaaaaaa

So yeah so much for the code

Last edited by Lure.d; 07-10-2010 at 19:38.
Lure.d is offline
Send a message via Skype™ to Lure.d
Old 07-10-2010, 15:08
MiKe4444
This message has been deleted by MiKe4444. Reason: noob question...
Xalus
Veteran Member
Join Date: Dec 2009
Location: Belgium
Old 07-10-2010 , 15:14   Re: [REQ] /drugs
Reply With Quote #3

public client_putinserver( client )
g_has_drugs[ client ] = false;

public client_disconnect( client )
g_has_drugs[ client ] = false;

Connect is enough?
__________________
Retired.
Xalus is offline
MiKe4444
Member
Join Date: Nov 2009
Location: 127.0.0.1
Old 07-10-2010 , 15:19   Re: [REQ] /drugs
Reply With Quote #4

Can u make it with command /nodrugs...
Thats stops it...
MiKe4444 is offline
Lure.d
BANNED
Join Date: Dec 2009
Location: Lithuania->USA
Old 07-10-2010 , 15:21   Re: [REQ] /drugs
Reply With Quote #5

actually type /drugs again and it disables it

@xalus yea i know, i just pasted wrong version here with lots of code

Last edited by Lure.d; 07-10-2010 at 15:25.
Lure.d is offline
Send a message via Skype™ to Lure.d
MiKe4444
Member
Join Date: Nov 2009
Location: 127.0.0.1
Old 07-10-2010 , 15:25   Re: [REQ] /drugs
Reply With Quote #6

lol i am stupid

Thx...
MiKe4444 is offline
Lure.d
BANNED
Join Date: Dec 2009
Location: Lithuania->USA
Old 07-10-2010 , 15:27   Re: [REQ] /drugs
Reply With Quote #7

no ur not, you just didn't know it since you're not a coder yet...
no problem dude, glad i helped you
Lure.d is offline
Send a message via Skype™ to Lure.d
dj_freeze
Veteran Member
Join Date: Dec 2009
Location: Looking for you!
Old 07-10-2010 , 16:18   Re: [REQ] /drugs
Reply With Quote #8

Can you remake this script so when a player types /drugs his hands will get longer.. As in Zombie plague.. this will be until he types it again.
__________________
dj_freeze is offline
Send a message via Skype™ to dj_freeze
unnyquee
Senior Member
Join Date: Jun 2009
Location: Constanta, Romania
Old 07-10-2010 , 17:35   Re: [REQ] /drugs
Reply With Quote #9

I assume that you didn't tested yet ^^.
__________________
unnyquee is offline
Lure.d
BANNED
Join Date: Dec 2009
Location: Lithuania->USA
Old 07-10-2010 , 19:03   Re: [REQ] /drugs
Reply With Quote #10

I have. Also added mini-tut for newbies ;)

Last edited by Lure.d; 07-10-2010 at 19:39.
Lure.d is offline
Send a message via Skype™ to Lure.d
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 15:10.


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