Raised This Month: $ Target: $400
 0% 

DispatchKeyValue woes


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
SidLuke
Senior Member
Join Date: Mar 2004
Location: Poland, Chrzanow
Old 06-26-2004 , 12:51  
Reply With Quote #7

Code:
static cell AMX_NATIVE_CALL create_pwup(AMX *amx, cell *params){ // pwup ,origin[3]

	string_t item = MAKE_STRING("ts_powerup"); 
	edict_t	*pent = CREATE_NAMED_ENTITY( item );
	if ( FNullEnt( pent ) ){
		return 0;
	}

	KeyValueData pkvd;
	char szTemp[16];

	sprintf(szTemp,"%d",params[1]);

	pkvd.szClassName = (char *)STRING(pent->v.classname);
	pkvd.szKeyName = "pwuptype"; // type
	pkvd.szValue = szTemp;
	pkvd.fHandled = false;
	MDLL_KeyValue(pent, &pkvd);

	pkvd.szClassName = (char *)STRING(pent->v.classname);
	pkvd.szKeyName = "pwupduration"; // duration
	pkvd.szValue = "60";
	pkvd.fHandled = false;
	MDLL_KeyValue(pent, &pkvd);

/*
	pkvd.szClassName = (char *)STRING(pent->v.classname);
	pkvd.szKeyName = "message";
	pkvd.szValue = "";
	pMDLL_KeyValue(pEntity, &pkvd);
*/
	cell *vInput = MF_GetAmxAddr(amx,params[2]);

	float fNewX = *(float *)((void *)&vInput[0]);
	float fNewY = *(float *)((void *)&vInput[1]);
	float fNewZ = *(float *)((void *)&vInput[2]);

	vec3_t vNewValue = vec3_t(fNewX, fNewY, fNewZ);

	MDLL_Spawn(pent);
	pent->v.origin = vNewValue;

	return ENTINDEX(pent);
}

// create_pwup -> !wait! -> give_pwup
static cell AMX_NATIVE_CALL give_pwup(AMX *amx, cell *params){ // index,pwupentindex

	edict_t* pent = INDEXENT(params[2]);
	if ( FNullEnt( pent ) || strcmp("ts_powerup",STRING(pent->v.classname))!=0 ){
		return 0;
	}
	
	int id = params[1];
	if ( id<1 || id>gpGlobals->maxClients ){ 
		MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
		return 0;
	}
	CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
	if ( !pPlayer->ingame || !pPlayer->IsAlive() ){
		REMOVE_ENTITY(pent);
		return 0;
	}

	pent->v.origin = pPlayer->pEdict->v.origin;

	MDLL_Touch(pent, pPlayer->pEdict);

	REMOVE_ENTITY(pent);

	return 1;

}
SidLuke is offline
Send a message via AIM to SidLuke Send a message via MSN to SidLuke
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:40.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode