This piece of code gives errors and i cant understand why -
slymatt - 20.07.2011
Could you help me with this piece of code please:
Код:
switch(listitem)
{
case DIALOG_NOOB247:
{
if(response == 1)
{
case 0:
{
if(GetPlayerMoney(playerid) < 10) return SendClientMessage(playerid, COLOUR_YELLOW, "You cant afford this item.");
GivePlayerMoney(playerid, -10);
}
case 1:
{
if(GetPlayerMoney(playerid) < 20) return SendClientMessage(playerid, COLOUR_YELLOW, "You cant afford this item.");
GivePlayerMoney(playerid, -20);
}
case 2:
{
if(GetPlayerMoney(playerid) < 30) return SendClientMessage(playerid, COLOUR_YELLOW, "You cant afford this item.");
GivePlayerMoney(playerid, -30);
}
case 3:
{
return SendClientMessage(playerid, COLOUR_YELLOW, "You cant afford this item.");
}
}
}
case DIALOG_GIVECAR:
{
if(response == 1)
{
case 4:
{
CreateVehicle(541, xaxis, yaxis, zaxis, angle, 1, 1, 0); //Bullet
}
case 5:
{
CreateVehicle(541, 1472.7599, -1726.0511, 13.5469, 182.6850, 1, 1, 0);//Super GT
}
case 6:
{
CreateVehicle(541, 1472.7599, -1726.0511, 13.5469, 182.6850, 1, 1, 0);//Hotring Racer
}
case 7:
{
CreateVehicle(541, 1472.7599, -1726.0511, 13.5469, 182.6850, 1, 1, 0);//Turismo
}
case 8:
{
CreateVehicle(541, 1472.7599, -1726.0511, 13.5469, 182.6850, 1, 1, 0);//Beagle(Plane)
}
}
}
}
}
Im getting these errors and cant understand why:
Код:
C:\Users\mattt\Desktop\New\gamemodes\arrp.pwn(382) : warning 203: symbol is never used: "params"
C:\Users\mattt\Desktop\New\gamemodes\arrp.pwn(401) : warning 203: symbol is never used: "params"
C:\Users\mattt\Desktop\New\gamemodes\arrp.pwn(706) : error 002: only a single statement (or expression) can follow each "case"
C:\Users\mattt\Desktop\New\gamemodes\arrp.pwn(706 -- 707) : error 028: invalid subscript (not an array or too many subscripts): "listitem"
C:\Users\mattt\Desktop\New\gamemodes\arrp.pwn(706 -- 709) : error 001: expected token: "}", but found "case"
C:\Users\mattt\Desktop\New\gamemodes\arrp.pwn(706 -- 709) : fatal error 107: too many error messages on one line
Re: This piece of code gives errors and i cant understand why -
Roko_foko - 20.07.2011
You have too much cases. Some have their switch, but some don't. Cases can't be alone. They must have their switch.
pawn Код:
swirch(Var)
{
case 0:printf("Hello");
}
^this is ok.
^not good.
pawn Код:
swirch(Var)
{
case 0:printf("Hello");
if(Var==2)
{
printf("Hello2");
}
}
^not good aswell. In switch clause only cases, and default can exist
Re: This piece of code gives errors and i cant understand why -
slymatt - 20.07.2011
so why does all this work but that doesnt:
Код:
new Float:xaxis, Float:yaxis, Float:zaxis, Float:angle;
GetPlayerPos(playerid, xaxis, yaxis, zaxis);
GetPlayerFacingAngle(playerid, angle);
switch(dialogid)
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if (response)
{
if(!strlen(inputtext)) {
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""WHITE"Registering",""RED"You have entered an invalid password.\n"WHITE"Type your password below to register a new account.","Register","Quit");
}
if(INI_Open(getINI(playerid))) {
INI_WriteString("Pass", inputtext);
//INI_WriteInt("Age", strval(inputtext));
INI_WriteInt("Cash", StartingCash);
INI_WriteInt("Score",1);
INI_WriteInt("Skin", 299);
INI_WriteInt("Kills", killer[playerid]);
INI_WriteInt("Deaths", died[playerid]);
//INI_WriteInt("Timeplayed", 0);
//INI_WriteString("Ipaddress", "NEEDS SETTING");
INI_WriteString("Savedpositionx", "361.8363");
INI_WriteString("Savedpositiony", "173.4745");
INI_WriteString("Savedpositionz", "1008.3828");
INI_WriteString("Savedpositiona", "90.2508");
INI_WriteInt("playersInterior", 3);
INI_WriteInt("playersVworld", 0);
INI_WriteInt("Admin", 0);
//INI_WriteInt("Faction", 0);
//INI_WriteInt("Faction", 0);
//INI_WriteInt("Bankdeposit", 0);
//INI_WriteInt("Banned", 0);
//INI_WriteString("Banreason", "");
//INI_WriteInt("House", 0);
//INI_WriteInt("Biz", 0);
//INI_WriteInt("Fightstyle", 0);
//INI_WriteInt("Walkstyle", 0);
//INI_WriteInt("TimesArrested", 0);
//INI_WriteInt("Drivinglicense", 0);
//INI_WriteInt("Flinglicense", 0);
//INI_WriteInt("Boatlicense", 0);
//INI_WriteInt("GunLicense", 0);
//INI_WriteInt("Car", 0);
//INI_WriteInt("Job", 0);
//INI_WriteInt("Earnings", 0);
INI_Save();
INI_Close();
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""WHITE"Login",""WHITE"Type your password below to login.","Login","Quit");
}
}
}
case DIALOG_LOGIN:
{
if (!response) return Kick ( playerid );
if(response)
{
if(!strlen(inputtext)) {
return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Login",""RED"You have entered an invalid password.\n"WHITE"Type your password below to login.","Login","Quit");
}
if(INI_Open(getINI(playerid))) {
INI_ReadString(PlayerInfo[playerid][Pass],"Pass",20);
if(strcmp(inputtext,PlayerInfo[playerid][Pass],false)) {
return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""WHITE"Login",""RED"You have entered an incorrect password.\n"WHITE"Type your password below to login.","Login","Quit");
}
new Float:x, Float:y, Float:z, Float:a;
SetPlayerScore(playerid, INI_ReadInt("Score"));
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, INI_ReadInt("Cash"));
PlayerInfo[playerid][Admin] = INI_ReadInt("Admin");
PlayerInfo[playerid][Skin] = INI_ReadInt("Skin");
x = INI_ReadFloat("Savedpositionx");
y = INI_ReadFloat("Savedpositiony");
z = INI_ReadFloat("Savedpositionz");
a = INI_ReadFloat("Savedpositiona");
SetPlayerInterior(playerid, INI_ReadInt("playersInterior"));
SetPlayerVirtualWorld(playerid, INI_ReadInt("playersVworld"));
SetSpawnInfo(playerid, 0, PlayerInfo[playerid][Skin], x, y, z, a, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
INI_Close();
}
}
}
//DMV CODE!
case DIALOG_DMVCARTEST:
{
if(response)
{
SendClientMessage(playerid, COLOUR_YELLOW, "Welcome to you the DMV Licensing Center");
SendClientMessage(playerid, COLOUR_YELLOW, "We will now start your test please head outside");
SendClientMessage(playerid, COLOUR_YELLOW, "to the test car outside.");
CreateVehicle(404, 1424.6630, -1700.2382, 13.0871, 358.1393, 0, 0, 0);
}
else
{
SendClientMessage(playerid, COLOUR_YELLOW, "Come back soon, You'll be getting find if you drive without a license.");
}
}
}
could you tell me how to fix it please
Код:
///// 24/7 NOOBSPAWN
case DIALOG_NOOB247:
{
switch(listitem)
{
if(response == 1)
{
case 0:
{
if(GetPlayerMoney(playerid) < 10) return SendClientMessage(playerid, COLOUR_YELLOW, "You cant afford this item.");
GivePlayerMoney(playerid, -10);
}
case 1:
{
if(GetPlayerMoney(playerid) < 20) return SendClientMessage(playerid, COLOUR_YELLOW, "You cant afford this item.");
GivePlayerMoney(playerid, -20);
}
case 2:
{
if(GetPlayerMoney(playerid) < 30) return SendClientMessage(playerid, COLOUR_YELLOW, "You cant afford this item.");
GivePlayerMoney(playerid, -30);
}
case 3:
{
return SendClientMessage(playerid, COLOUR_YELLOW, "You cant afford this item.");
}
}
}
This code worked before i added the give car case
Re: This piece of code gives errors and i cant understand why -
ketnui - 20.07.2011
why dont you use this?
http://https://sampforum.blast.hk/showthread.php?tid=286
Re: This piece of code gives errors and i cant understand why -
alpha500delta - 20.07.2011
Quote:
Originally Posted by ketnui
|
Did you even read this topic?
Re: This piece of code gives errors and i cant understand why -
slymatt - 20.07.2011
the link doesnt work.
Re: This piece of code gives errors and i cant understand why -
ketnui - 20.07.2011
https://sampforum.blast.hk/showthread.php?tid=286
Re: This piece of code gives errors and i cant understand why -
slymatt - 20.07.2011
thats a filterscript.
I dont want a filterscrip thats why im coding it myself. but i need a little help
Re: This piece of code gives errors and i cant understand why -
ketnui - 20.07.2011
ok sorry man though it might help give you some idea on what it should be like.
Re: This piece of code gives errors and i cant understand why -
ketnui - 20.07.2011
yeh i just messed the //http up a bit.