Hi. I am working on a new resource. I wanted to make my first NUI script. However, it is not completely working. I am attempting to make a scratch card, howeverrr it is not changing/scrarching when moving mouse over. It works in a default html browser, just not in-game.
This is the script
https://hastebin.com/duloxadidi.js
The following part is working:
var canvas = document.getElementById('canvas'),
ctx = canvas.getContext('2d');
var rect = canvas.getBoundingClientRect();
canvas.width = 248;
canvas.height = 226;
ctx.fillStyle = "#CDAC5C";
ctx.fillRect(0, 0, canvas.width, canvas.height);
Shouldn’t the event listener names be:
onmousedown
onmousemove
onmouseup
Instead of:
mousedown
mousemove
mouseup
Nah. After some debugging it turns out it does not like these:
ctx.globalCompositeOperation = 'destination-out';
ctx.fillRect(e.clientX - rect.left - 25, e.clientY - rect.top - 25, 50, 50);
No clue why but I just switched over to a different scratching mechanic and managed to get it working. Thanks though!
This sounds really fun btw.
Would love to see the end result!
1 Like
Well, I just releasted it! Feel free to check it out:
Welcome to dr-scratching! [v3.1.0]
After scrolling a bit through the releases I found a couple of scratch card resources which looked fairly simple to make. So, I decided to make my own one.
[banner]
Features
ESX and QBCore
NUI included. Not just a boring ‘use item’ and get money
Language configuration for ESX (includes currency, notifications, …)
Really customizable! (Change e.g. win/lose changes, price money, notifications, scratch amount, …)
Included .sql file. Easily addable to existin…