←  Problemy

AMXX.pl: Support AMX Mod X i SourceMod

»

Liczba całkowita do float'u

Zablokowany

  • +
  • -
Sniper Elite - zdjęcie Sniper Elite 07.07.2011

Witam. Staram się obliczyć wyrażenie zmiennych:

set_pev(id, pev_gravity, grawitacja_klasy[klasa_gracza[id]]-grawitacja_gracza[id]*0.01)

Ale mam przy tym error tag mistmach i nie działa jak powinno.

Jak to zapisać aby podawało we floacie te liczbę czyli żeby była zmiennoprzecinkowa bez potrzeby deklarowania zmiennej grawitacja_gracza jako float.

Dzięki za pomoc
Odpowiedz

  • +
  • -
sebul - zdjęcie sebul 07.07.2011

set_pev(id, pev_gravity, float(grawitacja_klasy[klasa_gracza[id]]-grawitacja_gracza[id]*0.01))
Odpowiedz

  • +
  • -
Sniper Elite - zdjęcie Sniper Elite 07.07.2011

Dalej to samo, error tag mismatch
Odpowiedz

  • +
  • -
sebul - zdjęcie sebul 07.07.2011

To chyba tak
set_pev(id, pev_gravity, float(grawitacja_klasy[klasa_gracza[id]])-grawitacja_gracza[id]*0.01)
Odpowiedz

  • +
  • -
Sniper Elite - zdjęcie Sniper Elite 07.07.2011

Dalej to samo :/
Odpowiedz

  • +
  • -
R3X - zdjęcie R3X 07.07.2011

set_pev(id, pev_gravity, float(grawitacja_klasy[klasa_gracza[id]])-float(grawitacja_gracza[id])*0.01)
no to próbuj dalej float`ować xD albo w końcu pokaż nam definicje tych tablic
Odpowiedz

  • +
  • -
Sniper Elite - zdjęcie Sniper Elite 07.07.2011

new grawitacja_gracza[33];
new const Float:grawitacja_klasy[] = {0.0, 1.0, 0.8, 1.0, 1.0};

Próbowałem tak, że grawitacja_gracza jest we floacie, ale później jej do nvault zapisać nie mogłem, oraz statystyki z nią nie działały.
Odpowiedz

  • +
  • -
R3X - zdjęcie R3X 07.07.2011

set_pev(id, pev_gravity, grawitacja_klasy[klasa_gracza[id]]-float(grawitacja_gracza[id])*0.01)
no to tak
Odpowiedz

  • +
  • -
Sniper Elite - zdjęcie Sniper Elite 07.07.2011

Ok, dzięki działa, pomógłbyś mi jeszcze z wpływaniem na obrażenia do zombie moda. Mam funkcję taką:

public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{
	// Non-player damage or self damage
	if (victim == attacker || !is_user_valid_connected(attacker))
		return HAM_IGNORED;
	
	// New round starting or round ended
	if (g_newround || g_endround)
		return HAM_SUPERCEDE;
	
	// Victim shouldn't take damage or victim is frozen
	if (g_nodamage[victim] || g_frozen[victim])
		return HAM_SUPERCEDE;
	
	// Prevent friendly fire
	if (g_zombie[attacker] == g_zombie[victim])
		return HAM_SUPERCEDE;
	
	// Attacker is human...
	if (!g_zombie[attacker])
	{
		// Armor multiplier for the final damage on normal zombies
		if (!g_nemesis[victim])
		{
			damage *= get_pcvar_float(cvar_zombiearmor)
			SetHamParamFloat(4, damage)
		}
		
		// Reward ammo packs
		if (!g_survivor[attacker] || !get_pcvar_num(cvar_survignoreammo))
		{
			// Store damage dealt
			g_damagedealt[attacker] += floatround(damage)
			
			// Reward ammo packs for every [ammo damage] dealt
			while (g_damagedealt[attacker] > get_pcvar_num(cvar_ammodamage))
			{
				g_ammopacks[attacker]++
				g_damagedealt[attacker] -= get_pcvar_num(cvar_ammodamage)
			}
		}
		
		return HAM_IGNORED;
	}
	
	// Attacker is zombie...
	
	// Prevent infection/damage by HE grenade (bugfix)
	if (damage_type & DMG_HEGRENADE)
		return HAM_SUPERCEDE;
	
	// Nemesis?
	if (g_nemesis[attacker])
	{
		// Ignore nemesis damage override if damage comes from a 3rd party entity
		// (to prevent this from affecting a sub-plugin's rockets e.g.)
		if (inflictor == attacker)
		{
			// Set nemesis damage
			SetHamParamFloat(4, get_pcvar_float(cvar_nemdamage))
		}
		
		return HAM_IGNORED;
	}
	
	// Last human or not an infection round
	if (g_survround || g_nemround || g_swarmround || g_plagueround || fnGetHumans() == 1)
		return HAM_IGNORED; // human is killed
	
	// Does human armor need to be reduced before infecting?
	if (get_pcvar_num(cvar_humanarmor))
	{
		// Get victim armor
		static Float:armor
		pev(victim, pev_armorvalue, armor)
		
		// Block the attack if he has some
		if (armor > 0.0)
		{
			emit_sound(victim, CHAN_BODY, sound_armorhit, 1.0, ATTN_NORM, 0, PITCH_NORM)
			set_pev(victim, pev_armorvalue, floatmax(0.0, armor - damage))
			return HAM_SUPERCEDE;
		}
	}
	
	// Infection allowed
	zombieme(victim, attacker, 0, 0, 1) // turn into zombie
	return HAM_SUPERCEDE;
}

Można by wpłynąć tak jak na codzie przez:

SetHamParamFloat(4, damage);

Tylko nie wiem gdzie to umieścić aby działało.

Dodano 07 lipiec 2011 - 18:08:
Już się uporałem z tym
Odpowiedz
Zablokowany