OnDialogRespons HELP !+REP
#1

here is the case
Код:
 
1764 public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
1765 {
1766    if(dialogid == DIALOG_KUPOVINA)
1767    {
1768        if(response) // If they clicked 'Select' or double-clicked a weapon
1769        {
1770            // Give them the weapon
1771            switch(listitem)
1772            {
1773                case 0:
1774				GivePlayerWeapon(playerid,41,500);
1775                GivePlayerMoney(playerid,-500);
1776                case 1:
1777				GivePlayerWeapon(playerid,2,1);
1778                GivePlayerMoney(playerid,-200);
1779            }
1780        }
1781        return 1; 
1782    }
1783	return 0;
1784}
And here are the errors

C:\Users\korisnik\Desktop\Novi server\gamemodes\VirtualLife.pwn(1775) : error 002: only a single statement (or expression) can follow each "case"
C:\Users\korisnik\Desktop\Novi server\gamemodes\VirtualLife.pwn(1775) : warning 215: expression has no effect
C:\Users\korisnik\Desktop\Novi server\gamemodes\VirtualLife.pwn(1776) : error 014: invalid statement; not in switch
C:\Users\korisnik\Desktop\Novi server\gamemodes\VirtualLife.pwn(1776) : warning 215: expression has no effect
C:\Users\korisnik\Desktop\Novi server\gamemodes\VirtualLife.pwn(1776) : error 001: expected token: ";", but found ":"
C:\Users\korisnik\Desktop\Novi server\gamemodes\VirtualLife.pwn(1776) : error 029: invalid expression, assumed zero
C:\Users\korisnik\Desktop\Novi server\gamemodes\VirtualLife.pwn(1776) : fatal error 107: too many error messages on one line
Reply
#2

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_KUPOVINA)
{
if(response) // If they clicked 'Select' or double-clicked a weapon
{
// Give them the weapon
switch(listitem)
{
case 0:
{
GivePlayerWeapon(playerid,41,500);
GivePlayerMoney(playerid,-500);
}
case 1:
{
GivePlayerWeapon(playerid,2,1);
GivePlayerMoney(playerid,-200);
}
}
}
return 1;
}
return 0;
}
Reply
#3

Thank u
!
Reply
#4

Creating bracket in a case is not usefull (I think), when you can do this code in one line. You can do like this, It's should compile without errors..
pawn Код:
// on the switch :

                case 0: GivePlayerWeapon(playerid,41,500), GivePlayerMoney(playerid,-500);
                case 1: GivePlayerWeapon(playerid,2,1), GivePlayerMoney(playerid,-200);
Reply
#5

yes it worked, but how can i make that if he chose something "u don't have enough money" ??
Reply
#6

As you can see now I adding bracket because the codes does two lines.

pawn Код:
case 0:
{
    if(GetPlayerMoney(playerid) < PRICE_HE_SHOULD HAVE) return SendClientMessage(playerid, COLOR, "poorguys")
    GivePlayerWeapon(playerid,41,500), GivePlayerMoney(playerid,-500);
}
// do the same thing for the second case.
by addind this line :
pawn Код:
if(GetPlayerMoney(playerid) < PRICE_HE_SHOULD HAVE) return SendClientMessage(playerid, COLOR, "poorguys")
// remplace "PRICE_HE_SHOULD_HAVE" by the price of the guns.. and "poorguys" by your message.
Reply
#7

This tutorial will be useful if you are creating a weapon shop...

https://sampforum.blast.hk/showthread.php?tid=540051
Reply
#8

Thank u guys !
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)