PDA

View Full Version : error 029: Invalid Expression, Assumed Zero!


BlackLineCnR
23/09/2017, 01:56 PM
I made a command to buy vip for cookies,
here is the code:-

Code:
COMMAND:cbuyvip(playerid, params[])
{
if(playerData[playerid][playerLoggedIn])
{
if(playerData[playerid][cookies] >=500)
{
new
message2[128]
;

else
{
playerData[playerid][cookies] = playerData[playerid][cookies] -500;
playerData[playerid][playerVIPLevel] = 1;
playerData[playerid][vipExpires] = gettime() + 2592000;
playerGiveMoney(playerid, 500000);
playerGiveXP(playerid, 500);

format(message2, sizeof(message2), "{B7B7B7}[INFO] {FFFFFF}You have bought Standard VIP");
SendClientMessage(playerid, COLOR_WHITE, message2);

disableAchieve(playerid);
PlayerTextDrawShow(playerid, playerData[playerid][Achieve1]);
PlayerTextDrawShow(playerid, playerData[playerid][Achieve2]);
PlayerTextDrawShow(playerid, playerData[playerid][Achieve3]);
PlayerTextDrawShow(playerid, playerData[playerid][Achieve4]);

PlayerTextDrawSetString(playerid, playerData[playerid][Achieve3], "You're VIP!");
PlayerTextDrawSetString(playerid, playerData[playerid][Achieve4], "You are now a VIP member, nice!");
PlayerPlaySound(playerid, 1185 ,0.0, 0.0, 0.0);

playerData[playerid][achieveTimer] = SetTimerEx("disableAchieve", 6000, false, "i", playerid);

playerGiveXP(playerid, 25);
playerData[playerid][playerScore] = playerData[playerid][playerScore] + 2;
SetPlayerScore(playerid, playerData[playerid][playerScore]);
}
}
}
return 1;
}

But it is giving error on this line:-

Code:-
else

Plz anyone help, +rep if suceed :D

Zedder
23/09/2017, 02:01 PM
COMMAND:cbuyvip(playerid, params[])
{
if(playerData[playerid][playerLoggedIn])
{
if(playerData[playerid][cookies] >=500)
{



new
message2[128];


playerData[playerid][cookies] = playerData[playerid][cookies] -500;
playerData[playerid][playerVIPLevel] = 1;
playerData[playerid][vipExpires] = gettime() + 2592000;
playerGiveMoney(playerid, 500000);
playerGiveXP(playerid, 500);

format(message2, sizeof(message2), "{B7B7B7}[INFO] {FFFFFF}You have bought Standard VIP");
SendClientMessage(playerid, COLOR_WHITE, message2);

disableAchieve(playerid);
PlayerTextDrawShow(playerid, playerData[playerid][Achieve1]);
PlayerTextDrawShow(playerid, playerData[playerid][Achieve2]);
PlayerTextDrawShow(playerid, playerData[playerid][Achieve3]);
PlayerTextDrawShow(playerid, playerData[playerid][Achieve4]);

PlayerTextDrawSetString(playerid, playerData[playerid][Achieve3], "You're VIP!");
PlayerTextDrawSetString(playerid, playerData[playerid][Achieve4], "You are now a VIP member, nice!");
PlayerPlaySound(playerid, 1185 ,0.0, 0.0, 0.0);

playerData[playerid][achieveTimer] = SetTimerEx("disableAchieve", 6000, false, "i", playerid);

playerGiveXP(playerid, 25);
playerData[playerid][playerScore] = playerData[playerid][playerScore] + 2;
SetPlayerScore(playerid, playerData[playerid][playerScore]);
}
else SendClientMessage(playerid, -1, "You need to have more than 500 cookies to buy VIP");
}
else SendClientMessage(playerid, -1, "You are not logged in yet to use any commands");
}
return 1;
}
Sorry if the code looks messed up, because its edited in Vbulletin Editor xD.

MEW273
23/09/2017, 02:01 PM
Remove that line. Why do you have an 'else' statement with no corresponding 'if' statement?

BlackLineCnR
23/09/2017, 02:10 PM
COMMAND:cbuyvip(playerid, params[])
{
if(playerData[playerid][playerLoggedIn])
{
if(playerData[playerid][cookies] >=500)
{



new
message2[128];


playerData[playerid][cookies] = playerData[playerid][cookies] -500;
playerData[playerid][playerVIPLevel] = 1;
playerData[playerid][vipExpires] = gettime() + 2592000;
playerGiveMoney(playerid, 500000);
playerGiveXP(playerid, 500);

format(message2, sizeof(message2), "{B7B7B7}[INFO] {FFFFFF}You have bought Standard VIP");
SendClientMessage(playerid, COLOR_WHITE, message2);

disableAchieve(playerid);
PlayerTextDrawShow(playerid, playerData[playerid][Achieve1]);
PlayerTextDrawShow(playerid, playerData[playerid][Achieve2]);
PlayerTextDrawShow(playerid, playerData[playerid][Achieve3]);
PlayerTextDrawShow(playerid, playerData[playerid][Achieve4]);

PlayerTextDrawSetString(playerid, playerData[playerid][Achieve3], "You're VIP!");
PlayerTextDrawSetString(playerid, playerData[playerid][Achieve4], "You are now a VIP member, nice!");
PlayerPlaySound(playerid, 1185 ,0.0, 0.0, 0.0);

playerData[playerid][achieveTimer] = SetTimerEx("disableAchieve", 6000, false, "i", playerid);

playerGiveXP(playerid, 25);
playerData[playerid][playerScore] = playerData[playerid][playerScore] + 2;
SetPlayerScore(playerid, playerData[playerid][playerScore]);
}
else SendClientMessage(playerid, -1, "You need to have more than 500 cookies to buy VIP");
}
else SendClientMessage(playerid, -1, "You are not logged in yet to use any commands");
}
return 1;
}
Sorry if the code looks messed up, because its edited in Vbulletin Editor xD.

Yeah, Worked But Error Jumped To The Second Last Line, Return 1;

Zedder
23/09/2017, 02:13 PM
COMMAND:cbuyvip(playerid, params[])
{
if(!playerData[playerid][playerLoggedIn]) return SendClientMessage(playerid, -1, "You are not logged in yet to use any commands");

if(playerData[playerid][cookies] < 500) return SendClientMessage(playerid, -1, "You need to have more than 500 cookies to buy VIP");

new
message2[128];


playerData[playerid][cookies] = playerData[playerid][cookies] -500;
playerData[playerid][playerVIPLevel] = 1;
playerData[playerid][vipExpires] = gettime() + 2592000;
playerGiveMoney(playerid, 500000);
playerGiveXP(playerid, 500);

format(message2, sizeof(message2), "{B7B7B7}[INFO] {FFFFFF}You have bought Standard VIP");
SendClientMessage(playerid, COLOR_WHITE, message2);

disableAchieve(playerid);
PlayerTextDrawShow(playerid, playerData[playerid][Achieve1]);
PlayerTextDrawShow(playerid, playerData[playerid][Achieve2]);
PlayerTextDrawShow(playerid, playerData[playerid][Achieve3]);
PlayerTextDrawShow(playerid, playerData[playerid][Achieve4]);

PlayerTextDrawSetString(playerid, playerData[playerid][Achieve3], "You're VIP!");
PlayerTextDrawSetString(playerid, playerData[playerid][Achieve4], "You are now a VIP member, nice!");
PlayerPlaySound(playerid, 1185 ,0.0, 0.0, 0.0);

playerData[playerid][achieveTimer] = SetTimerEx("disableAchieve", 6000, false, "i", playerid);

playerGiveXP(playerid, 25);
playerData[playerid][playerScore] = playerData[playerid][playerScore] + 2;
SetPlayerScore(playerid, playerData[playerid][playerScore]);

return 1;
}
Try now! this is my way of doing it!

BlackLineCnR
23/09/2017, 02:21 PM
Zeddar Thnx Man, It Worked!!! :D
+Reped!