Help
Remember Me?
Home
Forum
Download
Scripting docs
Wiki
Main
Special Pages
Books
Recent Changes
Blogs
Wiki
Main
BarrelScript (Fallout: New Vegas)
This site has been archived and made available for preservation purposes. No edits can be made.
If this is your first visit, be sure to check out the
FAQ
by clicking the link above. You may have to
register
before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.
article
discussion
source
history
Viewing source for:
BarrelScript (Fallout: New Vegas)
This script uses a timer to check for the player being near a special spot. If the player is near that spot and has a certain Z-angle, he will find a broken 9mm pistol.[image]barrel.jpg|thumb|right|BarrelScript in-game[/image] [h="2"] Code [/h] [highlight=cpp] #include "vaultscript.h" #include <cstdio> using namespace std; using namespace vaultmp; Base _9mm = (Base) 0x000E3778; Value spot[] = {-102.76, -398.82, 3458.55}; Value angle[] = {93.0, 134.0}; IDSet player_barrel; Result VAULTSCRIPT BarrelSpot() noexcept { IDVector players = GetList(Type::ID_PLAYER); for (const ID& id : players) { if (!player_barrel.count(id) && IsNearPoint(id, spot[0], spot[1], spot[2], 30.0)) { Value X, Y, Z; GetAngle(id, X, Y, Z); if (Z > angle[0] && Z < angle[1]) { UIMessage(id, "You found a broken 9mm pistol at the bottom of the barrel!"); AddItem(id, _9mm, 1, 0.0, False); player_barrel.insert(id); } } } return (Result) 0; } Void VAULTSCRIPT exec() noexcept { if (GetGameCode() != Index::NEWVEGAS) { printf("BarrelScript is for Fallout: New Vegas only!\n"); terminate(); } CreateTimer(&BarrelSpot, (Interval) 500); printf("BarrelScript for Fallout: New Vegas loaded\n"); } Void VAULTSCRIPT OnPlayerDisconnect(ID player, Reason reason) noexcept { player_barrel.erase(player); } Void VAULTSCRIPT OnSpawn(ID object) noexcept { player_barrel.erase(object); } [/highlight] [highlight=c] #include <vaultmp> #define MAX_PLAYERS (4) new PlayerID[MAX_PLAYERS] = [0,...]; new _9mm = 0x000E3778, Float:spot[] = [-102.76,-398.82,3458.55], Float:angle[] = [93.0,134.0], bool:event[MAX_PLAYERS] = [false,...]; main() { if(GetMaximumPlayers() > MAX_PLAYERS) printf("Error, your MAX_PLAYERS is too low! Required: %d",GetMaximumPlayers()); switch(GetGameCode()) { case NEWVEGAS: { printf("BarrelScript for Fallout: New Vegas loaded\n"); CreateTimer("BarrelSpot",1000); } default: printf("BarrelScript is for Fallout: New Vegas only!\n"); } } public OnPlayerDisconnect(ID, reason) { new conID = GetConnection(ID); event[conID] = false; PlayerID[conID] = 0; } forward BarrelSpot(); public BarrelSpot() { for (new i; i<MAX_PLAYERS; i++) { new ID = PlayerID[i]; if(ID == 0 || event[i]) continue; if(!IsNearPoint(ID,spot[0],spot[1],spot[2],30.0)) continue; new Float:x,Float:y,Float:z; GetAngle(ID,x,y,z); if(z > angle[0] && z < angle[1]) { UIMessage(ID,"You found a broken 9mm pistol at the bottom of the barrel!"); AddItem(ID,_9mm,1,0.0,Bool:false); event[i] = true; } } return 1; } [/highlight] [category]Script examples[/category]