[Open Source] 5M: Cops n' Robbers (5MCNR) - Reopened!

Welcome to the thread for 5M Cops and Robbers (henceforth 5MCNR, or ‘CNR’)


About the Gamemode
5M:CNR is a gamemode I’ve been working on that I had intended to open a server for. However, because of the scale of the project and my commitment to University and my family (yay, father of two), I’ve decided it’s in the best interest for myself and the community to release my gamemode as an open source project.

CNR is loosely based on everyone’s old favorite “Crazybob’s Cops and Robbers” on SA:MP. You are an innocent civilian in the GTA V online world, who can do whatever the script allows you to do. Commit crimes, and you will become wanted. Join the police force, and go after wanted persons. If you rather avoid all the trouble altogether, you can just go fishing or do deliveries and avoid the law.

How the gamemode Works
Players join the server, and upon first connection, design their character (currently, due to time restrictions, players currently pick a random Ped Model, freemode models coming soon). When a player connects for the first time, they’re randomly spawned at any number of spawn points in the active zone. The active zone is the portion of the map where crimes can be committed, and missions can be obtained. This is to keep everyone in a similar area. The zone changes every 4 hours, whether there are players connected or not.

Players can then either obtain legal employment by delivering packages, fishing, hunting, or more. If players wish to make more money or get involved with the cops, they can commit crimes and do illegal jobs. Players can also join the police force, and go after wanted players. The rest of the gamemode is in development. Currently you can rob convenience stores, become a cop, or random things you can typically do in unscripted servers.

CURRENT CONTROLS

  • (F2) -> Arrests/Tickets the nearest player. (In the future, you will subdue players by tackling or tasing them. F2 will be the button for issuing tickets).
  • (E) -> E is the go-to interaction key. Starting work, picking up equipment, etc.
  • Starting Robberies: Point a gun. For now, you will need a trainer to give yourself a gun.

Github / Gamemode Development
5M CNR is an Open Source, community game mode as of this point. What this means, is that while I still own the repository, I have opened it up to forking. You can create your own fork, work on the gamemode/optimize things I have written, or even write new features for the gamemode and submit a pull request to have your branch merged into the official gamemode.

If you do not know how to fork/pull/push/pull-request, please see the bottom of this thread.

Standalone Gamemode
The intention is to have this gamemode self-served. Meaning, it will not rely on base resources, or other resources to operate. However, due to time restrictions and current development, it does require SQL integration, spawnmanager, and other base resources. By the time Version 1.0 is released, the game mode will handle all natives and behaviors on it’s own.

GitHub https://github.com/rhapidfyre/Cops-n-Robbers
Anyone can fork and submit pull requests at any time. I will review your modifications to the script, and will merge appropriately.

Existing Code
I realize that my code may not be the best written… Originally, I was making this game mode for self-serving interests, and selfishly operating a game server, being the sole community running this game mode. I decided that, with the pluthera of Roleplay servers available and not many other options, to make this a community effort to make not only a new game mode, but the best game mode that can be offered. When I decided to make this game mode open source, I began to convert things into a more easily readable format. This included using coding conventions, adding function headers, organizing files… Administrative stuff that does not include going back through all 30+ files and revising my pre-alpha code. If you find things that are inefficient, such as loops that don’t make sense, or natives that are obsolete, you are more than welcome to revise them and submit a pull request.

TL;DR - I have been doing a lot of administrative changes, and haven’t touched the code too recently. It’s a mess, but we’ll get there together.

Current Development/Plans
Currently, we are at a crossroad. The base game works. Players can be charged with crimes, arrested by the cops, thrown in jail, and release when their time is up. However, there isn’t much to do yet. Players can’t own vehicles, can’t own apartments, can’t buy clothes, use the Freemode model, do any jobs, fish, hunt, buy guns, find pickups around the map, etc. There are a lot of features missing, and a lot of potential for this to go somewhere.

:checkered_flag: How to Fork / Pull / Push :checkered_flag:
First thing you will need to do to assist with the project is to make an account at Github. Once you are logged in, you will go to the main repository page, and at the top right click “Fork”. Create a new fork, and then clone your fork to your local machine, and start coding!

As you code, you can push files to your fork without affecting the main branch, where you can troubleshoot and even add collaborators to YOUR fork to help. Once you have a stable version you would like to have added to the master branch, or your contribution has been finished, you should add any relevant information such as a README file, update the existing README file, and comment any necessary fields. If you a re editing an existing resource, be sure to add yourself to the Contributor list in the __resource.lua file.

Last but not least, when all your changes are finished, when your edits are stable (they do not have to be final/finished, but they must be error/conflict free), you go to the main repository for the project (not your fork), and submit a pull request. Fill out the relevant info, and then myself or a project Collaborator will review the changes.

10 Likes

Awesome job man! Almost all of us have real life… keep up this great project

1 Like

Thank you! It is my intention to continue developing this game mode, I just wanted to open it to contributions so that we can all shape and forge it to be a solid community effort we can all use.

The details are quite good, gonna test it later on a server to see if it’s really worth making a seperate server for.

Currently, there is not nearly enough stuff to do or features to make it worth running an active server. That is half the reason I decided to make it an open source project; To allow others to add these features. Meanwhile, I will be developing it further on my own.

While I am all for unique and custom resources, please remember to adhere to our Release Rules & FAQ Page, once this is done, I’ll gladly relist and post under the Release section for you. Thank you very much for coming up with something non-rp related.

Advertising
Any advertisement is not tolerated . This includes any mentions of support through third-party services like Discord and websites. If you would like to contact a user do so via Direct Messages or find their contact details via their profile description. Advertising includes, but is not limited to:

  • Any Discord link/user (this includes extra support)

Can you add a basic server.cfg file to the repo which explains in which order the resources need to be loaded ?

[2019/09/11 12:07:21.550] [Info] SCRIPT ERROR: @cnr_charcreate/sv_create.lua:33: attempt to concatenate a nil value (local ‘steamIdentifier’)

This is what I get when loading the resources into a fresh server and connecting to it.

1 Like

Relisted then moved to Resource Development & Modding : Releases.

op, if you didn’t want this in releases please let me know.

Looks like an awesome project, can’t wait to get my fork into it…

1 Like

You seem to not be connected to steam, or steam has not launched in your PC. Try relaunching steam.
For the author: Well done mate, nice to see some fresh gamemodes here other than roleplay and ESX addons.

1 Like

I had to remove the whitelist from the script to release it. It seems I caused an error in doing so. I will patch this in the next couple hours.

You were totally right about Steam not being connected. When you’re offline on Steam, it doesn’t work

@RhapidFyre The cnr_charcreate folder also seems to be missing a changelog.txt file

[2019/09/11 15:52:28.300] [Info] [CNR 15:52] Failed to open changelog.txt

@RhapidFyre After getting past the changelog issue, picking a ped and pressing Select this comes up in the server console

[2019/09/11 16:02:52.154] [Info] e[31m[ERROR] [MariaDB:10.4.6-MariaDB] [cnr_charcreate] An error happens on MySQL for query “INSERT INTO characters (idUnique, model) VALUES (@uid, ?) : [“s_m_y_fireman_01”]”: ER_BAD_NULL_ERROR: Column ‘idUnique’ cannot be nulle[0m

Did you import the SQL database? By the looks of the error, it seems you have. if idUnique is nil, that means the game was unable to create your player account. I’m guessing there is probably an error before that as well. If I had to take a wild guess, you probably removed the Steam Account requirement because of my screwup with the Whitelist, which means the game was unable to add your player account to the Database.

EDIT
This should not be an issue on the newest version.

Update your Forks/Clones
merged changelog-fix to master branch on 9/11/19 @ 4:48PM

This update fixes the login script issues. Previously, you could only log in with Steam, and various changelog errors (which was intended for my server, not for the gamemode release) were bricking logins. There were also issues with the MySQL database, such as an unoptimized procedure, and not a long enough VARCHAR length to store a FiveM License number.

This update fixes the login issues

Notes

  • Removed the dependency on Steam. Players no longer need Steam to play this gamemode. However, the gamemode will prefer that you use Steam; Therefore, if you have 3 or 4 FiveM accounts, and then log in on Steam, the character who identifies with the SteamID will be loaded. In the future, we will make the script “smart”; I.E: Combine all the characters into one when a Steam ID is detected, so that you can play that character profile regardless of what account you’re using, so long as you have been verified to be you. How we will do this, no clue. That’s for later.

  • Added SQL Stored Procedure new_player, which adds the new player to the database and returns their Unique ID for the script to use immediately, so they can play without reconnecting.

  • Removed the dependency on a changelog file. If a changelog file exists, it will be used. Otherwise, it is ignored.

  • Added the controls to both the main post of this thread, and the Github README.md

  • Removed DEFINER on the SQL procedures. SQL now does not care who is running or created the procedure. Change this on your own if you’re concerned regarding security. We’ll revisit this later.

Let me know if you encounter any issues. Half of these problems were discovered by someone who was interested in this gamemode and messaged me to resolve them. It is my plan to ONLY update the master branch once a week hereforth on Sunday evenings, so you don’t have to continue pulling multiple times. I apologize sincerely about all the updates today, but this was a critical bug that had to be fixed ASAP.

1 Like

How do I create clan? And how to set admin?
Sorry to bother you with this, is that I did not find anywhere in your post.

You would have to write these additions yourself, or wait for it to be developed. The clan resource is not 100% finished, and there is no admin resource as of yet.

e[31m[ERROR] [MySQL] [cnr_charcreate] An error happens on MySQL for query "SELECT idUnique FROM players WHERE idSteam = ? OR idFiveM = ? LIMIT 1 : ["steam:************","license:*************************be"]": connect ECONNREFUSED 127.0.0.1:3306e[0m

I edited json for DB, but i get this in console and stay on loading,

Where am i going wrong :slight_smile: