Untitled

mail@pastecode.io avatar
unknown
javascript
a month ago
2.5 kB
2
Indexable
Never
Player.WrestlingData.Clicks++;
	
	if(Player.WrestlingData.Position == 0) 
	{
		mp.players.broadcast("PLAYER 0 CLICKED");
		Player.WrestlingData.Table.setVariable("INTENSION", currentIntesnionFloat + 0.015);
	}
	else 
	{
		mp.players.broadcast("PLAYER 1 CLICKED");
		Player.WrestlingData.Table.setVariable("INTENSION", currentIntesnionFloat - 0.015);
	}

	if (currentIntesnionFloat > 0.9) {

		mp.players.broadcast("W1");

		Player.WrestlingData?.Table?.setVariable("READY", 0);
		

		const opponent = ArmWrestling.GetWrestlingPlayer( (Player.WrestlingData.Position == 1 ? 0 : 1) );

		mp.players.broadcast(`${Player.name} (${Player.WrestlingData.Clicks}) - ${opponent.name} (${opponent.WrestlingData.Clicks})`);

		if(!opponent || !mp.players.exists(opponent))
			return console.log("Player one doesn't exist anymore.");

		let winner = (Player.WrestlingData.Clicks > opponent.WrestlingData.Clicks ? Player : opponent),
			loser = (Player.WrestlingData.Clicks > opponent.WrestlingData.Clicks ? opponent : Player);

		winner.call('SendNotification', ["info", "Congrats, you won!", "toast-top-center"]);
		winner.playAnimation("mini@arm_wrestling", "win_a_ped_a", 1, 1);

		loser.call('SendNotification', ["warning", `${winner.name} has won!`, "toast-top-center"]);
		loser.playAnimation("mini@arm_wrestling", "win_a_ped_b", 1, 1);

		setTimeout(() => {
			ArmWrestling.LeaveTable(opponent);
			ArmWrestling.LeaveTable(Player);
		}, 4000);


		return;
	}
	else if (currentIntesnionFloat < 0.10) {

		mp.players.broadcast("W2");

		const opponent = ArmWrestling.GetWrestlingPlayer( (Player.WrestlingData.Position == 0 ? 1 : 0) );
		if(!opponent || !mp.players.exists(opponent)) return console.log("Player two doesn't exist anymore.");

		mp.players.broadcast(`${Player.name} (${Player.WrestlingData.Clicks}) - ${opponent.name} (${opponent.WrestlingData.Clicks})`);

		let winner = (Player.WrestlingData.Clicks > opponent.WrestlingData.Clicks ? Player : opponent),
			loser = (Player.WrestlingData.Clicks > opponent.WrestlingData.Clicks ? opponent : Player);

		winner.call('SendNotification', ["info", "Congrats, you won!", "toast-top-center"]);
		winner.playAnimation("mini@arm_wrestling", "win_b_ped_b", 1, 1);

		loser.call('SendNotification', ["warning", `${winner.name} has won!`, "toast-top-center"]);
		loser.playAnimation("mini@arm_wrestling", "win_b_ped_a", 1, 1);

		Player.WrestlingData?.Table?.setVariable("READY", 0);
		setTimeout(() => {
			ArmWrestling.LeaveTable(opponent);
			ArmWrestling.LeaveTable(Player);
		}, 4000);

		return;
	}
Leave a Comment