Start working on logic for new items

This commit is contained in:
Vortrex
2022-05-15 22:28:01 -05:00
parent 1dfd9f1dbf
commit 9e66e0c227
2 changed files with 42 additions and 2 deletions

View File

@@ -723,6 +723,12 @@ function playerUseItem(client, hotBarSlot) {
return false;
}
if(!getItemData(itemIndex)) {
submitBugReport(client, `[AUTOMATED REPORT] Tried to use invalid item (index ${itemIndex} in player slot ${hotBarSlot})`);
cachePlayerHotBarItems(client);
return false;
}
switch(getItemTypeData(getItemData(itemIndex).itemTypeIndex).useType) {
case VRR_ITEM_USETYPE_SKIN: {
getPlayerData(client).itemActionItem = itemIndex;
@@ -1024,6 +1030,39 @@ function playerUseItem(client, hotBarSlot) {
break;
}
case VRR_ITEM_USETYPE_HEALTH: {
let closestPlayer = getClosestPlayer(getPlayerPosition(client), client);
if(!getPlayerData(closestPlayer)) {
messagePlayerError(client, "There isn't anyone close enough to heal!");
return false;
}
if(getDistance(getPlayerPosition(closestPlayer), getPlayerPosition(client)) > getGlobalConfig().firstAidKitPlayerDistance) {
messagePlayerError(client, "There isn't anyone close enough to heal!");
return false;
}
break;
}
case VRR_ITEM_USETYPE_LOTTOTICKET: {
break;
}
case VRR_ITEM_USETYPE_AREARADIO: {
let state = getItemData(itemIndex)
meActionToNearbyPlayers(client, `turns ${getOnOffFromBool(state)} the boombox radio`);
messagePlayerAlert(client, `Use /radiostation to set the radio station and drop it on the ground to play`);
break;
}
case VRR_ITEM_USETYPE_PERSONALRADIO: {
meActionToNearbyPlayers(client, `turns ${getOnOffFromBool(state)} the boombox radio`);
messagePlayerAlert(client, `Use /radiostation to set the radio station`);
break;
}
default: {
messagePlayerError(client, `The ${getItemName(itemIndex)} doesn't do anything when you try to use it.`);
break;