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

[HELP] Make clients use opposite keys -OnPlayerRunCmd-


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
beastedout
Member
Join Date: Aug 2018
Old 09-05-2018 , 12:23   [HELP] Make clients use opposite keys -OnPlayerRunCmd-
Reply With Quote #1

Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <cstrike>

#pragma semicolon 1
#pragma newdecls required


Handle OppoKeys;

public Plugin myinfo = {
	name = "Opposite Keys Mode",
	author = "shanapu",
	description = "Players in the server press the opposite keys",
	version = "",
	url = ""
};

public void OnPluginStart()
{
	OppoKeys =	CreateConVar("sm_oppo_keys", "1", "Opposite keys?");
}

public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon) 
{
	for(int i = 1; i <= MaxClients; ++i)
	{
		if (GetConVarBool(OppoKeys))
		{
			if (buttons & IN_MOVELEFT)
			{
				buttons |= IN_MOVERIGHT;
			}
			else if (buttons & IN_MOVERIGHT)
			{
				buttons |= IN_MOVELEFT;
			}
			
			else if (buttons & IN_FORWARD)
			{
				buttons |= IN_BACK;
			}
			else if (buttons & IN_BACK)
			{
				buttons |= IN_FORWARD;
			}
		}
		else
		{
			if (buttons & IN_MOVELEFT)
			{
				
			}
			else if (buttons & IN_MOVERIGHT)
			{
				
			}
			
			else if (buttons & IN_FORWARD)
			{
				
			}
			else if (buttons & IN_BACK)
			{
				
			}
		}
	}
	return Plugin_Continue;
}
Can someone help?
beastedout is offline
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 09-05-2018 , 12:44   Re: [HELP] Make clients use opposite keys -OnPlayerRunCmd-
Reply With Quote #2

HTML Code:
return Plugin_Changed;
And no need for a loop.

Take a look here: https://github.com/shanapu/MyJailbre...sp#L1001-L1041

Edit:
Btw author = "shanapu"... Wtf?! Where did you get this? It's not my work
__________________
coding & free software

Last edited by shanapu; 09-05-2018 at 12:53.
shanapu is offline
beastedout
Member
Join Date: Aug 2018
Old 09-05-2018 , 13:02   Re: [HELP] Make clients use opposite keys -OnPlayerRunCmd-
Reply With Quote #3

Quote:
Originally Posted by shanapu View Post
HTML Code:
return Plugin_Changed;
And no need for a loop.
Nothing else needs to be changed?
Quote:
Take a look here: https://github.com/shanapu/MyJailbre...sp#L1001-L1041

Edit:
Btw author = "shanapu"... Wtf?! Where did you get this? It's not my work
I took code from your MyJailbreak plugin, so kept your name

Last edited by beastedout; 09-05-2018 at 13:03.
beastedout is offline
beastedout
Member
Join Date: Aug 2018
Old 09-05-2018 , 13:09   Re: [HELP] Make clients use opposite keys -OnPlayerRunCmd-
Reply With Quote #4

Quote:
Originally Posted by shanapu View Post
This is from where i copy-pasted the code
Code:
vel[1] = -vel[1];
didn't understand what this does but it wasn't allowing me to press key(wasd) + jump together for some reason.

Last edited by beastedout; 09-05-2018 at 13:10.
beastedout is offline
mug1wara
AlliedModders Donor
Join Date: Jun 2018
Old 09-05-2018 , 13:29   Re: [HELP] Make clients use opposite keys -OnPlayerRunCmd-
Reply With Quote #5

vel[1] = -vel[1];

This is a progression.
-3 -2 -1 0 1 2 3

Velocity is inverted.

You've forgotten to block the keys.
PHP Code:
buttons &= ~IN_FORWARD
mug1wara is offline
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 09-05-2018 , 15:17   Re: [HELP] Make clients use opposite keys -OnPlayerRunCmd-
Reply With Quote #6

Quote:
Originally Posted by beastedout View Post
I took code from your MyJailbreak plugin, so kept your name
But I'm NOT the author of this. Never write/publish code under other peoples name!
Adding credits for the code you used & keep the GPL headers info is the way todo.
like here or here

Quote:
Originally Posted by beastedout View Post
This is from where i copy-pasted the code
If you had really copy/pasted this from mine plugin, why did you add a client loop? and why you removed the "button blocks"? and why is yours so different from mine...



Btw a plugin like you try to write already exists..: https://forums.alliedmods.net/showthread.php?p=2402076
__________________
coding & free software
shanapu is offline
beastedout
Member
Join Date: Aug 2018
Old 09-05-2018 , 22:15   Re: [HELP] Make clients use opposite keys -OnPlayerRunCmd-
Reply With Quote #7

Quote:
Originally Posted by shanapu View Post
But I'm NOT the author of this. Never write/publish code under other peoples name!
Adding credits for the code you used & keep the GPL headers info is the way todo.
Oh, sorry. Will do like this from next time!

Quote:
Btw a plugin like you try to write already exists..: https://forums.alliedmods.net/showthread.php?p=2402076
Thanks
beastedout 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 05:24.


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