AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   [REQ] /drugs (https://forums.alliedmods.net/showthread.php?t=131963)

MiKe4444 07-10-2010 14:21

[REQ] /drugs
 
Iam searching for thats plugin...
Admin say /drugs and he get screen shake (drugs)...

Lure.d 07-10-2010 14:41

Re: [REQ] /drugs
 
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_drugsclient ] = 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 :D

So yeah so much for the code :)

Xalus 07-10-2010 15:14

Re: [REQ] /drugs
 
public client_putinserver( client )
g_has_drugs[ client ] = false;

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

Connect is enough?

MiKe4444 07-10-2010 15:19

Re: [REQ] /drugs
 
Can u make it with command /nodrugs...
Thats stops it...

Lure.d 07-10-2010 15:21

Re: [REQ] /drugs
 
actually type /drugs again and it disables it :)

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

MiKe4444 07-10-2010 15:25

Re: [REQ] /drugs
 
lol i am stupid :) :)

Thx...

Lure.d 07-10-2010 15:27

Re: [REQ] /drugs
 
no ur not, you just didn't know it since you're not a coder yet...
no problem dude, glad i helped you :)

dj_freeze 07-10-2010 16:18

Re: [REQ] /drugs
 
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.

unnyquee 07-10-2010 17:35

Re: [REQ] /drugs
 
I assume that you didn't tested yet ^^.

Lure.d 07-10-2010 19:03

Re: [REQ] /drugs
 
I have. Also added mini-tut for newbies ;)


All times are GMT -4. The time now is 16:48.

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