[Help] Working on bag script, like a seperate inventory.
#1

The idea is this;

For someone to be able to store mats, and drugs away into a bag. Also be able to store weapons.
Using some of the built in commands from my Gamemode, I was able to build something that I think could work when placed into it.
(due to functions etc.)
I would just like for someone with a little more skill, to help me enhance this to the most of his/her ability.

Thank you.

Код:
new gotbag[MAX_PLAYERS];

enum bag
{
	bDrugs
	bMats
}

public OnPlayerCommandText(playerid, cmdtext[]) {
	if (strcmp("/buybag", cmdtext, true, 5) == 0) {
		if(gotbag[playerid] == 0)
		{
			GivePlayerCash(playerid, -100);
			SendClientMessage(playerid, COLOR_BLUE, "You have purchased a bag.");
			SendClientMessage(playerid, COLOR_BLUE, " Use /baghelp ");
			gotbag = 1;
		}
		return 1;
	}
	if (strcmp("/baghelp", cmdtext, true, 5) == 0) {
	{
			if(gotbag[playerid] == 1)
			{
				SendClientMessage(playerid, COLOR_GREEN, " You can use this bag to store things.");
				SendClientMessage(playerid, COLOR_GREEN, " /bputdrugs || /btakedrugs || /bputmats || /btakemats || /bputgun || /btakegun ");
			}
			else
			{
				SendClientMessage(playerid, COLOR_GREEN, " You don't have a bag, buy one /buybag ");
			}
			return 1;
	if (strcmp("/bputdrugs", cmdtext, true, 5) == 0) {
	{
			if(gotbag[playerid] == 1);
			new drugbag = strval(tmp);
			if(!strlen(tmp));
			{
				PlayerInfo[playerid][pDrugs] -= drugbag;
				PlayerInfo[playerid][bDrugs] += drugbag;
				PlayerActionMessage(playerid,15.0,"unzips his bag and places a package into it.");
				PlayerActionMessage(playerid,15.0,"zips his bag back up.");
				return 1;
			{
	if (strcmp("/btakedrugs", cmdtext, true, 5) == 0) {
	{
			if(gotbag[playerid] == 1);
			new drugbag = strval(tmp);
			if(!strlen(tmp));
			{
				PlayerInfo[playerid][pDrugs] += drugbag;
				PlayerInfo[playerid][bDrugs] -= drugbag;
				PlayerActionMessage(playerid,15.0,"unzips his bag and takes a package out of it.");
				PlayerActionMessage(playerid,15.0,"zips his bag back up.");
				return 1;
			{
	if (strcmp("/bputmats", cmdtext, true, 5) == 0) {
	{
			if(gotbag[playerid] == 1);
			new drugbag = strval(tmp);
			if(!strlen(tmp));
			{
				PlayerInfo[playerid][pMats] -= drugbag;
				PlayerInfo[playerid][bMats] += drugbag;
				PlayerActionMessage(playerid,15.0,"unzips his bag and places a package into it.");
				PlayerActionMessage(playerid,15.0,"zips his bag back up.");
				return 1;
			{
	if (strcmp("/btakemats", cmdtext, true, 5) == 0) {
	{
			if(gotbag[playerid] == 1);
			new drugbag = strval(tmp);
			if(!strlen(tmp));
			{
				PlayerInfo[playerid][pDrugs] += drugbag;
				PlayerInfo[playerid][bDrugs] -= drugbag;
				PlayerActionMessage(playerid,15.0,"unzips his bag and takes a package out of it.");
				PlayerActionMessage(playerid,15.0,"zips his bag back up.");
				return 1;
			}
		}
	}
	return 0;
}
Some errors I get on compile (most will be fixed when I move it into the GM)

Код:
[12:28:45 AM] Compile failed. Errors: 10 Warnings: 3
-------- Compile details: --------
* Setting directory: C:\Documents and Settings\HP_Administrator\Desktop
* Executing: C:\Documents and Settings\HP_Administrator\Desktop\samp02Xserver.win32\pawno\pawncc.exe "C:\Documents and Settings\HP_Administrator\Desktop\Bag.pwn" -;+ -(+ -v2
-------- Output: --------
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


11 Errors.

-------- Errors: --------
C:\Documents and Settings\HP_Administrator\Desktop\Bag.pwn(11) : error 001: expected token: "}", but found "-identifier-"
C:\Documents and Settings\HP_Administrator\Desktop\Bag.pwn(28) : error 017: undefined symbol "GivePlayerCash"
C:\Documents and Settings\HP_Administrator\Desktop\Bag.pwn(31) : error 033: array must be indexed (variable "gotbag")
C:\Documents and Settings\HP_Administrator\Desktop\Bag.pwn(47) : warning 225: unreachable code
C:\Documents and Settings\HP_Administrator\Desktop\Bag.pwn(47) : warning 217: loose indentation
C:\Documents and Settings\HP_Administrator\Desktop\Bag.pwn(49) : error 036: empty statement
C:\Documents and Settings\HP_Administrator\Desktop\Bag.pwn(50) : error 017: undefined symbol "tmp"
C:\Documents and Settings\HP_Administrator\Desktop\Bag.pwn(51) : error 017: undefined symbol "tmp"
C:\Documents and Settings\HP_Administrator\Desktop\Bag.pwn(51) : error 036: empty statement
C:\Documents and Settings\HP_Administrator\Desktop\Bag.pwn(53) : error 017: undefined symbol "PlayerInfo"
C:\Documents and Settings\HP_Administrator\Desktop\Bag.pwn(53) : warning 215: expression has no effect
C:\Documents and Settings\HP_Administrator\Desktop\Bag.pwn(53) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\HP_Administrator\Desktop\Bag.pwn(53) : error 029: invalid expression, assumed zero
C:\Documents and Settings\HP_Administrator\Desktop\Bag.pwn(53) : fatal error 107: too many error messages on one line

Compilation aborted.
I left some of the useless things out like definitions for colors etc.

Also I am using a modified version of Carlito's role-play.
Reply
#2

The brackets are not correct.
Reply
#3

A crap load of it is wrong not just brackets, semicolons on the end of statements, arrays with no index, '5' in all the strcmp lengths so only five characters will be compared, unused enums and variables which don't seem to be declared unless he is using 'strtok' and has only showed snippets of code in which case he needs to get rid of strtok and goto DCMD (or index cmdtext) because using strtok for commands with no or single parameters is a seriously crap way of going about it.

Yes there is more but that's something to chew on for now dude.

Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)