SA-MP Forums Archive
Why message send "Two or even three times" - 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: Why message send "Two or even three times" (/showthread.php?tid=631649)



Why message send "Two or even three times" - henkas - 02.04.2017

Hi
Any ideas why sometimes message send two or three times "You picked something"?
Код:
    if(pInfo[playerid][IsPlayerInfected] == 0)
	{
    new slot, weap, ammo;
    for ( slot = 0; slot < 14; slot++ )
    {
    GetPlayerWeaponData(playerid,slot,weap,ammo);
    if(IsValidWeapon(weap))
    {
    new randomselect = random(3); // i put random 5 because i want give a chance win nothing.
    switch(randomselect)
	{
    case 0:
	{
    new randomammo = random(15);
    GivePlayerWeapon(playerid,weap,randomammo);
	format(sudasnx,sizeof(sudasnx),""COL_WHITE"|: You picked something");
	SendClientMessage(playerid,-1,sudasnx);
	DestroyPickup(meatDrops[playerid]);
    }



Re: Why message send "Two or even three times" - SyS - 02.04.2017

Break from loop or use return to break from function its self when a match or true statement occurred.


Re: Why message send "Two or even three times" - henkas - 02.04.2017

Quote:
Originally Posted by Sreyas
Посмотреть сообщение
Break from loop or use return to break from function its self when a match or true statement occurred.
Like this?
Код:
new randomammo = random(15);
    GivePlayerWeapon(playerid,weap,randomammo);
	format(sudasnx,sizeof(sudasnx),""COL_WHITE"|: You picked something");
	SendClientMessage(playerid,-1,sudasnx);
	DestroyPickup(meatDrops[playerid]);
        break;



Re: Why message send "Two or even three times" - henkas - 05.04.2017

Bump


Re: Why message send "Two or even three times" - Dangjai - 05.04.2017

Код:
    if(pInfo[playerid][IsPlayerInfected] == 0)
	{
    new slot, weap, ammo;
    for ( slot = 0; slot < 14; slot++ )
    {
    GetPlayerWeaponData(playerid,slot,weap,ammo);
    if(IsValidWeapon(weap))
    {
    new randomselect = random(3); // i put random 5 because i want give a chance win nothing.
    switch(randomselect)
	{
    case 0:
	{
    new randomammo = random(15);
    GivePlayerWeapon(playerid,weap,randomammo);
	format(sudasnx,sizeof(sudasnx),""COL_WHITE"|: You picked something");
	SendClientMessage(playerid,-1,sudasnx);
	DestroyPickup(meatDrops[playerid]);
        return 1;
    }