Scripting help.
#1

I get a warning with this code. Let me show you.
pawn Код:
{
  if (strcmp("/heal", cmdtext, true) == 0)
  {
  GetPlayerMoney (playerid);
  if(GetPlayerMoney(playerid) < 300)
{
  SendClientMessage(playerid,YELLOW,"[ERROR]: Not enough money!! This costs $300!");
}
else
{
  SendClientMessage(playerid,YELLOW,"[PLAYER]: Healed for $300!");
  SetPlayerHealth(playerid, 100);
  GivePlayerMoney (playerid, -300);
}
    return 1;
}
{
  if (strcmp("/armour", cmdtext, true) == 0)
{
  GetPlayerMoney (playerid);
  if(GetPlayerMoney(playerid) < 300)
{
  SendClientMessage(playerid,YELLOW,"[ERROR]: Not enough money!!");
}
  else
{
  SendClientMessage(playerid,YELLOW,"[PLAYER]: Armour given for $300!");
  SetPlayerArmour(playerid, 100);
   GivePlayerMoney (playerid, -300);
}
    return 1;
  }
  return 0;
}
This: (right under the code above) cannot be reached...
pawn Код:
if (strcmp("/help", cmdtext, true) == 0)
  {
    SendClientMessage(playerid,YELLOW,"________________________________________________________________________________________");
    SendClientMessage(playerid,YELLOW,"[HELP]: Hello, and welcome to Ultimate Freeroam. This uses a custom script by [UF]Jesco");
    SendClientMessage(playerid,YELLOW,"and was created specifically for his first server; Ultimate Freeroam.");
    SendClientMessage(playerid,YELLOW,"You can use the command: [/commands] to get a list of commands!");
    SendClientMessage(playerid,YELLOW,"________________________________________________________________________________________");
    return 1;
}

  if (strcmp("/commands", cmdtext, true) == 0)
  {
    SendClientMessage(playerid,YELLOW,"[COMMANDLIST]: /heal; /armour; /register; /login; /admins; /changelog; /report ");
    return 1;
  }
  if (strcmp("/changelog", cmdtext, true) == 0)
  {
    SendClientMessage(playerid,YELLOW,"___________________________________________");
    SendClientMessage(playerid,YELLOW,"Ultimate Freeroam Script Changelog:");
    SendClientMessage(playerid,YELLOW,"< Added a /heal and /armour command. >");
    SendClientMessage(playerid,YELLOW,"< Added admin and login/register system. >");
    SendClientMessage(playerid,YELLOW,"< Added new spawn position. >");
    SendClientMessage(playerid,YELLOW,"____________________________________________");
    return 1;
  }
return 0;
}
Error Code in the Compiler:
Код:
C:\Program Files\Rockstar Games\Roleplay server 0.223\gamemodes\UltimateFreeroambeta.pwn(65) : warning 202: number of arguments does not match definition
C:\Program Files\Rockstar Games\Roleplay server 0.223\gamemodes\UltimateFreeroambeta.pwn(65) : warning 202: number of arguments does not match definition
C:\Program Files\Rockstar Games\Roleplay server 0.223\gamemodes\UltimateFreeroambeta.pwn(65) : warning 202: number of arguments does not match definition
C:\Program Files\Rockstar Games\Roleplay server 0.223\gamemodes\UltimateFreeroambeta.pwn(90) : warning 217: loose indentation
C:\Program Files\Rockstar Games\Roleplay server 0.223\gamemodes\UltimateFreeroambeta.pwn(103) : warning 202: number of arguments does not match definition
C:\Program Files\Rockstar Games\Roleplay server 0.223\gamemodes\UltimateFreeroambeta.pwn(104) : warning 217: loose indentation
C:\Program Files\Rockstar Games\Roleplay server 0.223\gamemodes\UltimateFreeroambeta.pwn(111) : warning 217: loose indentation
C:\Program Files\Rockstar Games\Roleplay server 0.223\gamemodes\UltimateFreeroambeta.pwn(136) : warning 217: loose indentation
C:\Program Files\Rockstar Games\Roleplay server 0.223\gamemodes\UltimateFreeroambeta.pwn(139) : error 029: invalid expression, assumed zero
C:\Program Files\Rockstar Games\Roleplay server 0.223\gamemodes\UltimateFreeroambeta.pwn(144) : warning 217: loose indentation
C:\Program Files\Rockstar Games\Roleplay server 0.223\gamemodes\UltimateFreeroambeta.pwn(146) : warning 217: loose indentation
C:\Program Files\Rockstar Games\Roleplay server 0.223\gamemodes\UltimateFreeroambeta.pwn(158) : warning 217: loose indentation
C:\Program Files\Rockstar Games\Roleplay server 0.223\gamemodes\UltimateFreeroambeta.pwn(160) : warning 217: loose indentation
C:\Program Files\Rockstar Games\Roleplay server 0.223\gamemodes\UltimateFreeroambeta.pwn(164) : warning 225: unreachable code
C:\Program Files\Rockstar Games\Roleplay server 0.223\gamemodes\UltimateFreeroambeta.pwn(164) : warning 217: loose indentation
C:\Program Files\Rockstar Games\Roleplay server 0.223\gamemodes\UltimateFreeroambeta.pwn(189) : warning 217: loose indentation
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Quite new to scripting gamemodes.
Help me correct this problem?
Thanks.

~Justin
Reply
#2

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/heal", cmdtext, true) == 0)
    {
        if(GetPlayerMoney(playerid) < 300)
        {
            SendClientMessage(playerid,YELLOW,"[ERROR]: Not enough money!! This costs $300!");
            return 1;
        }
        else
        {
            SendClientMessage(playerid,YELLOW,"[PLAYER]: Healed for $300!");
            SetPlayerHealth(playerid, 100);
            GivePlayerMoney (playerid, -300);
            return 1;
        }
    }
    if (strcmp("/armour", cmdtext, true) == 0)
    {
        if(GetPlayerMoney(playerid) < 300)
        {
            SendClientMessage(playerid,YELLOW,"[ERROR]: Not enough money!!");
            return 1;
        }
        else
        {
            SendClientMessage(playerid,YELLOW,"[PLAYER]: Armour given for $300!");
            SetPlayerArmour(playerid, 100);
            GivePlayerMoney (playerid, -300);
            return 1;
        }
    }
    if (strcmp("/help", cmdtext, true) == 0)
    {
        SendClientMessage(playerid,YELLOW,"________________________________________________________________________________________");
        SendClientMessage(playerid,YELLOW,"[HELP]: Hello, and welcome to Ultimate Freeroam. This uses a custom script by [UF]Jesco");
        SendClientMessage(playerid,YELLOW,"and was created specifically for his first server; Ultimate Freeroam.");
        SendClientMessage(playerid,YELLOW,"You can use the command: [/commands] to get a list of commands!");
        SendClientMessage(playerid,YELLOW,"________________________________________________________________________________________");
        return 1;
    }
    if (strcmp("/commands", cmdtext, true) == 0)
    {
        SendClientMessage(playerid,YELLOW,"[COMMANDLIST]: /heal; /armour; /register; /login; /admins; /changelog; /report ");
        return 1;
    }
    if (strcmp("/changelog", cmdtext, true) == 0)
    {
        SendClientMessage(playerid,YELLOW,"___________________________________________");
        SendClientMessage(playerid,YELLOW,"Ultimate Freeroam Script Changelog:");
        SendClientMessage(playerid,YELLOW,"< Added a /heal and /armour command. >");
        SendClientMessage(playerid,YELLOW,"< Added admin and login/register system. >");
        SendClientMessage(playerid,YELLOW,"< Added new spawn position. >");
        SendClientMessage(playerid,YELLOW,"____________________________________________");
        return 1;
    }
    return 0;
}
The thing to note is where where i return 1. Compare that to yours and you should see the problem. Also mine is a little more efficient.
Reply
#3

LoL, your indentation is really fkd. Lol
Reply
#4

Thanks. Fixed. @Mean And yeah, if you'd read my post, I said I'm new to scripting. Some people have dirty secrets to how they get such a postcount.......
Reply
#5

But btw read this... It will help you scripting cleanup!

https://sampforum.blast.hk/showthread.php?tid=199560
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)