SA-MP Forums Archive
Bug with GetPlayerWeapon in class selection - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Bug with GetPlayerWeapon in class selection (/showthread.php?tid=571196)



Bug with GetPlayerWeapon in class selection - losrivarola98 - 17.04.2015

If you speak english, please use ****** translate.
Hola, quiero reportar este error en la funcion nativa GetPlayerWeapon, les explicare: Estoy jugando un gamemode y, por ejemplo, tengo el arma id: 31, entonces cuando reinicio el gamemode y estoy en la seleccion de clase, el GetPlayerWeapon me detecta el arma que tenia anteriormente, es decir id 31, probe usando ResetPlayerWeapon en OnPlayerConnect o OnPlayerRequestClass, pero aun asi me detecta la anterior arma. Quisiera que resuelvan ese problema lo mas pronto posible y que el GetPlayerWeapon detecte siempre ID 0 en las selecciones de clase. Saludos!


Re: Bug with GetPlayerWeapon in class selection - Crayder - 17.04.2015

Why would you need GetPlayerWeapon while in class selection? You could easily hook class selection and GetPlayerWeapon to resolve this.
Код:
static bool:DERP_PlayerInClassSelection[MAX_PLAYERS];

stock DERP_GetPlayerWeapon(playerid)
{
	if(DERP_PlayerInClassSelection[playerid]) return 0;
	else return GetPlayerWeapon(playerid);
}

#if defined _ALS_GetPlayerWeapon
	#undef GetPlayerWeapon
#else
	#define _ALS_GetPlayerWeapon
#endif
#define GetPlayerWeapon DERP_GetPlayerWeapon

public OnPlayerRequestClass(playerid, classid)
{
	DERP_PlayerInClassSelection[playerid] = true;
	#if defined DERP_OnPlayerRequestClass
		return DERP_OnPlayerRequestClass(playerid, classid);
	#else
		return 1;
	#endif
}

#if defined _ALS_OnPlayerRequestClass
	#undef OnPlayerRequestClass
#else
	#define _ALS_OnPlayerRequestClass
#endif
#define OnPlayerRequestClass DERP_OnPlayerRequestClass
#if defined DERP_OnPlayerRequestClass
	forward DERP_OnPlayerRequestClass(playerid, classid);
#endif

public OnPlayerSpawn(playerid)
{
	DERP_PlayerInClassSelection[playerid] = false;
	
	#if defined DERP_OnPlayerSpawn
		return DERP_OnPlayerSpawn(playerid);
	#else
		return 1;
	#endif
}

#if defined _ALS_OnPlayerSpawn
	#undef OnPlayerSpawn
#else
	#define _ALS_OnPlayerSpawn
#endif
#define OnPlayerSpawn DERP_OnPlayerSpawn
#if defined DERP_OnPlayerSpawn
	forward DERP_OnPlayerSpawn(playerid);
#endif
You can throw this in your script to fix your problem.