Skip to content

Commit 01489cd

Browse files
committed
client: Add hasLocalMeta and getLocalMeta
Former-commit-id: 9d50865
1 parent 0323dfa commit 01489cd

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

client/src/bindings/Player.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,28 @@ static void ToString(const v8::FunctionCallbackInfo<v8::Value>& info)
2424
V8_RETURN_STRING(ss.str().c_str());
2525
}
2626

27+
static void HasLocalMeta(const v8::FunctionCallbackInfo<v8::Value>& info)
28+
{
29+
V8_GET_ISOLATE_CONTEXT();
30+
V8_CHECK_ARGS_LEN_MIN(1);
31+
V8_GET_THIS_BASE_OBJECT(player, alt::IPlayer);
32+
33+
V8_ARG_TO_STD_STRING(1, key);
34+
35+
V8_RETURN(player->HasLocalMetaData(key));
36+
}
37+
38+
static void GetLocalMeta(const v8::FunctionCallbackInfo<v8::Value>& info)
39+
{
40+
V8_GET_ISOLATE_CONTEXT();
41+
V8_CHECK_ARGS_LEN_MIN(1);
42+
V8_GET_THIS_BASE_OBJECT(player, alt::IPlayer);
43+
44+
V8_ARG_TO_STD_STRING(1, key);
45+
46+
V8_RETURN_MVALUE(player->GetLocalMetaData(key));
47+
}
48+
2749
static void CurrentWeaponComponentsGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
2850
{
2951
V8_GET_ISOLATE_CONTEXT();
@@ -128,6 +150,9 @@ extern V8Class v8Player("Player", v8Entity, [](v8::Local<v8::FunctionTemplate> t
128150
V8Helpers::SetStaticAccessor(isolate, tpl, "streamedIn", &StreamedInGetter);
129151
V8Helpers::SetStaticAccessor(isolate, tpl, "local", &LocalGetter);
130152

153+
V8Helpers::SetMethod(isolate, tpl, "hasLocalMeta", &HasLocalMeta);
154+
V8Helpers::SetMethod(isolate, tpl, "getLocalMeta", &GetLocalMeta);
155+
131156
// Common getters
132157
V8Helpers::SetAccessor<IPlayer, std::string, &IPlayer::GetName>(isolate, tpl, "name");
133158
V8Helpers::SetAccessor<IPlayer, Ref<IVehicle>, &IPlayer::GetVehicle>(isolate, tpl, "vehicle");

0 commit comments

Comments
 (0)