Mtasa-blue: OOP: ped:setControlState() returns deprecated function

Created on 1 Feb 2019  路  9Comments  路  Source: multitheftauto/mtasa-blue

Describe the bug
using the setControlState OOP function will display in server console that the function is deprecated and needs to be replaced with setPedControlState.

To reproduce
Create a script and white a script to create a ped. Once you've created the ped, use ped:setControlState("walk",true) and save the script. Run the resource, and you will see the warning in the server console.

Expected behaviour
Due to it being an OOP function, it should not be expected for setControlState to be deprecated. Maybe the OOP function needs to be updated to the newer function in the metatable.

Screenshots
image

Version
Server: MTA:SA Server v1.5.6-release-16352

bug good first issue

Most helpful comment

Test resource: testoop.zip
Starting resource on 18720:

[2019-07-08 13:56:02] start: Requested by Console
[2019-07-08 13:56:02] WARNING: testoop/server.lua(Line 3) [Server] isPlayerDead is deprecated and may not work in future versions. Please replace with isPedDead.
[2019-07-08 13:56:02] WARNING: testoop/client.lua(Line 2) [Client] setControlState is deprecated and may not work in future versions. Please replace with setPedControlState.
[2019-07-08 13:56:02] Some files in 'testoop' use deprecated functions.
[2019-07-08 13:56:02] Use the 'upgrade' command to perform a basic upgrade of resources.
[2019-07-08 13:56:02] Starting testoop
[2019-07-08 13:56:02] start: Resource 'testoop' started

Starting resource on 18727 (3418ceb):

[2019-07-08 13:52:49] start: Requested by Console
[2019-07-08 13:52:50] Starting testoop
[2019-07-08 13:52:50] start: Resource 'testoop' started

All 9 comments

I think this happens because it sees setControlState and thinks it's a legacy function.

ped:setControlState(...)
    ^^^^^^^^^^^^^^^

A fix for this would be to check for (?<!:)setControlState.

Also function RaceBase:isPlayerDead(uPlayer) gives deprecation message (with setControlState probably aswell)

That one is unavoidable as it's a Lua script method with the same name of an inbuilt.

Wouldnt something like this work @qaisjp ?
https://regex101.com/r/xdd8a1/4

(didnt test for tabs / other characters at the beginning)

as per same function naming: What about checking whenever a function with that name will be added ? We could disable that message for that resource then

It would not be clean to compose one large regex. If RaceBase:isPlayerDead is in the current race code, the race code should be changed. This issue is related to MTA's OOP Lua API being broken by the upgrade system.

Apparently 3418ceb would fix this issue as mentioned by @StrixG. I'd like to hear from @1B0Y whether this is accurate in this issue. This commit will be available in the next nightly.

Test resource: testoop.zip
Starting resource on 18720:

[2019-07-08 13:56:02] start: Requested by Console
[2019-07-08 13:56:02] WARNING: testoop/server.lua(Line 3) [Server] isPlayerDead is deprecated and may not work in future versions. Please replace with isPedDead.
[2019-07-08 13:56:02] WARNING: testoop/client.lua(Line 2) [Client] setControlState is deprecated and may not work in future versions. Please replace with setPedControlState.
[2019-07-08 13:56:02] Some files in 'testoop' use deprecated functions.
[2019-07-08 13:56:02] Use the 'upgrade' command to perform a basic upgrade of resources.
[2019-07-08 13:56:02] Starting testoop
[2019-07-08 13:56:02] start: Resource 'testoop' started

Starting resource on 18727 (3418ceb):

[2019-07-08 13:52:49] start: Requested by Console
[2019-07-08 13:52:50] Starting testoop
[2019-07-08 13:52:50] start: Resource 'testoop' started

@patrikjuvonen based on Strix's demonstration above & OP's absence, can we close this issue?

@qaisjp Sure!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PlatinMTA picture PlatinMTA  路  3Comments

Cazomino05 picture Cazomino05  路  3Comments

qaisjp picture qaisjp  路  4Comments

CrosRoad95 picture CrosRoad95  路  4Comments

commanderagu picture commanderagu  路  3Comments