View Single Post
Re: [CZ] Changing model directory "on the fly"?
Old
  (#36)
sPlOrYgOn
<-- He did it.
 
sPlOrYgOn's Avatar
 
Status: Offline
Posts: 1,558
Join Date: Jan 2004
Location: Los Angeles, California, USA, North America, Earth, Solar System, Milky Way.
Default Re: [CZ] Changing model directory "on the fly"? - 12-07-2005

yes it seems possible.
as here is some code from VexdUM module for amx
VexdUM.cpp:
Code:
static cell AMX_NATIVE_CALL CS_SetModel(AMX *amx, cell *params) {
  int iIndex = params[1];

  if (check_player(iIndex)) {
    AMX_RAISEERROR(amx,AMX_ERR_NATIVE);
	return 0;
  }

  int iLength;
  char *szModel = GET_AMXSTRING(amx, params[2], 0, iLength);
  edict_t *pPlayer = INDEXENT(iIndex);
  strcpy(PlInfo[iIndex].szModel, szModel);
  PlInfo[iIndex].bModeled = true;
  SET_CLIENT_KEYVALUE(iIndex, GET_INFO_KEYBUFFER(pPlayer), "model", PlInfo[iIndex].szModel);

  return 1;
}
meta_api.cpp:
Code:
// pfnPlayerPostThink, this code is to set the model at a specified time.
// The second part of the code activates the plugin forward functionality.
void PlayerPostThink(edict_t *pEntity) {
  int index = ENTINDEX(pEntity);

  if((PlInfo[index].bModeled) && (PlInfo[index].fModelSet != 0) && (PlInfo[index].fModelSet < gpGlobals->time)) {
    SET_CLIENT_KEYVALUE(index, GET_INFO_KEYBUFFER(pEntity), "model", PlInfo[index].szModel);
  }

  cell iRetVal = 0;

  for(AmxCallList::AmxCall* i = vPostThinkCallList.head; i ; i = i->next ) {
    if(IS_PLUGIN_RUNNING(i->amx)) {
	  AMX_EXEC(i->amx, &iRetVal, i->iFunctionIdx, 1, index);
	  if(iRetVal & (1 || 2)) {
		  RETURN_META(MRES_SUPERCEDE);
	  }
	}
  }
  RETURN_META(MRES_IGNORED);
}
Code:
// Engine message functions.
void MessageBegin(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed) {

  static int gmsgResetHUD = GET_USER_MSG_ID(PLID, "ResetHUD", NULL);

  // Reset player model a couple milliseconds after this if they are using an edited model.
  if(msg_type == gmsgResetHUD ) {

    int index = ENTINDEX(ed);

    if(PlInfo[index].bModeled) {
      PlInfo[index].fModelSet = gpGlobals->time + AMS_OFFSET;
    }
  }

  // ...

  RETURN_META(MRES_IGNORED);
}

Last edited by sPlOrYgOn; 12-07-2005 at 06:09..
  
Reply With Quote