Several Classes(REP+)
#1

Hey guys,

I've just been trying to add a new class to my server. (Pilot) Over trucking, but i came across a few errors.

I'm going to paste my whole mission FS in here, so you can understand the code thoroughly(I guess),
And any help would be appreciated!
Thanks for your time!

Код:
#include <a_samp>
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

#define COLOR_ORANGE 0xF5A300FF
#define COLOR_LIMEGREEN 0x32CD32FF
#define COLOR_ROYALBLUE 0x4169E1FF
#define COLOR_SALMON 0xFA8072FF
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x00DE28FF
#define COLOR_RED 0xFF0000FF
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_LIGHTBLUE 0x33CCFFAA

enum MisLocationsEnum
{
	ID,
	LoadName[128],
	Float:LoadX,
	Float:LoadY,
	Float:LoadZ,
	Float:UnloadX,
	Float:UnloadY,
	Float:UnloadZ,
	Pay
}
new MisLocations[][MisLocationsEnum] =

{
	{0, "Beer from Red County Brewery to Bone County Diner",-24.4073,-281.8898,5.9985,-305.4319,1315.6797,54.6189, 15980},
	{1, "Fuel from LV Oil Refinery to LV Dirtring",266.8981,1416.5417,10.2001,1097.5164,1741.7422,10.5474, 15700},
	{2, "Plane Parts from SF Airport ATC to Wang Cars",-1268.8223,13.6925,14.8682,-1986.3477,253.9728,35.8985, 12642},
	{3, "Fuel from SF Oil Refinery to RS Haul",-1016.3634,-688.2434,32.7284,-55.3397,-1138.2479,0.8052, 18770},
	{4, "Stationary from LS Depot to Verdant Meadows Airstrip",2214.9072,-2221.1094,13.5469,415.9888,2523.2358,16.4844, 11324},
	{5, "Car Parts from LS Coutt and Shutz to Wang Autos",2131.8630,-1136.8284,25.6143,-1996.0587,273.7694,32.8254, 13245}
};
new PMisLocations[][MisLocationsEnum] =

{
	{0, "Car Parts from LS Coutt and Shutz to Wang Autos",2131.8630,-1136.8284,25.6143,-1996.0587,273.7694,32.8254, 13245}//Just as a test mission, to see if it works.
};

//Classes
#define TEAM_TRUCKER 1
#define TEAM_PILOT 	 2
new     iMissionText[512][MAX_PLAYERS], Float:unx[MAX_PLAYERS], Float:uny[MAX_PLAYERS], Float:unz[MAX_PLAYERS], iPay[MAX_PLAYERS], MissionStatus[MAX_PLAYERS];

main()
{
}
public OnGameModeInit()
{
	return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
	switch (classid)
	{
		case 0:
		{
		    ShowPlayerDialog(playerid, 0, DIALOG_STYLE_LIST, "Choose A Class:", "Trucker -		0 score\nPilot -		20 score", "Choose","");
		}
	}
	return 1;
}
public OnPlayerSpawn(playerid)
{
	return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
	dcmd(work, 4, cmdtext);
	dcmd(stopwork, 8, cmdtext);
	return 0;
}
dcmd_work(playerid, params[])
{
	#pragma unused params
	if(GetPlayerTeam(playerid) == TEAM_TRUCKER) return T_NewJob(playerid);
	if(GetPlayerTeam(playerid) == TEAM_PILOT) return P_NewJob(playerid);
	return 1;

}
dcmd_stopwork(playerid, params[])
{
	#pragma unused params
	if(GetPlayerTeam(playerid) == TEAM_TRUCKER) return StopWork(playerid);
	if(GetPlayerTeam(playerid) == TEAM_PILOT) return StopWork(playerid);
	return 1;
}
stock T_NewJob(playerid)
{
	new vID = GetPlayerVehicleID(playerid);
	if(GetVehicleModel(vID)== 403 || GetVehicleModel(vID)== 515 || GetVehicleModel(vID) == 514)
	{
		if(IsTrailerAttachedToVehicle(vID))
		{
			MissionStatus[playerid] = 1;
			new MisRand = random(sizeof(MisLocations));
			new LoadText[128], Float:x, Float:y, Float:z;
			x = MisLocations[MisRand][LoadX];
			y = MisLocations[MisRand][LoadY];
			z = MisLocations[MisRand][LoadZ];
			unx[playerid] = MisLocations[MisRand][UnloadX];
			uny[playerid] = MisLocations[MisRand][UnloadY];
			unz[playerid] = MisLocations[MisRand][UnloadZ];
			iPay[playerid] = MisLocations[MisRand][Pay];
			SetPlayerCheckpoint(playerid, x, y, z, 7);
			format(LoadText, 128, "%s",MisLocations[MisRand][LoadName]);
			SendClientMessage(playerid, COLOR_GREEN, "Mission:");
			SendClientMessage(playerid, COLOR_GREEN, "");
			SendClientMessage(playerid, 0xFFFFFFFF, LoadText);
		}
		else
		{
			SendClientMessage(playerid, COLOR_RED, "ERROR:You need a trailer to work!");
		}
	}
	else
	{
		SendClientMessage(playerid, COLOR_RED, "ERROR: You must be in a Truck to work!");
	}
	return 1;
}
stock P_NewJob(playerid)//Pilot New Job
{
	new vID = GetPlayerVehicleID(playerid);
	if(GetVehicleModel(vID)== 519 ||)
	{
		MissionStatus[playerid] = 1;
		new MisRand = random(sizeof(MisLocations));
		new LoadText[128], Float:x, Float:y, Float:z;
		x = PMisLocations[MisRand][LoadX];
		y = PMisLocations[MisRand][LoadY];
		z = PMisLocations[MisRand][LoadZ];
		unx[playerid] = PMisLocations[MisRand][UnloadX];
		uny[playerid] = PMisLocations[MisRand][UnloadY];
		unz[playerid] = PMisLocations[MisRand][UnloadZ];
		iPay[playerid] = PMisLocations[MisRand][Pay];
		SetPlayerCheckpoint(playerid, x, y, z, 7);
		format(LoadText, 128, "%s",pMisLocations[MisRand][LoadName]);
		SendClientMessage(playerid, COLOR_GREEN, "Mission:");
		SendClientMessage(playerid, COLOR_GREEN, "");
		SendClientMessage(playerid, 0xFFFFFFFF, LoadText);
		}
	}
	else
	{
		SendClientMessage(playerid, COLOR_RED, "ERROR:You must be in a plane to work!");
	}
	return 1;
}

stock StopWork(playerid)
{
	DisablePlayerCheckpoint(playerid);
	SendClientMessage(playerid, COLOR_RED, "MISSION:You chose to cancel the mission and got fined $4500");
	GivePlayerMoney(playerid, -4500);
	MissionStatus[playerid] = 0;
	return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
	CheckpointEntered(playerid);
	return 1;
}
stock CheckpointEntered(playerid)
{
	new gString[128];
	new vID = GetPlayerVehicleID(playerid);
	if(!IsTrailerAttachedToVehicle(vID)) return SendClientMessage(playerid, COLOR_RED, "ERROR:You need a trailer to unload!");
	if(MissionStatus[playerid] == 1)
	{
		DisablePlayerCheckpoint(playerid);
		SetPlayerCheckpoint(playerid, unx[playerid], uny[playerid], unz[playerid], 7);
		SendClientMessage(playerid, COLOR_ORANGE, "MISSION:Loaded. Please proceed to your destination.");
		MissionStatus[playerid] = 2;
	}
	else if(MissionStatus[playerid] == 2)
	{
		DisablePlayerCheckpoint(playerid);
		GivePlayerMoney(playerid, iPay[playerid]);
		SendClientMessage(playerid, COLOR_GREEN, "MISSION:Mission Completed. Here's your reward!");
		format(gString, 512, "%s has completed mission: %s", pName(playerid), iMissionText[playerid]);
		SendClientMessageToAll(COLOR_GREEN, gString);
		SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
		MissionStatus[playerid] = 0;
	}
	return 1;
}
stock pName(PN)
{
	new PX[MAX_PLAYER_NAME];
	GetPlayerName(PN, PX, sizeof(PX));
	return PX;
}
The Errors:

Код:
C:\Users\WickeD\Desktop\Alpine Trucking\filterscripts\missions.pwn(131) : warning 211: possibly unintended assignment
C:\Users\WickeD\Desktop\Alpine Trucking\filterscripts\missions.pwn(131) : error 008: must be a constant expression; assumed zero
C:\Users\WickeD\Desktop\Alpine Trucking\filterscripts\missions.pwn(132) : error 033: array must be indexed (variable "-unknown-")
C:\Users\WickeD\Desktop\Alpine Trucking\filterscripts\missions.pwn(132) : error 003: declaration of a local variable must appear in a compound block
C:\Users\WickeD\Desktop\Alpine Trucking\filterscripts\missions.pwn(132) : warning 217: loose indentation
C:\Users\WickeD\Desktop\Alpine Trucking\filterscripts\missions.pwn(132) : error 017: undefined symbol "MisRand"
C:\Users\WickeD\Desktop\Alpine Trucking\filterscripts\missions.pwn(132) : fatal error 107: too many error messages on one line

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


5 Errors.
Reply
#2

pawn Код:
#include <a_samp>
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

#define COLOR_ORANGE 0xF5A300FF
#define COLOR_LIMEGREEN 0x32CD32FF
#define COLOR_ROYALBLUE 0x4169E1FF
#define COLOR_SALMON 0xFA8072FF
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x00DE28FF
#define COLOR_RED 0xFF0000FF
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_LIGHTBLUE 0x33CCFFAA

enum MisLocationsEnum
{
    ID,
    LoadName[128],
    Float:LoadX,
    Float:LoadY,
    Float:LoadZ,
    Float:UnloadX,
    Float:UnloadY,
    Float:UnloadZ,
    Pay
}

new MisLocations[][MisLocationsEnum] =

{
    {0, "Beer from Red County Brewery to Bone County Diner",-24.4073,-281.8898,5.9985,-305.4319,1315.6797,54.6189, 15980},
    {1, "Fuel from LV Oil Refinery to LV Dirtring",266.8981,1416.5417,10.2001,1097.5164,1741.7422,10.5474, 15700},
    {2, "Plane Parts from SF Airport ATC to Wang Cars",-1268.8223,13.6925,14.8682,-1986.3477,253.9728,35.8985, 12642},
    {3, "Fuel from SF Oil Refinery to RS Haul",-1016.3634,-688.2434,32.7284,-55.3397,-1138.2479,0.8052, 18770},
    {4, "Stationary from LS Depot to Verdant Meadows Airstrip",2214.9072,-2221.1094,13.5469,415.9888,2523.2358,16.4844, 11324},
    {5, "Car Parts from LS Coutt and Shutz to Wang Autos",2131.8630,-1136.8284,25.6143,-1996.0587,273.7694,32.8254, 13245}
};
new PMisLocations[][MisLocationsEnum] =

{
    {0, "Car Parts from LS Coutt and Shutz to Wang Autos",2131.8630,-1136.8284,25.6143,-1996.0587,273.7694,32.8254, 13245}//Just as a test mission, to see if it works.
};

//Classes
#define TEAM_TRUCKER 1
#define TEAM_PILOT   2
new     iMissionText[512][MAX_PLAYERS], Float:unx[MAX_PLAYERS], Float:uny[MAX_PLAYERS], Float:unz[MAX_PLAYERS], iPay[MAX_PLAYERS], MissionStatus[MAX_PLAYERS];

main()
{
}
public OnGameModeInit()
{
    return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
    switch (classid)
    {
        case 0:
        {
            ShowPlayerDialog(playerid, 0, DIALOG_STYLE_LIST, "Choose A Class:", "Trucker -      0 score\nPilot -        20 score", "Choose","");
        }
    }
    return 1;
}
public OnPlayerSpawn(playerid)
{
    return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(work, 4, cmdtext);
    dcmd(stopwork, 8, cmdtext);
    return 0;
}
dcmd_work(playerid, params[])
{
    #pragma unused params
    if(GetPlayerTeam(playerid) == TEAM_TRUCKER) return T_NewJob(playerid);
    if(GetPlayerTeam(playerid) == TEAM_PILOT) return P_NewJob(playerid);
    return 1;

}
dcmd_stopwork(playerid, params[])
{
    #pragma unused params
    if(GetPlayerTeam(playerid) == TEAM_TRUCKER) return StopWork(playerid);
    if(GetPlayerTeam(playerid) == TEAM_PILOT) return StopWork(playerid);
    return 1;
}
stock T_NewJob(playerid)
{
    new vID = GetPlayerVehicleID(playerid);
    if(GetVehicleModel(vID)== 403 || GetVehicleModel(vID)== 515 || GetVehicleModel(vID) == 514)
    {
        if(IsTrailerAttachedToVehicle(vID))
        {
            MissionStatus[playerid] = 1;
            new MisRand = random(sizeof(MisLocations));
            new LoadText[128], Float:x, Float:y, Float:z;
            x = MisLocations[MisRand][LoadX];
            y = MisLocations[MisRand][LoadY];
            z = MisLocations[MisRand][LoadZ];
            unx[playerid] = MisLocations[MisRand][UnloadX];
            uny[playerid] = MisLocations[MisRand][UnloadY];
            unz[playerid] = MisLocations[MisRand][UnloadZ];
            iPay[playerid] = MisLocations[MisRand][Pay];
            SetPlayerCheckpoint(playerid, x, y, z, 7);
            format(LoadText, 128, "%s",MisLocations[MisRand][LoadName]);
            SendClientMessage(playerid, COLOR_GREEN, "Mission:");
            SendClientMessage(playerid, COLOR_GREEN, "");
            SendClientMessage(playerid, 0xFFFFFFFF, LoadText);
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED, "ERROR:You need a trailer to work!");
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "ERROR: You must be in a Truck to work!");
    }
    return 1;
}

stock P_NewJob(playerid)//Pilot New Job
{
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 519) return SendClientMessage(playerid, COLOR_RED, "ERROR:You must be in a plane to work!");
    MissionStatus[playerid] = 1;
    new MisRand = random(sizeof(MisLocations));
    new LoadText[128], Float:x, Float:y, Float:z;
    x = PMisLocations[MisRand][LoadX];
    y = PMisLocations[MisRand][LoadY];
    z = PMisLocations[MisRand][LoadZ];
    unx[playerid] = PMisLocations[MisRand][UnloadX];
    uny[playerid] = PMisLocations[MisRand][UnloadY];
    unz[playerid] = PMisLocations[MisRand][UnloadZ];
    iPay[playerid] = PMisLocations[MisRand][Pay];
    SetPlayerCheckpoint(playerid, x, y, z, 7);
    format(LoadText, 128, "%s", PMisLocations[MisRand][LoadName]);
    SendClientMessage(playerid, COLOR_GREEN, "Mission:");
    SendClientMessage(playerid, COLOR_GREEN, "");
    SendClientMessage(playerid, 0xFFFFFFFF, LoadText);
    return 1;
}

stock StopWork(playerid)
{
    DisablePlayerCheckpoint(playerid);
    SendClientMessage(playerid, COLOR_RED, "MISSION:You chose to cancel the mission and got fined $4500");
    GivePlayerMoney(playerid, -4500);
    MissionStatus[playerid] = 0;
    return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
    CheckpointEntered(playerid);
    return 1;
}
stock CheckpointEntered(playerid)
{
    new gString[128];
    new vID = GetPlayerVehicleID(playerid);
    if(!IsTrailerAttachedToVehicle(vID)) return SendClientMessage(playerid, COLOR_RED, "ERROR:You need a trailer to unload!");
    if(MissionStatus[playerid] == 1)
    {
        DisablePlayerCheckpoint(playerid);
        SetPlayerCheckpoint(playerid, unx[playerid], uny[playerid], unz[playerid], 7);
        SendClientMessage(playerid, COLOR_ORANGE, "MISSION:Loaded. Please proceed to your destination.");
        MissionStatus[playerid] = 2;
    }
    else if(MissionStatus[playerid] == 2)
    {
        DisablePlayerCheckpoint(playerid);
        GivePlayerMoney(playerid, iPay[playerid]);
        SendClientMessage(playerid, COLOR_GREEN, "MISSION:Mission Completed. Here's your reward!");
        format(gString, 512, "%s has completed mission: %s", pName(playerid), iMissionText[playerid]);
        SendClientMessageToAll(COLOR_GREEN, gString);
        SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
        MissionStatus[playerid] = 0;
    }
    return 1;
}
stock pName(PN)
{
    new PX[MAX_PLAYER_NAME];
    GetPlayerName(PN, PX, sizeof(PX));
    return PX;
}
I won't bother tidying up the script, but the problem was:
- if(GetVehicleModel(vID)== 519 ||) should not have the '||' in it, because you are only checking it once.
- You had two closing braces for 1 opening brace in your PNew_job function.
Reply
#3

It works beautifully. Dude, you're a lifesaver. Thank you a lot, and REP+.
Reply
#4

Actually, when i tried adding it, nothing comes up when i do /work or anything..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)