int CEntityNatives::Create(SQVM* pVM) { CResource* pResource = g_pResourceManager->Get(pVM); assert( pResource ); const char* szName; sq_getstring(pVM,2,&szName); if(CEntity::GetType(szName) == ENTITY_TYPE_CUSTOM) { CEntity* pEntity = new CEntity(ENTITY_TYPE_CUSTOM, pResource, szName); if(pEntity->GetID() != INVALID_ENTITY_ID_LONG) { sq_pushentity(pVM,pEntity); } else { delete pEntity; sq_pushnull(pVM); } } else sq_pushnull(pVM); return 1; }
int CEntityNatives::GetID(SQVM* pVM) { CEntity* pEntity = sq_toentity(pVM, 2); if(pEntity) sq_pushinteger(pVM,pEntity->GetID()); else sq_pushnull(pVM); return 1; }