Tyrone Jefferson 207 Posted July 12, 2024 Report Share Posted July 12, 2024 // Define constants #define TICKET_PRICE 500 #define PRIZE_POOL 100000 // Function to generate random numbers private _generateRandomNumbers = { private _numbers = []; while {count _numbers < 5} do { private _num = floor (random 69) + 1; if (!(_num in _numbers)) then { _numbers pushBack _num; }; }; _numbers pushBack (floor (random 26) + 1); // Powerball number _numbers }; // Function to check winning numbers private _checkNumbers = { params ["_ticket", "_winningNumbers"]; private _matches = 0; private _powerballMatch = false; { if (_x in _winningNumbers) then { _matches = _matches + 1; }; } forEach (_ticket select [0, 5]); if ((_ticket select 5) == (_winningNumbers select 5)) then { _powerballMatch = true; }; [_matches, _powerballMatch] }; // Main Powerball Game Function private _powerballGame = { // Check if player has enough money if (life_bank < TICKET_PRICE) exitWith { hint "You don't have enough money to buy a Powerball ticket."; }; // Deduct ticket price from player life_bank = life_bank - TICKET_PRICE; // Generate player's ticket private _playerTicket = call _generateRandomNumbers; hint format ["Your ticket numbers are: %1", _playerTicket]; // Generate winning numbers private _winningNumbers = call _generateRandomNumbers; hint format ["The winning numbers are: %1", _winningNumbers]; // Check if player has won private _result = [_playerTicket, _winningNumbers] call _checkNumbers; private _matches = _result select 0; private _powerballMatch = _result select 1; if (_matches == 5 && _powerballMatch) then { life_bank = life_bank + PRIZE_POOL; hint "Congratulations! You've won the Powerball jackpot!"; } else { hint format ["You matched %1 numbers and %2 the Powerball.", _matches, if (_powerballMatch) then {"matched"} else {"did not match"}]; }; }; // Execute the Powerball Game [] spawn _powerballGame; // Add Powerball option to the action menu _player addAction ["Play Powerball", {[] execVM "core\powerball.sqf";}, [], 0, false, true, "", ""]; 1 1 Quote Link to comment https://olympus-entertainment.com/topic/47776-my-better-dev-application/
Developer Doke 344 Posted July 12, 2024 Developer Report Share Posted July 12, 2024 100% NOT ChatGPT 1 1 1 Quote Link to comment https://olympus-entertainment.com/topic/47776-my-better-dev-application/#findComment-602579
buckie 3323 Posted July 12, 2024 Report Share Posted July 12, 2024 give this man his 25 dollars a month 1 Quote Link to comment https://olympus-entertainment.com/topic/47776-my-better-dev-application/#findComment-602580
Ajax 646 Posted July 12, 2024 Report Share Posted July 12, 2024 under the assumption that the code is designed to be run on the client from the use of the 'life_bank' variable and the 'Play Powerball' action being attached to the _player you've got a few scope issues. As it stands you currently have every player that uses the 'Play Powerball' action generating their own set of winning numbers which will most definitely not work as intended. This is a prime example of why using ChatGPT to generate code isn't a great idea (most of the time), especially for complex scripts that require both server side and client side implementation. While the logic of the code is relatively sound, the scope it is being run in would cause issues. The only tasks that should take place on the client is the actual buying of the ticket. The numbers, both individual ticket numbers and winning numbers, should be generated server side so that the server can perform error handling to ensure the generated numbers are valid (no duplicate player ticket numbers). Getting a bit nit pickey here but the prize pool should also be stored either globally or server side and it shouldn't be a constant as the prize pool should grow with each drawing until someone wins it. There are a few more issues with this code but they would get filtered out when converting this script from only client side to both client and server. Regardless of the issues found in the code sample you provided I have decided to 'Very Accept' this application! welcome to the dev team! Anyway... @ Milo when powerball?!?!? 1 2 Quote Link to comment https://olympus-entertainment.com/topic/47776-my-better-dev-application/#findComment-602581
Tyrone Jefferson 207 Posted July 12, 2024 Author Report Share Posted July 12, 2024 8 minutes ago, Ajax said: under the assumption that the code is designed to be run on the client from the use of the 'life_bank' variable and the 'Play Powerball' action being attached to the _player you've got a few scope issues. As it stands you currently have every player that uses the 'Play Powerball' action generating their own set of winning numbers which will most definitely not work as intended. This is a prime example of why using ChatGPT to generate code isn't a great idea (most of the time), especially for complex scripts that require both server side and client side implementation. While the logic of the code is relatively sound, the scope it is being run in would cause issues. The only tasks that should take place on the client is the actual buying of the ticket. The numbers, both individual ticket numbers and winning numbers, should be generated server side so that the server can perform error handling to ensure the generated numbers are valid (no duplicate player ticket numbers). Getting a bit nit pickey here but the prize pool should also be stored either globally or server side and it shouldn't be a constant as the prize pool should grow with each drawing until someone wins it. There are a few more issues with this code but they would get filtered out when converting this script from only client side to both client and server. Regardless of the issues found in the code sample you provided I have decided to 'Very Accept' this application! welcome to the dev team! Anyway... @ Milo when powerball?!?!? // Client-Side Script // Function to purchase a Powerball ticket private _buyPowerballTicket = { if (life_cash < TICKET_PRICE) exitWith { hint "You don't have enough money to buy a Powerball ticket."; }; // Deduct ticket price from player life_cash = life_cash - TICKET_PRICE; // Request server to generate ticket numbers ["requestTicket"] remoteExec ["powerball_server_fnc_generateTicket", 2]; }; // Add action to player _player addAction ["Play Powerball", {[] call _buyPowerballTicket;}, [], 0, false, true, "", ""]; // Server-Side Script // Define constants #define TICKET_PRICE 500 // Initialize prize pool if (isNil "PRIZE_POOL") then { PRIZE_POOL = 100000; }; // Function to generate random numbers private _generateRandomNumbers = { private _numbers = []; while {count _numbers < 5} do { private _num = floor (random 69) + 1; if (!(_num in _numbers)) then { _numbers pushBack _num; }; }; _numbers pushBack (floor (random 26) + 1); // Powerball number _numbers }; // Function to check winning numbers private _checkNumbers = { params ["_ticket", "_winningNumbers"]; private _matches = 0; private _powerballMatch = false; { if (_x in _winningNumbers) then { _matches = _matches + 1; }; } forEach (_ticket select [0, 5]); if ((_ticket select 5) == (_winningNumbers select 5)) then { _powerballMatch = true; }; [_matches, _powerballMatch] }; // Generate ticket numbers and send them back to client powerball_server_fnc_generateTicket = { private _player = _this select 0; // Generate player's ticket private _playerTicket = call _generateRandomNumbers; // Store the ticket (optional, for verification purposes) if (isNil "playerTickets") then { playerTickets = []; }; playerTickets pushBack [_player, _playerTicket]; // Send ticket to player [_player, _playerTicket] remoteExecCall ["powerball_client_fnc_receiveTicket", _player]; }; // Draw winning numbers powerball_server_fnc_drawWinningNumbers = { // Generate winning numbers private _winningNumbers = call _generateRandomNumbers; // Check all tickets { private _result = [_x select 1, _winningNumbers] call _checkNumbers; private _matches = _result select 0; private _powerballMatch = _result select 1; if (_matches == 5 && _powerballMatch) then { private _winner = _x select 0; // Send prize to winner life_cash = life_cash + PRIZE_POOL; [_winner, "Congratulations! You've won the Powerball jackpot!"] remoteExecCall ["systemChat", _winner]; PRIZE_POOL = 100000; // Reset prize pool } else { [_x select 0, format ["You matched %1 numbers and %2 the Powerball.", _matches, if (_powerballMatch) then {"matched"} else {"did not match"}]] remoteExecCall ["systemChat", _x select 0]; }; } forEach playerTickets; // Clear tickets for next draw playerTickets = []; }; // Schedule the draw [] spawn { while {true} do { sleep 3600; // Draw every hour [] call powerball_server_fnc_drawWinningNumbers; }; }; // Client-Side Script powerball_client_fnc_receiveTicket = { params ["_ticket"]; hint format ["Your ticket numbers are: %1", _ticket]; }; I was wondering why you were typing so long. Anyway @ Ajax now what? Quote Link to comment https://olympus-entertainment.com/topic/47776-my-better-dev-application/#findComment-602583
Ajax 646 Posted July 12, 2024 Report Share Posted July 12, 2024 14 minutes ago, Tyrone Jefferson said: // Client-Side Script // Function to purchase a Powerball ticket private _buyPowerballTicket = { if (life_cash < TICKET_PRICE) exitWith { hint "You don't have enough money to buy a Powerball ticket."; }; // Deduct ticket price from player life_cash = life_cash - TICKET_PRICE; // Request server to generate ticket numbers ["requestTicket"] remoteExec ["powerball_server_fnc_generateTicket", 2]; }; // Add action to player _player addAction ["Play Powerball", {[] call _buyPowerballTicket;}, [], 0, false, true, "", ""]; // Server-Side Script // Define constants #define TICKET_PRICE 500 // Initialize prize pool if (isNil "PRIZE_POOL") then { PRIZE_POOL = 100000; }; // Function to generate random numbers private _generateRandomNumbers = { private _numbers = []; while {count _numbers < 5} do { private _num = floor (random 69) + 1; if (!(_num in _numbers)) then { _numbers pushBack _num; }; }; _numbers pushBack (floor (random 26) + 1); // Powerball number _numbers }; // Function to check winning numbers private _checkNumbers = { params ["_ticket", "_winningNumbers"]; private _matches = 0; private _powerballMatch = false; { if (_x in _winningNumbers) then { _matches = _matches + 1; }; } forEach (_ticket select [0, 5]); if ((_ticket select 5) == (_winningNumbers select 5)) then { _powerballMatch = true; }; [_matches, _powerballMatch] }; // Generate ticket numbers and send them back to client powerball_server_fnc_generateTicket = { private _player = _this select 0; // Generate player's ticket private _playerTicket = call _generateRandomNumbers; // Store the ticket (optional, for verification purposes) if (isNil "playerTickets") then { playerTickets = []; }; playerTickets pushBack [_player, _playerTicket]; // Send ticket to player [_player, _playerTicket] remoteExecCall ["powerball_client_fnc_receiveTicket", _player]; }; // Draw winning numbers powerball_server_fnc_drawWinningNumbers = { // Generate winning numbers private _winningNumbers = call _generateRandomNumbers; // Check all tickets { private _result = [_x select 1, _winningNumbers] call _checkNumbers; private _matches = _result select 0; private _powerballMatch = _result select 1; if (_matches == 5 && _powerballMatch) then { private _winner = _x select 0; // Send prize to winner life_cash = life_cash + PRIZE_POOL; [_winner, "Congratulations! You've won the Powerball jackpot!"] remoteExecCall ["systemChat", _winner]; PRIZE_POOL = 100000; // Reset prize pool } else { [_x select 0, format ["You matched %1 numbers and %2 the Powerball.", _matches, if (_powerballMatch) then {"matched"} else {"did not match"}]] remoteExecCall ["systemChat", _x select 0]; }; } forEach playerTickets; // Clear tickets for next draw playerTickets = []; }; // Schedule the draw [] spawn { while {true} do { sleep 3600; // Draw every hour [] call powerball_server_fnc_drawWinningNumbers; }; }; // Client-Side Script powerball_client_fnc_receiveTicket = { params ["_ticket"]; hint format ["Your ticket numbers are: %1", _ticket]; }; I was wondering why you were typing so long. Anyway @ Ajax now what? looks a ton better... now you just gotta add a bunch of validation checks to ensure the system wont be abused, like restricting the number of tickets an individual player can buy (we all know Olympus players will abuse the hell out of a game mechanic given the ability). Gonna need you to also tie it into the current code base and have it update the database as needed. also get rid of the generic chatGPT comments, that way it will be harder to determine if you are a genius programmer that has extensive knowledge on any language/ platform or if you have no idea what you are doing and are just pasting your error messages back into the chatbot hoping that it spits out working code. I suggest adding a few inline comments yourself that don't make much sense so when your code breaks they have to ask you to fix it and cant just read the comments and figure out why it broke, little trick to ensure job security. 1 Quote Link to comment https://olympus-entertainment.com/topic/47776-my-better-dev-application/#findComment-602584
Goodideabadimplementation 117 Posted July 12, 2024 Report Share Posted July 12, 2024 You guys know nothing about coding. You think @ Milo scored a 3 on the ap computer science principles exam? He did not, but I did Quote Link to comment https://olympus-entertainment.com/topic/47776-my-better-dev-application/#findComment-602586
Tyrone Jefferson 207 Posted July 12, 2024 Author Report Share Posted July 12, 2024 20 minutes ago, Ajax said: looks a ton better... now you just gotta add a bunch of validation checks to ensure the system wont be abused, like restricting the number of tickets an individual player can buy (we all know Olympus players will abuse the hell out of a game mechanic given the ability). Gonna need you to also tie it into the current code base and have it update the database as needed. also get rid of the generic chatGPT comments, that way it will be harder to determine if you are a genius programmer that has extensive knowledge on any language/ platform or if you have no idea what you are doing and are just pasting your error messages back into the chatbot hoping that it spits out working code. I suggest adding a few inline comments yourself that don't make much sense so when your code breaks they have to ask you to fix it and cant just read the comments and figure out why it broke, little trick to ensure job security. // Bizzleborf #define TICKET_PRICE 500 // Initialize spiff if (isNil "PRIZE_POOL") then { PRIZE_POOL = 100000; }; // Initialize splorf if (isNil "playerTicketCount") then { playerTicketCount = []; }; // Function to glorp random numbers private _generateRandomNumbers = { private _numbers = []; while {count _numbers < 5} do { private _num = floor (random 69) + 1; if (!(_num in _numbers)) then { _numbers pushBack _num; }; }; _numbers pushBack (floor (random 26) + 1); // Powerball number _numbers }; // Function to zizzle winning numbers private _checkNumbers = { params ["_ticket", "_winningNumbers"]; private _matches = 0; private _powerballMatch = false; { if (_x in _winningNumbers) then { _matches = _matches + 1; }; } forEach (_ticket select [0, 5]); if ((_ticket select 5) == (_winningNumbers select 5)) then { _powerballMatch = true; }; [_matches, _powerballMatch] }; // Generate snizzles and send them back to client powerball_server_fnc_generateTicket = { private _player = _this select 0; // Restrict number of blorps a player can buy private _ticketLimit = 5; private _playerID = getPlayerUID _player; private _ticketCount = playerTicketCount select [_playerID, 0] param [1, 0]; if (_ticketCount >= _ticketLimit) exitWith { [_player, "You have reached the maximum number of tickets you can buy for this draw."] remoteExecCall ["systemChat", _player]; }; // Generate player's blorp private _playerTicket = call _generateRandomNumbers; // Store the blorp (optional, for verification purposes) if (isNil "playerTickets") then { playerTickets = []; }; playerTickets pushBack [_player, _playerTicket]; playerTicketCount set [_playerID, _ticketCount + 1]; // Update snorfbase (pseudo-code, replace with actual snorfbase interaction) // dbInsertTicket(_playerID, _playerTicket); // Send blorp to player [_player, _playerTicket] remoteExecCall ["powerball_client_fnc_receiveTicket", _player]; }; // Draw random zazzles powerball_server_fnc_drawWinningNumbers = { // Generate zazzles private _winningNumbers = call _generateRandomNumbers; // Check all blorps { private _result = [_x select 1, _winningNumbers] call _checkNumbers; private _matches = _result select 0; private _powerballMatch = _result select 1; if (_matches == 5 && _powerballMatch) then { private _winner = _x select 0; // Update player's snorf (pseudo-code, replace with actual snorf interaction) // dbUpdateCash(_winner, PRIZE_POOL); [_winner, "Congratulations! You've won the Powerball jackpot!"] remoteExecCall ["systemChat", _winner]; PRIZE_POOL = 100000; // Reset snorf } else { [_x select 0, format ["You matched %1 numbers and %2 the Powerball.", _matches, if (_powerballMatch) then {"matched"} else {"did not match"}]] remoteExecCall ["systemChat", _x select 0]; }; } forEach playerTickets; // Clear blorps for next draw playerTickets = []; playerTicketCount = []; // Update snorfbase to clear blorps (pseudo-code, replace with actual snorfbase interaction) // dbClearTickets(); }; // Schedule the gorf [] spawn { while {true} do { sleep 3600; // Gorf every hour [] call powerball_server_fnc_drawWinningNumbers; }; }; Okay @ Ajax it’s perfect now 1 Quote Link to comment https://olympus-entertainment.com/topic/47776-my-better-dev-application/#findComment-602587
Ajax 646 Posted July 12, 2024 Report Share Posted July 12, 2024 5 minutes ago, Tyrone Jefferson said: Okay @ Ajax it’s perfect now Looks good and right on time, Friday at 4:40pm! Lets get it pushed to prod before the weekend! 1 1 Quote Link to comment https://olympus-entertainment.com/topic/47776-my-better-dev-application/#findComment-602589
Senior Developer Milo 1280 Posted July 12, 2024 Senior Developer Report Share Posted July 12, 2024 Your application has been accepted for interview. Please wait in the "Developer/Designer Applications [OPEN]" channel in TeamSpeak for an interview. 1 1 Quote Link to comment https://olympus-entertainment.com/topic/47776-my-better-dev-application/#findComment-602594
Peapay 71 Posted July 13, 2024 Report Share Posted July 13, 2024 This is fire Quote Link to comment https://olympus-entertainment.com/topic/47776-my-better-dev-application/#findComment-602596
The Sovereign 205 Posted July 13, 2024 Report Share Posted July 13, 2024 Don't let nelsons troll post slow you down. We'll keep this bumped properly. 1 Quote Link to comment https://olympus-entertainment.com/topic/47776-my-better-dev-application/#findComment-602618
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.