Skip to content
Permalink
Browse files

Remove setControlState clientside (#4267)

  • Loading branch information...
qaisjp committed Jun 12, 2017
1 parent 41a21fd commit 934ba8ca142b46d6fa663b605e0912819837e0ca
@@ -1604,6 +1604,10 @@ bool CStaticFunctionDefinitions::GetPedClothes ( CClientPed & Ped, unsigned char

bool CStaticFunctionDefinitions::GetPedControlState ( CClientPed & Ped, const char * szControl, bool & bState )
{
if (&Ped == GetLocalPlayer ()) {
return GetControlState (szControl, bState);
}

if ( Ped.GetType () == CCLIENTPLAYER )
{
CControllerState cs;
@@ -1628,10 +1632,12 @@ bool CStaticFunctionDefinitions::GetPedControlState ( CClientPed & Ped, const ch
return true;
}
}

if ( Ped.m_Pad.GetControlState ( szControl, bState ) )
{
return true;
}

return false;
}

@@ -2223,6 +2229,11 @@ bool CStaticFunctionDefinitions::SetPedControlState ( CClientEntity & Entity, co
if ( IS_PED ( &Entity ) )
{
CClientPed& Ped = static_cast < CClientPed& > ( Entity );

if (&Ped == GetLocalPlayer ()) {
return SetControlState ( szControl, bState );
}

if ( Ped.m_Pad.SetControlState ( szControl, bState ) )
{
return true;
@@ -293,29 +293,6 @@ int CLuaFunctionDefs::GetKeyState ( lua_State * luaVM )
return 1;
}


int CLuaFunctionDefs::GetControlState ( lua_State * luaVM )
{
SString strControlState = "";
CScriptArgReader argStream ( luaVM );
argStream.ReadString ( strControlState );

if ( !argStream.HasErrors ( ) )
{
bool bState;
if ( CStaticFunctionDefinitions::GetControlState ( strControlState , bState ) )
{
lua_pushboolean ( luaVM, bState );
return 1;
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );

lua_pushboolean ( luaVM, false );
return 1;
}

int CLuaFunctionDefs::GetAnalogControlState ( lua_State * luaVM )
{
SString strControlState = "";
@@ -694,31 +671,6 @@ int CLuaFunctionDefs::GetKeyBoundToCommand ( lua_State* luaVM )
return 1;
}


int CLuaFunctionDefs::SetControlState ( lua_State * luaVM )
{
SString strControl = "";
bool bState = false;
CScriptArgReader argStream ( luaVM );
argStream.ReadString ( strControl );
argStream.ReadBool ( bState );

if ( !argStream.HasErrors ( ) )
{
if ( CStaticFunctionDefinitions::SetControlState ( strControl, bState ) )
{
lua_pushboolean ( luaVM, true );
return 1;
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage() );

lua_pushboolean ( luaVM, false );
return 1;
}


int CLuaFunctionDefs::ToggleControl ( lua_State * luaVM )
{
SString strControl = "";
@@ -214,6 +214,8 @@ void CLuaManager::LoadCFunctions ( void )
CLuaCFunctions::AddFunction ( "isPlayerDead", CLuaPedDefs::IsPedDead );
CLuaCFunctions::AddFunction ( "guiEditSetCaratIndex", CLuaGUIDefs::GUIEditSetCaretIndex );
CLuaCFunctions::AddFunction ( "guiMemoSetCaratIndex", CLuaGUIDefs::GUIMemoSetCaretIndex );
CLuaCFunctions::AddFunction ( "setControlState", CLuaPedDefs::SetPedControlState);
CLuaCFunctions::AddFunction ( "getControlState", CLuaPedDefs::GetPedControlState);
// ** END OF BACKWARDS COMPATIBILITY FUNCS. **

// Event funcs
@@ -368,7 +370,6 @@ void CLuaManager::LoadCFunctions ( void )
CLuaCFunctions::AddFunction ( "bindKey", CLuaFunctionDefs::BindKey );
CLuaCFunctions::AddFunction ( "unbindKey", CLuaFunctionDefs::UnbindKey );
CLuaCFunctions::AddFunction ( "getKeyState", CLuaFunctionDefs::GetKeyState );
CLuaCFunctions::AddFunction ( "getControlState", CLuaFunctionDefs::GetControlState );
CLuaCFunctions::AddFunction ( "getAnalogControlState", CLuaFunctionDefs::GetAnalogControlState );
CLuaCFunctions::AddFunction ( "setAnalogControlState", CLuaFunctionDefs::SetAnalogControlState );
CLuaCFunctions::AddFunction ( "isControlEnabled", CLuaFunctionDefs::IsControlEnabled );
@@ -378,7 +379,6 @@ void CLuaManager::LoadCFunctions ( void )
CLuaCFunctions::AddFunction ( "getCommandsBoundToKey", CLuaFunctionDefs::GetCommandsBoundToKey );
CLuaCFunctions::AddFunction ( "getKeyBoundToCommand", CLuaFunctionDefs::GetKeyBoundToCommand );

CLuaCFunctions::AddFunction ( "setControlState", CLuaFunctionDefs::SetControlState );
CLuaCFunctions::AddFunction ( "toggleControl", CLuaFunctionDefs::ToggleControl );
CLuaCFunctions::AddFunction ( "toggleAllControls", CLuaFunctionDefs::ToggleAllControls );

@@ -1061,10 +1061,13 @@ int CLuaPedDefs::GetPedClothes ( lua_State* luaVM )
int CLuaPedDefs::GetPedControlState ( lua_State* luaVM )
{
// Verify the argument
CClientPed* pPed = NULL;
CClientPed* pPed = CStaticFunctionDefinitions::GetLocalPlayer();
SString strControl = "";
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pPed );

if (argStream.NextIsUserData ()) {
argStream.ReadUserData (pPed);
}
argStream.ReadString ( strControl );

if ( !argStream.HasErrors () )
@@ -1597,11 +1600,14 @@ int CLuaPedDefs::RemovePedClothes ( lua_State* luaVM )
int CLuaPedDefs::SetPedControlState ( lua_State* luaVM )
{
// Verify the argument
CClientEntity* pEntity = NULL;
CClientEntity* pEntity = CStaticFunctionDefinitions::GetLocalPlayer();
SString strControl = "";
bool bState = false;
CScriptArgReader argStream ( luaVM );
argStream.ReadUserData ( pEntity );

if (argStream.NextIsUserData ()) {
argStream.ReadUserData (pEntity);
}
argStream.ReadString ( strControl );
argStream.ReadBool ( bState );

@@ -629,4 +629,4 @@ int CLuaPlayerDefs::GetPlayerMapBoundingBox ( lua_State* luaVM )
//The map is invisible
lua_pushboolean ( luaVM, false );
return 1;
}
}

3 comments on commit 934ba8c

@Einheit-101

This comment has been minimized.

Copy link

replied Jun 12, 2017

Will you add setPedControlState to the server, when you are at this now? ^^

@qaisjp

This comment has been minimized.

Copy link
Member Author

replied Jun 12, 2017

Doesn't that just entail renaming the setControlState function?

@Einheit-101

This comment has been minimized.

Copy link

replied Jun 12, 2017

Uhm most likely true lol. Amazeballs. I can test that practically immediately. Finally i dont have to sync ped control states on all clients anymore.

€DIT: What about analog control state?
It is both:
-Not available server side
-Exists in 2 variants (setAnalogControlState, setPedAnalogControlState)

Please sign in to comment.
You can’t perform that action at this time.