SA-MP Forums Archive
Fix this Dialog - 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: Fix this Dialog (/showthread.php?tid=653348)



Fix this Dialog - Dirda - 02.05.2018

Anyone know what's problem with this dialog? My server crashes after i choose any listitem In-Game.

Код:
if(dialogid == DIALOG_MEDICINE)
	{
	    if(!response) return 1;
	    switch(listitem)
	    {
	        case 0:
	        {
	        if(PlayerInfo[playerid][pAspirin] < 1)
	        {
	         SendClientMessageEx(playerid, COLOR_WHITE, "Anda tidak mempunyai obat Aspirin");
	         return 1;
	        }
	         SetPVarInt(playerid, "UseAspirin") == 1;
	         PlayerInfo[playerid][pAspirin] -= 1;
	         SendClientMessageEx(playerid, COLOR_WHITE, "Anda telah meminum sebutir obat Aspirin");
	        }
	        case 1:
	        {
	        if(PlayerInfo[playerid][pParacetamol] < 1)
	        {
	         SendClientMessageEx(playerid, COLOR_WHITE, "Anda tidak mempunyai obat Paracetamol");
	         return 1;
	        }
	         SetPVarInt(playerid, "UseParacetamol") == 1;
	         PlayerInfo[playerid][pParacetamol] -= 1;
	         SendClientMessageEx(playerid, COLOR_WHITE, "Anda telah meminum sebutir obat Paracetamol");
	        }
	        case 2:
	        {
	        if(PlayerInfo[playerid][pMylanta] < 1)
	        {
	         SendClientMessageEx(playerid, COLOR_WHITE, "Anda tidak mempunyai obat Mylanta");
	         return 1;
	        }
	         SetPVarInt(playerid, "UseMylanta") == 1;
	         PlayerInfo[playerid][pMylanta] -= 1;
	         SendClientMessageEx(playerid, COLOR_WHITE, "Anda telah meminum sebutir obat Mylanta");
	        }
	        case 3:
	        {
	        if(PlayerInfo[playerid][pAspirin] < 1)
	        {
	         SendClientMessageEx(playerid, COLOR_WHITE, "Anda tidak mempunyai obat Buscopan Plus");
	         return 1;
	        }
	         SetPVarInt(playerid, "UseBuscopan") == 1;
	         PlayerInfo[playerid][pBuscopan] -= 1;
	         SendClientMessageEx(playerid, COLOR_WHITE, "Anda telah meminum sebutir obat Buscopan Plus");
	        }
	    }
	}



Re: Fix this Dialog - DarkMythHunter - 02.05.2018

Quote:
Originally Posted by Dirda
Посмотреть сообщение
Anyone know what's problem with this dialog? My server crashes after i choose any listitem In-Game.

Код:
if(dialogid == DIALOG_MEDICINE)
	{
	    if(!response) return 1;
	    switch(listitem)
	    {
	        case 0:
	        {
	        if(PlayerInfo[playerid][pAspirin] < 1)
	        {
	         SendClientMessageEx(playerid, COLOR_WHITE, "Anda tidak mempunyai obat Aspirin");
	         return 1;
	        }
	         SetPVarInt(playerid, "UseAspirin") == 1;
	         PlayerInfo[playerid][pAspirin] -= 1;
	         SendClientMessageEx(playerid, COLOR_WHITE, "Anda telah meminum sebutir obat Aspirin");
	        }
	        case 1:
	        {
	        if(PlayerInfo[playerid][pParacetamol] < 1)
	        {
	         SendClientMessageEx(playerid, COLOR_WHITE, "Anda tidak mempunyai obat Paracetamol");
	         return 1;
	        }
	         SetPVarInt(playerid, "UseParacetamol") == 1;
	         PlayerInfo[playerid][pParacetamol] -= 1;
	         SendClientMessageEx(playerid, COLOR_WHITE, "Anda telah meminum sebutir obat Paracetamol");
	        }
	        case 2:
	        {
	        if(PlayerInfo[playerid][pMylanta] < 1)
	        {
	         SendClientMessageEx(playerid, COLOR_WHITE, "Anda tidak mempunyai obat Mylanta");
	         return 1;
	        }
	         SetPVarInt(playerid, "UseMylanta") == 1;
	         PlayerInfo[playerid][pMylanta] -= 1;
	         SendClientMessageEx(playerid, COLOR_WHITE, "Anda telah meminum sebutir obat Mylanta");
	        }
	        case 3:
	        {
	        if(PlayerInfo[playerid][pAspirin] < 1)
	        {
	         SendClientMessageEx(playerid, COLOR_WHITE, "Anda tidak mempunyai obat Buscopan Plus");
	         return 1;
	        }
	         SetPVarInt(playerid, "UseBuscopan") == 1;
	         PlayerInfo[playerid][pBuscopan] -= 1;
	         SendClientMessageEx(playerid, COLOR_WHITE, "Anda telah meminum sebutir obat Buscopan Plus");
	        }
                return 1;
	    }
            return 0;
	}
Try this?


Re: Fix this Dialog - Dirda - 02.05.2018

Still.

I found the solution.
Missunderstanding with the SetPVarInt, it doesn't need any operator.