My script just died.
#1

Couple of people said to me; manipulate with your script, learn by yourself and so I did. Well. I got bunches of errors, if someone knows how to fix this I would be more than glad to give rep up.

Код:
CMD:fastfood(playerid, params[])
{
     new fastfood = SetPlayerCheckpoint(playerid, 2106.7183,1383.6013,10.3024,141.4535, 20)
     if(IsPlayerInCheckPoint(playerid, fastfood));
     {
	 ShowPlayerDialog(playerid, 20324, DIALOG_STYLE_LIST, "Fast-Food shop.", "Hamburger(100$)\nHotDog(150$)\nPie(200$)\nBigMomma Burger(500$)", "I'll take this one.", "No thanks.");
     }
     else
     {
     SendClientMessage(playerid, 0xAA3333AA, "You're not near Fast-Food stand!");
     }
     return 1;
}
Код:
On this script these errors are showing:
C:\Users\MARKO\Desktop\Learning\gamemodes\Tutorial.pwn(149) : warning 219: local variable "fastfood" shadows a variable at a preceding level
C:\Users\MARKO\Desktop\Learning\gamemodes\Tutorial.pwn(149) : warning 202: number of arguments does not match definition
C:\Users\MARKO\Desktop\Learning\gamemodes\Tutorial.pwn(150) : error 001: expected token: ";", but found "if"
C:\Users\MARKO\Desktop\Learning\gamemodes\Tutorial.pwn(150) : error 017: undefined symbol "IsPlayerInCheckPoint"
C:\Users\MARKO\Desktop\Learning\gamemodes\Tutorial.pwn(150) : error 036: empty statement
C:\Users\MARKO\Desktop\Learning\gamemodes\Tutorial.pwn(150) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
If you need dialog that I was using about this:
Код:
			   ShowPlayerDialog(playerid, 20324, DIALOG_STYLE_LIST, "Fast-Food shop.", "Hamburger(100$)\nHotDog(150$)\nPie(200$)\nBigMomma Burger(500$)", "I'll take this one.", "No thanks.");
            }
        }
    }
    if (dialogid == 20326 && response)
    {
	   switch(listitem)
	   {
		  case 0:
		  {
		  if(GetPlayerMoney(playerid) < 100) return SendClientMessage(playerid, 0xFF0000, "Not enough money.");
		  GivePlayerMoney(playerid, -100);
		  AddPlayerHealth(playerid, 20);
		  SendClientMessage(playerid, 0x99FFFF, "You bought Hamburger.");
		  }
		  case 1:
		  {
		  if(GetPlayerMoney(playerid) < 150) return SendClientMessage(playerid, 0xFF0000, "Not enough money.");
	      GivePlayerMoney(playerid, -150);
		  AddPlayerHealth(playerid, 40);
		  SendClientMessage(playerid, 0x99FFFF, "You bought hotdog.");
		  }
		  case 2:
		  {
		  if(GetPlayerMoney(playerid) < 200) return SendClientMessage(playerid, 0xFF0000, "Not enough money.");
		  GivePlayerMoney(playerid, -200);
		  SetPlayerHealth(playerid, 75);
		  SendClientMessage(playerid, 0x99FFFF, "You bought pie.");
		  }
		  case 3:
		  {
		  if(GetPlayerMoney(playerid) < 500) return SendClientMessage(playerid, 0xFF0000, "Not enough money.");
		  GivePlayerMoney(playerid, -500);
		  SetPlayerHealth(playerid, 100);
		  SendClientMessage(playerid, 0x99FFFF, "You bought BigMomma Burger");
		  }
      }
   }

    return 1;
}
Reply
#2

RIP

Well let's start with the first warning:
pawn Код:
warning 219: local variable "fastfood" shadows a variable at a preceding level
This error is popping up here:
pawn Код:
new fastfood = SetPlayerCheckpoint(playerid, 2106.7183,1383.6013,10.3024,141.4535, 20)
This means that you don't need to declare a new local variable new fastfood. Because it is already defined in your script as a global variable (i.e. it is defined out of a callback on top of your script).

The second error:
pawn Код:
error 001: expected token: ";", but found "if"
Prompts up here:
pawn Код:
if(IsPlayerInCheckPoint(playerid, fastfood));
You need to remove the semicolon ';'.
pawn Код:
if(IsPlayerInCheckPoint(playerid, fastfood))
And you forgot a semicolon here:
pawn Код:
SetPlayerCheckpoint(playerid, 2106.7183,1383.6013,10.3024,141.4535, 20);
Reply
#3

pawn Код:
new fastfood = SetPlayerCheckpoint(playerid, 2106.7183,1383.6013,10.3024,141.4535, 20)
if(IsPlayerInCheckPoint(playerid, fastfood));
- "fastfood" is global variable and you try to declare it locally too, just use another name.
- SetPlayerCheckpoint has 5 parameters (playerid, x, y, z, size) and you used 6 (+ angle).
- Never used semicolon at the end of an if statement.
- SetPlayerCheckpoint returns 1 if the function executed successfully and 0 if not (player isn't connected) so storing the result to a variable is pointless.

pawn Код:
SetPlayerCheckpoint(playerid, 2106.7183,1383.6013,10.3024, 20);
if(IsPlayerInCheckPoint(playerid))
Reply
#4

Код:
CMD:fastfood(playerid, params[])
{
     SetPlayerCheckpoint(playerid, 2106.7183,1383.6013,10.3024, 20);
     if(IsPlayerInCheckPoint(playerid))
     {
	 ShowPlayerDialog(playerid, 20324, DIALOG_STYLE_LIST, "Fast-Food shop.", "Hamburger(100$)\nHotDog(150$)\nPie(200$)\nBigMomma Burger(500$)", "I'll take this one.", "No thanks.");
     }
     else
     {
     SendClientMessage(playerid, 0xAA3333AA, "You're not near Fast-Food stand!");
     }
     return 1;
}
This is the "fixed" script, of which I still get these errors:

C:\Users\MARKO\Desktop\Learning\gamemodes\Tutorial .pwn(150) : error 017: undefined symbol "IsPlayerInCheckPoint"
C:\Users\MARKO\Desktop\Learning\gamemodes\Tutorial .pwn(242) : error 001: expected token: ";", but found "return"

And by the way how do I add some health to a player, because AddPlayerHealth doesn't work. I want it to be like in regular gta sa - one "hamburger" adds 25 pt. of health?

C:\Users\MARKO\Desktop\Learning\gamemodes\Tutorial .pwn(527) : error 017: undefined symbol "AddPlayerHealth"
C:\Users\MARKO\Desktop\Learning\gamemodes\Tutorial .pwn(534) : error 017: undefined symbol "AddPlayerHealth"
C:\Users\MARKO\Desktop\Learning\gamemodes\Tutorial .pwn(561) : warning 203: symbol is never used: "fastfood"
I get these as well.
Reply
#5

It is IsPlayerInCheckPoint and not IsPlayerInCheckpoint.
And before line 242 somewhere you are missing a ';'.
And AddPlayerHealth is not a function. SetPlayerHealth is.
I recommend you to go through this to learn scripting.
https://sampwiki.blast.hk/
Reply
#6

The spelling should be "IsPlayerInCheckpoint" and not "IsPlayerInCheckPoint". About the error in line 242, you need to post lines 240 to 244 and AddPlayerHealth is not defined.

pawn Код:
AddPlayerHealth(playerid, Float: health)
{
    new
        Float: curr_health;
   
    if (GetPlayerHealth(playerid, curr_health)) return SetPlayerHealth(playerid, curr_health + health);
    return 0;
}
In case you use server-side health, register it to your variables.

EDIT: Too late once again.
Reply
#7

Okay. There are no errors only one question, how can I make it ADD health not set it? I want it like a player has 10% health. and he eats hotdog and instead of having 40 health he has 50% Because HotDog adds 40% health but doesn't set player health to 40, get it?
Reply
#8

Then use Konstantinos's function of AddPlayerHealth.
Reply
#9

It gets the current health and it adds the amount you specified. Let's say the health of a player is 10.0 and you add 40.0:
pawn Код:
AddPlayerHealth(playerid, 40.0);
it sets the health to 50.0
Reply
#10

Alright. I have to correct the script. The checkpoint is WAAAAAAAAAAAYYYYYYYYY big and it says: Not near the food stand if I type /fastfood in checkpoint?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)