help me ... ! - 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: help me ... ! (
/showthread.php?tid=510406)
help me ... ! -
jardysmith0316 - 01.05.2014
error.
Код:
forward DoiBung();
public DoiBung()
{
//for(new i = 0; i < MAX_PLAYERS; i++)
foreach(new i: Player)
{
if(HelpingNewbie[i] != INVALID_PLAYER_ID || PlayerInfo[i][pJailTime] > 0 || GetPlayerState(i) == PLAYER_STATE_SPECTATING || (GetPVarType(i, "pGodMode")) || (GetPVarType(i, "EventToken") != 0)
{ //error
}
else {
switch (PlayerInfo[i][pDoibung]) {
case 0: {
if(IsPlayerConnected(i)) {
new Float:mau;
if(TutStep[i] == 0) {
PlayerInfo[i][pDoibung]--;
GetPlayerHealth(i, mau);
SetPlayerDrunkLevel(i, 0);
SetPlayerHealth(i, mau - 5.0);
SendClientMessageEx(i, COLOR_LIGHTBLUE, "* Danh mat 5 suc khoe do doi bung");
}
}
case 1 .. 19: { //error
if(PlayerInfo[i][pDoibung] >= 85) {
PlayerTextDrawSetString(i, Trangthai[1], "~g~Rat No");
return 1;
}
}
case 20 .. 39: {
if(PlayerInfo[i][pDoibung] >= 50 && PlayerInfo[i][pDoibung] < 85) {
PlayerTextDrawSetString(i, Trangthai[1], "~g~No Bung");
return 1;
}
}
case 40 .. 79: {
if(PlayerInfo[i][pDoibung] >= 25 && PlayerInfo[i][pDoibung] < 50) {
GetPlayerHealth(i, mau);
SetPlayerHealth(i, mau - 10.0);
SetPlayerDrunkLevel(i, 50000);
SendClientMessageEx(i, COLOR_LIGHTRED, "Ban dang cam thay doi bung, tay chan ra roi.");
PlayerInfo[i][pDoibung]--;
PlayerTextDrawSetString(i, Trangthai[1], "~y~Doi Bung");
return 1;
}
}
case 80 .. 100: {
if(PlayerInfo[i][pDoibung] < 25 && PlayerInfo[i][pDoibung] != 0){
SendClientMessageEx(i, COLOR_LIGHTRED, "Ban dang bi mat suc qua nhieu! Hay den cac cua hang an trong thanh pho de lay lai suc khoe.");
PlayerTextDrawSetString(i, Trangthai[1], "~r~Rat Doi");
}
}
default: {
PlayerInfo[i][pDoibung] = 100;
}
if(PlayerInfo[i][pDoibung] == 0){
SetPlayerInHospital(i);
}
}
}
}
}
return 1;
}
Код:
: error 029: invalid expression, assumed zero
: error 014: invalid statement; not in switch
: warning 215: expression has no effect
: error 001: expected token: ";", but found ".."
: error 029: invalid expression, assumed zero
: fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
5 Errors.
Respuesta: help me ... ! -
Swedky - 01.05.2014
pawn Код:
forward DoiBung();
public DoiBung()
{
foreach(new i: Player)
{
if(HelpingNewbie[i] != INVALID_PLAYER_ID || PlayerInfo[i][pJailTime] > 0 || GetPlayerState(i) == PLAYER_STATE_SPECTATING || (GetPVarType(i, "pGodMode") == 1) || (GetPVarType(i, "EventToken") != 0)
{
return 1; // Stop the script.
}
else
{
switch(PlayerInfo[i][pDoibung])
{
case 0:
{
//if(IsPlayerConnected(i)) // This is not necessary (foreach only works with the connected ID's)
//{
new Float:mau;
if(TutStep[i] == 0)
{
PlayerInfo[i][pDoibung]--;
GetPlayerHealth(i, mau);
SetPlayerDrunkLevel(i, 0);
SetPlayerHealth(i, mau - 5.0);
SendClientMessageEx(i, COLOR_LIGHTBLUE, "* Danh mat 5 suc khoe do doi bung");
}
}
case 1 .. 19:
{
if(PlayerInfo[i][pDoibung] >= 85)
{
PlayerTextDrawSetString(i, Trangthai[1], "~g~Rat No");
}
}
case 20 .. 39:
{
if(PlayerInfo[i][pDoibung] >= 50 && PlayerInfo[i][pDoibung] < 85)
{
PlayerTextDrawSetString(i, Trangthai[1], "~g~No Bung");
}
}
case 40 .. 79:
{
if(PlayerInfo[i][pDoibung] >= 25 && PlayerInfo[i][pDoibung] < 50)
{
GetPlayerHealth(i, mau);
SetPlayerHealth(i, mau - 10.0);
SetPlayerDrunkLevel(i, 50000);
SendClientMessageEx(i, COLOR_LIGHTRED, "Ban dang cam thay doi bung, tay chan ra roi.");
PlayerInfo[i][pDoibung]--;
PlayerTextDrawSetString(i, Trangthai[1], "~y~Doi Bung");
}
}
case 80 .. 100:
{
if(PlayerInfo[i][pDoibung] < 25 && PlayerInfo[i][pDoibung] != 0)
{
SendClientMessageEx(i, COLOR_LIGHTRED, "Ban dang bi mat suc qua nhieu! Hay den cac cua hang an trong thanh pho de lay lai suc khoe.");
PlayerTextDrawSetString(i, Trangthai[1], "~r~Rat Doi");
}
}
default:
{
PlayerInfo[i][pDoibung] = 100;
}
/*
if(PlayerInfo[i][pDoibung] == 0) // Here you should continue using the expression ' case - default '.
{
SetPlayerInHospital(i);
}
*/
}
if(PlayerInfo[i][pDoibung] == 0)
{
SetPlayerInHospital(i);
}
//}
//}
}
}
return 1;
}
See the code and it will realize his mistakes.