@@ -223,21 +223,26 @@ int CLuaPlayerDefs::CanPlayerUseFunction(lua_State* luaVM)
223
223
int CLuaPlayerDefs::GetPlayerName (lua_State* luaVM)
224
224
{
225
225
// string getPlayerName ( player thePlayer )
226
- CElement* pElement;
226
+ CElement* pElement; // player or console
227
227
228
228
CScriptArgReader argStream (luaVM);
229
229
argStream.ReadUserData (pElement);
230
230
231
231
if (!argStream.HasErrors ())
232
232
{
233
- SString strNick;
234
- if (CStaticFunctionDefinitions::GetPlayerName (pElement, strNick))
233
+ if (IS_PLAYER (pElement) || IS_CONSOLE (pElement))
235
234
{
236
- lua_pushstring (luaVM, strNick);
237
- return 1 ;
235
+ SString strNick;
236
+ if (CStaticFunctionDefinitions::GetPlayerName (pElement, strNick))
237
+ {
238
+ lua_pushstring (luaVM, strNick);
239
+ return 1 ;
240
+ }
238
241
}
242
+ else
243
+ argStream.SetTypeError (" player or console" , 1 );
239
244
}
240
- else
245
+ if (argStream. HasErrors ())
241
246
m_pScriptDebugging->LogCustom (luaVM, argStream.GetFullErrorMessage ());
242
247
243
248
lua_pushboolean (luaVM, false );
@@ -247,21 +252,26 @@ int CLuaPlayerDefs::GetPlayerName(lua_State* luaVM)
247
252
int CLuaPlayerDefs::GetPlayerIP (lua_State* luaVM)
248
253
{
249
254
// string getPlayerIP ( player thePlayer )
250
- CElement* pElement;
255
+ CElement* pElement; // player or console
251
256
252
257
CScriptArgReader argStream (luaVM);
253
258
argStream.ReadUserData (pElement);
254
259
255
260
if (!argStream.HasErrors ())
256
261
{
257
- SString strIP;
258
- if (CStaticFunctionDefinitions::GetPlayerIP (pElement, strIP))
262
+ if (IS_PLAYER (pElement) || IS_CONSOLE (pElement))
259
263
{
260
- lua_pushstring (luaVM, strIP);
261
- return 1 ;
264
+ SString strIP;
265
+ if (CStaticFunctionDefinitions::GetPlayerIP (pElement, strIP))
266
+ {
267
+ lua_pushstring (luaVM, strIP);
268
+ return 1 ;
269
+ }
262
270
}
271
+ else
272
+ argStream.SetTypeError (" player or console" , 1 );
263
273
}
264
- else
274
+ if (argStream. HasErrors ())
265
275
m_pScriptDebugging->LogCustom (luaVM, argStream.GetFullErrorMessage ());
266
276
267
277
lua_pushboolean (luaVM, false );
@@ -292,21 +302,26 @@ int CLuaPlayerDefs::GetPlayerVersion(lua_State* luaVM)
292
302
int CLuaPlayerDefs::GetPlayerAccount (lua_State* luaVM)
293
303
{
294
304
// account getPlayerAccount ( player thePlayer )
295
- CElement* pElement;
305
+ CElement* pElement; // player or console
296
306
297
307
CScriptArgReader argStream (luaVM);
298
308
argStream.ReadUserData (pElement);
299
309
300
310
if (!argStream.HasErrors ())
301
311
{
302
- CAccount* pAccount = CStaticFunctionDefinitions::GetPlayerAccount (pElement);
303
- if (pAccount)
312
+ if (IS_PLAYER (pElement) || IS_CONSOLE (pElement))
304
313
{
305
- lua_pushaccount (luaVM, pAccount);
306
- return 1 ;
314
+ CAccount* pAccount = CStaticFunctionDefinitions::GetPlayerAccount (pElement);
315
+ if (pAccount)
316
+ {
317
+ lua_pushaccount (luaVM, pAccount);
318
+ return 1 ;
319
+ }
307
320
}
321
+ else
322
+ argStream.SetTypeError (" player or console" , 1 );
308
323
}
309
- else
324
+ if (argStream. HasErrors ())
310
325
m_pScriptDebugging->LogCustom (luaVM, argStream.GetFullErrorMessage ());
311
326
312
327
lua_pushboolean (luaVM, false );
@@ -316,8 +331,8 @@ int CLuaPlayerDefs::GetPlayerAccount(lua_State* luaVM)
316
331
int CLuaPlayerDefs::SetPlayerName (lua_State* luaVM)
317
332
{
318
333
// bool setPlayerName ( player thePlayer, string newName )
319
- CElement * pElement;
320
- SString strName;
334
+ CPlayer * pElement;
335
+ SString strName;
321
336
322
337
CScriptArgReader argStream (luaVM);
323
338
argStream.ReadUserData (pElement);
@@ -1118,7 +1133,7 @@ int CLuaPlayerDefs::SetPlayerBlurLevel(lua_State* luaVM)
1118
1133
1119
1134
int CLuaPlayerDefs::RedirectPlayer (lua_State* luaVM)
1120
1135
{
1121
- CElement* pElement;
1136
+ CPlayer* pElement;
1122
1137
SString strHost;
1123
1138
unsigned short usPort;
1124
1139
SString strPassword;
0 commit comments