PDA

View Full Version : Request simple plugin, but too hard for me.


TheReaperr
02-16-2013, 15:25
Hey

I want a plugin where if you type
/stealth

you will also do
/render @me 5
/cheat buddha

message only you get that you are in Stealth mode

and if you type it again

/render @me 0
/cheat buddha

message only you get that you are no longer in stealth mode


Yes I tried all the other godmode/invisibility plugins but the mod I'm trying to use it for doesn't support any of them, it just crashes the server.

Marcus_Brown001
02-16-2013, 21:08
The following code is untested, but from what you have said, it should work. You are asking for something that makes someone do the command /cheat and /render; you have to have another plugin(s) that have the commands sm_cheat and sm_render.

#include <sourcemod>

public OnPluginStart()
{
RegAdminCmd("sm_stealth", Command_Stealth, ADMFLAG_GENERIC);
}

public Action:Command_Stealth(client, args)
{
new toggle;

if(!toggle)
{
FakeClientCommand(client, "sm_render @me 5");
FakeClientCommand(client, "sm_cheat buddha");
PrintToChat(client, "[SM] You are now in stealth mode.");
toggle = 1;
} else
{
FakeClientCommand(client, "sm_render @me 0");
FakeClientCOmmand(client, "sm_cheat buddha");
PrintToChat(client, "[SM] You are no longer in stealth mode.");
toggle = 0;
}
return toggle;
}

MasterOfTheXP
02-16-2013, 23:14
toggle will always be 0/false with that code.

You should use static toggle[MAXPLAYERS + 1]; instead, then check toggle[client] instead of toggle.

TheReaperr
02-17-2013, 13:51
@Marcus_Brown001
Yes I do have the other 2 plugins and want to combine those 2 in this script.

@MasterOfTheXP
I don't mind changing that myself, but I couldn't figure out what parts of the script should be replaced with what you were saying, could you perhaps be more specific/ fix it yourself?

MasterOfTheXP
02-17-2013, 16:55
#include <sourcemod>

public OnPluginStart()
{
RegAdminCmd("sm_stealth", Command_Stealth, ADMFLAG_GENERIC);
}

public Action:Command_Stealth(client, args)
{
static bool:toggle[MAXPLAYERS + 1];

if(!toggle[client])
{
FakeClientCommand(client, "sm_render @me 5");
FakeClientCommand(client, "sm_cheat buddha");
PrintToChat(client, "[SM] You are now in stealth mode.");
}
else
{
FakeClientCommand(client, "sm_render @me 0");
FakeClientCOmmand(client, "sm_cheat buddha");
PrintToChat(client, "[SM] You are no longer in stealth mode.");
}
toggle[client] = !toggle[client];
return Plugin_Handled;
}

Marcus_Brown001
02-17-2013, 20:13
Yeah ... :D Was writing on laptop before I fell asleep. Thanks for the correction :D

TheReaperr
02-22-2013, 09:44
Thanks a lot :). Sorry I didn't respond very quickly... all the time, but I don't get notifications :\