SA-MP Forums Archive
Help - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help (/showthread.php?tid=80408)



Help - cigo - 04.06.2009

Hi, i wanna request a script. Little info - i want script where you can buy level, for example - Level 1 for 250 000 $ and then you can use a command, like /flip or something else, but players who hasn't level 1 can't use it, and you can only buy levle 2 if you are level 1. all what i want is just one level, so i can make my own. i have searched, but never found what i need ;( . please, help i really need this!

Sorry, if i writted this in wrong topic. (in script request topic nobody answerd me) and sorry for my bad english!


Re: Help - Weirdosport - 04.06.2009

There's a script request thread for a reason...


Re: Help - cigo - 04.06.2009

sorry, if you want you can delete this topic...


Re: Help - efeX - 04.06.2009

Look, it takes a couple simple variables and a command. Here..

Код:
new gPlayerLevel[MAX_PLAYERS]; // above main()
new gPlayerMoney[MAX_PLAYERS];

public OnPlayerCommandText(playerid, cmdtext[])
{
  if (strcmp(cmd, "/buylevel", true) == 0)
  {
    gPlayerMoney[playerid] = GetPlayerMoney(playerid);
    if (GetPlayerMoney(playerid) >= 250000)
    {
      gPlayerLevel[playerid] += 1;
      SetPlayerMoney(playerid, gPlayerMoney[playerid] - 250000);
    }
    return 1;
  }
  if (strcmp(cmd, "/flip", true) == 0)
  {
    if (gPlayerLevel[playerid] > 1)
    {
      SendClientMessage(playerid, 0xFFFFFFFF, "I just... flipped?");
      return 1;
    }
    else
      return SendClientMessage(playerid, 0xFFFFFFFF, "You are not high enough level to use this!");
  }
}
Not tested, but should work.


Re: Help - Weirdosport - 04.06.2009

Why goes gPlayerMoney need to be an array?

Answer: it doesn't :P


Re: Help - cigo - 04.06.2009

thank you I will test!

EDIT: It shows some errors:

Код:
C:\Documents and Settings\Install\Desktop\HOSTS\gamemodes\xlight.pwn(1128) : error 017: undefined symbol "cmd"
C:\Documents and Settings\Install\Desktop\HOSTS\gamemodes\xlight.pwn(1138) : error 017: undefined symbol "cmd"
C:\Documents and Settings\Install\Desktop\HOSTS\gamemodes\xlight.pwn(1148) : warning 209: function "OnPlayerCommandText" should return a value
C:\Documents and Settings\Install\Desktop\HOSTS\gamemodes\xlight.pwn(1330) : warning 217: loose indentation
C:\Documents and Settings\Install\Desktop\HOSTS\gamemodes\xlight.pwn(1364) : warning 235: public function lacks forward declaration (symbol "SetupPlayerForClassSelection")
C:\Documents and Settings\Install\Desktop\HOSTS\gamemodes\xlight.pwn(1581) : warning 235: public function lacks forward declaration (symbol "GameModeExitFunc")
C:\Documents and Settings\Install\Desktop\HOSTS\gamemodes\xlight.pwn(1689) : warning 203: symbol is never used: "ret_memcpy"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
EDIT 2: I just did this:

Код:
#define cmd
#define cmd
and now i've got this:
Код:
C:\Documents and Settings\Install\Desktop\HOSTS\gamemodes\xlight.pwn(1128) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Install\Desktop\HOSTS\gamemodes\xlight.pwn(1128) : warning 215: expression has no effect
C:\Documents and Settings\Install\Desktop\HOSTS\gamemodes\xlight.pwn(1128) : warning 215: expression has no effect
C:\Documents and Settings\Install\Desktop\HOSTS\gamemodes\xlight.pwn(1128) : error 001: expected token: ";", but found ")"
C:\Documents and Settings\Install\Desktop\HOSTS\gamemodes\xlight.pwn(1128) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Install\Desktop\HOSTS\gamemodes\xlight.pwn(1128) : fatal error 107: too many error messages on one line

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


4 Errors.
any ideas?


Re: Help - samgreen - 04.06.2009

Remove those #define's. Change the strcmp(cmd to strcmp(cmdtext. That will resolve those two errors properly, and allow you to process the commands. Post the relevant code including line numbers for each warning, and we'll work on getting those resolved next.


Re: Help - efeX - 04.06.2009

You're going to get loose indentation and all that.. I typed it in a code box not in pawn.

You need to adjust the script as needed. IT was not intended to work exactly with your code. Change it as needed..


Re: Help - cigo - 04.06.2009

now my command looks like that:

Код:
	public OnPlayerCommandText(playerid, cmdtext[])
	{
	if (strcmp(cmdtext"/buylevel", true) == 0;
	{
    gPlayerMoney[playerid] = GetPlayerMoney(playerid);
    if (GetPlayerMoney(playerid) >= 250000)
    {
      gPlayerLevel[playerid] += 1;
      SetPlayerMoney(playerid, gPlayerMoney[playerid] - 250000);
    }
    return 1;
  }
  if (strcmp(cmdtext"/flip", true) == 0)
  {
    if (gPlayerLevel[playerid] > 1)
    {
      SendClientMessage(playerid, 0xFFFFFFFF, "I just... flipped?");
      return 1;
    }
    else
      return SendClientMessage(playerid, 0xFFFFFFFF, "You are not high enough level to use this!");
  }
}
but i still got errors:

Код:
C:\Documents and Settings\Install\Desktop\HOSTS\gamemodes\xlight.pwn(1127) : error 001: expected token: ",", but found "-string-"
C:\Documents and Settings\Install\Desktop\HOSTS\gamemodes\xlight.pwn(1127) : warning 215: expression has no effect
C:\Documents and Settings\Install\Desktop\HOSTS\gamemodes\xlight.pwn(1127) : warning 215: expression has no effect
C:\Documents and Settings\Install\Desktop\HOSTS\gamemodes\xlight.pwn(1127) : error 001: expected token: ";", but found ")"
C:\Documents and Settings\Install\Desktop\HOSTS\gamemodes\xlight.pwn(1127) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Install\Desktop\HOSTS\gamemodes\xlight.pwn(1127) : fatal error 107: too many error messages on one line

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


4 Errors.
all warnings and errors are on this line:

Код:
if (strcmp(cmdtext"/buylevel", true) == 0;
If it's important - my gm is made from sftdm!




Re: Help - HuRRiCaNe - 04.06.2009


pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
    {
    if (strcmp(cmd, "/buylevel", true) == 0)
    {
    gPlayerMoney[playerid] = GetPlayerMoney(playerid);
    if (GetPlayerMoney(playerid) >= 250000)
    {
     gPlayerLevel[playerid] += 1;
     SetPlayerMoney(playerid, gPlayerMoney[playerid] - 250000);
    }
    return 1;
  }
  if (strcmp(cmdtext"/flip", true) == 0)
  {
    if (gPlayerLevel[playerid] > 1)
    {
      SendClientMessage(playerid, 0xFFFFFFFF, "I just... flipped?");
      return 1;
    }
    else
      return SendClientMessage(playerid, 0xFFFFFFFF, "You are not high enough level to use this!");
  }
}
Put like this