-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.cpp
30 lines (26 loc) · 926 Bytes
/
api.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/.
*
* The original code is copyright (c) 2022, open.mp team and contributors.
*/
#include <cstdlib>
#include "api.hpp"
SomeExternalAPI::SomeExternalAPI(std::string)
{
// We don't actually care about the location for this example...
}
// This is just a placeholder for some real world weather lookup API. We aren't going to bother
// with a full implementation as this class merely serves as an example of real-world usage. It
// isn't important to demonstrating the open.mp component SDK.
int SomeExternalAPI::getCurrentWeather()
{
// 1% chance of randomly selecting a new weather.
if (rand() % 100 == 0)
{
// I'm not using `<random>`...
currentWeather_ = rand() % 10;
}
return currentWeather_;
}