SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 05/02/2013, 09:53 PM   #1
Jonesy96
Huge Clucker
 
Join Date: Jun 2011
Posts: 232
Reputation: 18
Question If Statement/Case Statement assistance with /jobhelp

So, I'm creating a job system. I have a dialogue box allowing a selection of three jobs, trashmaster, trucker and pizzaboy. I'm new so keeping it simple. I scripted a /jobhelp command so that the help menu changes depending on which job you have selected from the joblist. But, no matter what job you choose, even if you don't have one, it just comes up with the trashmaster help menu, and not any of the others. I've no idea how to fix this. Script is below, please help. Thanks.

Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>

//Cityhall & Jobs
new jobpickup;
new cityhallenterpickup;
new cityhallexitpickup;
new TrashmasterJob;
new PizzaJob;
new TruckerJob;

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" Blank Filterscript by your name here");
	print("--------------------------------------\n");
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

#else

main()
{
	print("\n----------------------------------");
	print(" Blank Gamemode by your name here");
	print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
	// Don't use these lines if it's a filterscript
	SetGameModeText("Rhys' Test");
	AddPlayerClass(286,1481.0565,-1771.2000,18.7958,181.4338,0,0,0,0,0,0);
	// Cityhall & Jobs Pickups
	jobpickup = CreatePickup(1239,1,363.4658,173.8406,1008.3828);
	cityhallenterpickup = CreatePickup(1239,1,1481.0565,-1771.2000,18.7958);
	cityhallexitpickup = CreatePickup(1239,1,387.9753,173.5708,1008.3828);
	//Job Vehicles
	CreateVehicle(448,2098.0735,-1793.0139,12.9846,88.1403,3,6,120000);
	CreateVehicle(448,2098.1221,-1794.8608,12.9778,89.6968,3,6,120000);
	CreateVehicle(448,2098.0640,-1796.6982,12.9868,89.8181,3,6,120000);
	CreateVehicle(448,2098.2153,-1799.0900,12.9883,93.7124,3,6,120000);
	CreateVehicle(448,2098.0923,-1801.3217,12.9855,91.5414,3,6,120000);
	CreateVehicle(403,1989.9371,-2058.1421,13.9763,89.9044,37,1,120000);
	CreateVehicle(403,1989.9835,-2062.7520,13.9769,89.7113,37,1,120000);
	CreateVehicle(514,1974.9984,-2064.7517,13.9753,358.8618,25,1,120000);
	CreateVehicle(435,2133.0686,-2092.4158,14.1329,136.8398,25,1,120000);
	CreateVehicle(435,2126.2871,-2085.7627,14.1308,135.2913,25,1,120000);
	CreateVehicle(435,2118.7998,-2078.5063,14.1431,136.4138,25,1,120000);
	CreateVehicle(408,1768.9283,-2032.1532,14.2805,270.4727,26,26,120000);
	CreateVehicle(408,1769.2151,-2048.5842,14.2831,270.8420,26,26,120000);
	CreateVehicle(408,1788.3578,-2024.2463,14.0245,178.3893,26,26,120000);
	CreateVehicle(408,1795.2281,-2024.2175,14.0413,179.2720,26,26,120000);
	//Next vehicle was for test purposes - DELETE
	CreateVehicle(402,1481.0980,-1737.9425,13.5469,179.2720,26,26,120000);
	return 1;
}

public OnGameModeExit()
{
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
	SetPlayerPos(playerid, 1795.2281,-2024.2175,14.0413);
	SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
	return 1;
}

public OnPlayerConnect(playerid)
{
	SendClientMessage(playerid, 0xAA3333AA, "Rhys' Testing Script");
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	return 1;
}

public OnPlayerSpawn(playerid)
{
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	return 1;
}

public OnVehicleSpawn(vehicleid)
{
	return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
	return 1;
}

public OnPlayerText(playerid, text[])
{
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
//City hall & Jobs
{
 if (strcmp("/jobs", cmdtext, true, 10) == 0)
	{
		if (IsPlayerInRangeOfPoint(playerid, 10, 363.4658,173.8406,1008.3828))
		ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,"Available Employment","1)Trucker\n2)Pizzaboy\n3)Trashman","Select","Cancel");
		return 1;
	}
 if (strcmp("/enter", cmdtext, true, 10) ==0)
   	{
   	   if (IsPlayerInRangeOfPoint(playerid, 10,1481.0565,-1771.2000,18.7958))
	   SetPlayerPos(playerid,387.9753,173.5708,1008.3828);
	   SetPlayerInterior(playerid, 3);
       return 1;
	}
 if (strcmp("/exit", cmdtext,true, 10) ==0)
    {
	   if (IsPlayerInRangeOfPoint(playerid, 10,387.9753,173.5708,1008.3828))
	   SetPlayerPos(playerid,1481.0565,-1771.2000,18.7958);
	   SetPlayerInterior(playerid,0);
	   return 1;
	}
 if (strcmp("/jobhelp",cmdtext,true,10) ==0)
	{
	    if (playerid == TruckerJob)
	    {
			SendClientMessage(playerid,0xAFAFAFAA,"-----------Trucker Job-----------");
			SendClientMessage(playerid,0xAFAFAFAA,"/jobbegin, /jobend");
			SendClientMessage(playerid,0xAFAFAFAA,"/helpme if you need any more assistance");
			return 1;
		}
		else if (playerid == PizzaJob)
		{
		    SendClientMessage(playerid,0xAFAFAFAA,"-----------Pizzaboy Job-----------");
			SendClientMessage(playerid,0xAFAFAFAA,"/jobbegin, /jobend");
			SendClientMessage(playerid,0xAFAFAFAA,"/helpme if you need any more assistance");
			return 1;
		}
		else if (playerid == TrashmasterJob)
		{
		    SendClientMessage(playerid,0xAFAFAFAA,"-----------Trashmaster Job-----------");
			SendClientMessage(playerid,0xAFAFAFAA,"/jobbegin, /jobend");
			SendClientMessage(playerid,0xAFAFAFAA,"/helpme if you need any more assistance");
			return 1;
        }
		else if (playerid == 0)
		{
		    SendClientMessage(playerid,0xAFAFAFAA,"You do not have an occupation. Please go to city hall to apply for a job.");
			return 1;
		}
	}
 return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
	return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
	return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
	return 1;
}

public OnRconCommand(cmd[])
{
	return 1;
}

public OnPlayerRequestSpawn(playerid)
{
	return 1;
}

public OnObjectMoved(objectid)
{
	return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
	return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
//City hall & Jobs
{
	{
	if (pickupid == jobpickup)
	    {
	    GameTextForPlayer(playerid,"~g~ /jobs",5000,1);
	    }
	}
	{
	if(pickupid == cityhallenterpickup)
	    {
	    GameTextForPlayer(playerid,"~r~City Hall",2000,1);
	    }
	}
	{
	if (pickupid == cityhallexitpickup)
	    {
	    GameTextForPlayer(playerid,"~r~City Hall Exit",2000,1);
	    }
	}
	return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
	return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
	return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
	return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
	return 1;
}

public OnPlayerExitedMenu(playerid)
{
	return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
	return 1;
}

public OnPlayerUpdate(playerid)
{
	return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
	return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
	return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
	return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid==1 && response==1)
{
 switch(listitem)
 {
  case 0:
  {
   playerid = TruckerJob;
   SendClientMessage(playerid, 0x33AA33AA, "Application accepted. Your new job as a Trucker is waiting! Use /jobhelp for assistance.");
  }
  case 1:
  {
   playerid = PizzaJob;
   SendClientMessage(playerid, 0x33AA33AA, "Application accepted. Your new job as a Pizzaboy is waiting! Use /jobhelp for assistance.");
  }
  case 2:
  {
   playerid = TrashmasterJob;
   SendClientMessage(playerid, 0x33AA33AA, "Application accepted. Your new job as a Trashman is waiting! Use /jobhelp for assistance.");
  }
 }
}

return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
	return 1;
}
Jonesy96 is offline   Reply With Quote
Old 05/02/2013, 10:03 PM   #2
zde5
Little Clucker
 
Join Date: Jul 2009
Location: Croatia
Posts: 48
Reputation: 4
Default Re: If Statement/Case Statement assistance with /jobhelp

Try this



Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>

//Cityhall & Jobs
new jobpickup,
 cityhallenterpickup,
 cityhallexitpickup,
 TrashmasterJob,
 PizzaJob,
 TruckerJob,
 job[MAX_PLAYERS] = {0};

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" Blank Filterscript by your name here");
	print("--------------------------------------\n");
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

#else

main()
{
	print("\n----------------------------------");
	print(" Blank Gamemode by your name here");
	print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
	// Don't use these lines if it's a filterscript
	SetGameModeText("Rhys' Test");
	AddPlayerClass(286,1481.0565,-1771.2000,18.7958,181.4338,0,0,0,0,0,0);
	// Cityhall & Jobs Pickups
	jobpickup = CreatePickup(1239,1,363.4658,173.8406,1008.3828);
	cityhallenterpickup = CreatePickup(1239,1,1481.0565,-1771.2000,18.7958);
	cityhallexitpickup = CreatePickup(1239,1,387.9753,173.5708,1008.3828);
	//Job Vehicles
	CreateVehicle(448,2098.0735,-1793.0139,12.9846,88.1403,3,6,120000);
	CreateVehicle(448,2098.1221,-1794.8608,12.9778,89.6968,3,6,120000);
	CreateVehicle(448,2098.0640,-1796.6982,12.9868,89.8181,3,6,120000);
	CreateVehicle(448,2098.2153,-1799.0900,12.9883,93.7124,3,6,120000);
	CreateVehicle(448,2098.0923,-1801.3217,12.9855,91.5414,3,6,120000);
	CreateVehicle(403,1989.9371,-2058.1421,13.9763,89.9044,37,1,120000);
	CreateVehicle(403,1989.9835,-2062.7520,13.9769,89.7113,37,1,120000);
	CreateVehicle(514,1974.9984,-2064.7517,13.9753,358.8618,25,1,120000);
	CreateVehicle(435,2133.0686,-2092.4158,14.1329,136.8398,25,1,120000);
	CreateVehicle(435,2126.2871,-2085.7627,14.1308,135.2913,25,1,120000);
	CreateVehicle(435,2118.7998,-2078.5063,14.1431,136.4138,25,1,120000);
	CreateVehicle(408,1768.9283,-2032.1532,14.2805,270.4727,26,26,120000);
	CreateVehicle(408,1769.2151,-2048.5842,14.2831,270.8420,26,26,120000);
	CreateVehicle(408,1788.3578,-2024.2463,14.0245,178.3893,26,26,120000);
	CreateVehicle(408,1795.2281,-2024.2175,14.0413,179.2720,26,26,120000);
	//Next vehicle was for test purposes - DELETE
	CreateVehicle(402,1481.0980,-1737.9425,13.5469,179.2720,26,26,120000);
	return 1;
}

public OnGameModeExit()
{
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
	SetPlayerPos(playerid, 1795.2281,-2024.2175,14.0413);
	SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
	return 1;
}

public OnPlayerConnect(playerid)
{
	SendClientMessage(playerid, 0xAA3333AA, "Rhys' Testing Script");
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
//City hall & Jobs
{
 if (strcmp("/jobs", cmdtext, true, 10) == 0)
	{
		if (IsPlayerInRangeOfPoint(playerid, 10, 363.4658,173.8406,1008.3828))
		ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,"Available Employment","1)Trucker\n2)Pizzaboy\n3)Trashman","Select","Cancel");
		return 1;
	}
 if (strcmp("/enter", cmdtext, true, 10) ==0)
   	{
   	   if (IsPlayerInRangeOfPoint(playerid, 10,1481.0565,-1771.2000,18.7958))
	   SetPlayerPos(playerid,387.9753,173.5708,1008.3828);
	   SetPlayerInterior(playerid, 3);
       return 1;
	}
 if (strcmp("/exit", cmdtext,true, 10) ==0)
    {
	   if (IsPlayerInRangeOfPoint(playerid, 10,387.9753,173.5708,1008.3828))
	   SetPlayerPos(playerid,1481.0565,-1771.2000,18.7958);
	   SetPlayerInterior(playerid,0);
	   return 1;
	}
 if (strcmp("/jobhelp",cmdtext,true,10) ==0)
	{
	    if (job[playerid] == TruckerJob)
	    {
			SendClientMessage(playerid,0xAFAFAFAA,"-----------Trucker Job-----------");
			SendClientMessage(playerid,0xAFAFAFAA,"/jobbegin, /jobend");
			SendClientMessage(playerid,0xAFAFAFAA,"/helpme if you need any more assistance");
			return 1;
		}
		else if (job[playerid] == PizzaJob)
		{
		    SendClientMessage(playerid,0xAFAFAFAA,"-----------Pizzaboy Job-----------");
			SendClientMessage(playerid,0xAFAFAFAA,"/jobbegin, /jobend");
			SendClientMessage(playerid,0xAFAFAFAA,"/helpme if you need any more assistance");
			return 1;
		}
		else if (job[playerid] == TrashmasterJob)
		{
		    SendClientMessage(playerid,0xAFAFAFAA,"-----------Trashmaster Job-----------");
			SendClientMessage(playerid,0xAFAFAFAA,"/jobbegin, /jobend");
			SendClientMessage(playerid,0xAFAFAFAA,"/helpme if you need any more assistance");
			return 1;
        }
		else if (playerid == 0)
		{
		    SendClientMessage(playerid,0xAFAFAFAA,"You do not have an occupation. Please go to city hall to apply for a job.");
			return 1;
		}
	}
 return 0;
}

public OnPlayerPickUpPickup(playerid, pickupid)
//City hall & Jobs
{
	{
	if (pickupid == jobpickup)
	    {
	    GameTextForPlayer(playerid,"~g~ /jobs",5000,1);
	    }
	}
	{
	if(pickupid == cityhallenterpickup)
	    {
	    GameTextForPlayer(playerid,"~r~City Hall",2000,1);
	    }
	}
	{
	if (pickupid == cityhallexitpickup)
	    {
	    GameTextForPlayer(playerid,"~r~City Hall Exit",2000,1);
	    }
	}
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid==1 && response==1)
{
 switch(listitem)
 {
  case 0:
  {
   job[playerid] = TruckerJob;
   SendClientMessage(playerid, 0x33AA33AA, "Application accepted. Your new job as a Trucker is waiting! Use /jobhelp for assistance.");
  }
  case 1:
  {
   job[playerid] = PizzaJob;
   SendClientMessage(playerid, 0x33AA33AA, "Application accepted. Your new job as a Pizzaboy is waiting! Use /jobhelp for assistance.");
  }
  case 2:
  {
   job[playerid] = TrashmasterJob;
   SendClientMessage(playerid, 0x33AA33AA, "Application accepted. Your new job as a Trashman is waiting! Use /jobhelp for assistance.");
  }
 }
}

return 1;
}
zde5 is offline   Reply With Quote
Old 05/02/2013, 10:13 PM   #3
Jonesy96
Huge Clucker
 
Join Date: Jun 2011
Posts: 232
Reputation: 18
Default Re: If Statement/Case Statement assistance with /jobhelp

Hasn't made a difference :/
Jonesy96 is offline   Reply With Quote
Old 05/02/2013, 10:16 PM   #4
zde5
Little Clucker
 
Join Date: Jul 2009
Location: Croatia
Posts: 48
Reputation: 4
Default Re: If Statement/Case Statement assistance with /jobhelp

Then try this.

Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>

//Cityhall & Jobs
new jobpickup,
 cityhallenterpickup,
 cityhallexitpickup,
 job[MAX_PLAYERS] = {0};

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" Blank Filterscript by your name here");
	print("--------------------------------------\n");
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

#else

main()
{
	print("\n----------------------------------");
	print(" Blank Gamemode by your name here");
	print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
	// Don't use these lines if it's a filterscript
	SetGameModeText("Rhys' Test");
	AddPlayerClass(286,1481.0565,-1771.2000,18.7958,181.4338,0,0,0,0,0,0);
	// Cityhall & Jobs Pickups
	jobpickup = CreatePickup(1239,1,363.4658,173.8406,1008.3828);
	cityhallenterpickup = CreatePickup(1239,1,1481.0565,-1771.2000,18.7958);
	cityhallexitpickup = CreatePickup(1239,1,387.9753,173.5708,1008.3828);
	//Job Vehicles
	CreateVehicle(448,2098.0735,-1793.0139,12.9846,88.1403,3,6,120000);
	CreateVehicle(448,2098.1221,-1794.8608,12.9778,89.6968,3,6,120000);
	CreateVehicle(448,2098.0640,-1796.6982,12.9868,89.8181,3,6,120000);
	CreateVehicle(448,2098.2153,-1799.0900,12.9883,93.7124,3,6,120000);
	CreateVehicle(448,2098.0923,-1801.3217,12.9855,91.5414,3,6,120000);
	CreateVehicle(403,1989.9371,-2058.1421,13.9763,89.9044,37,1,120000);
	CreateVehicle(403,1989.9835,-2062.7520,13.9769,89.7113,37,1,120000);
	CreateVehicle(514,1974.9984,-2064.7517,13.9753,358.8618,25,1,120000);
	CreateVehicle(435,2133.0686,-2092.4158,14.1329,136.8398,25,1,120000);
	CreateVehicle(435,2126.2871,-2085.7627,14.1308,135.2913,25,1,120000);
	CreateVehicle(435,2118.7998,-2078.5063,14.1431,136.4138,25,1,120000);
	CreateVehicle(408,1768.9283,-2032.1532,14.2805,270.4727,26,26,120000);
	CreateVehicle(408,1769.2151,-2048.5842,14.2831,270.8420,26,26,120000);
	CreateVehicle(408,1788.3578,-2024.2463,14.0245,178.3893,26,26,120000);
	CreateVehicle(408,1795.2281,-2024.2175,14.0413,179.2720,26,26,120000);
	//Next vehicle was for test purposes - DELETE
	CreateVehicle(402,1481.0980,-1737.9425,13.5469,179.2720,26,26,120000);
	return 1;
}

public OnGameModeExit()
{
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
	SetPlayerPos(playerid, 1795.2281,-2024.2175,14.0413);
	SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
	return 1;
}

public OnPlayerConnect(playerid)
{
	SendClientMessage(playerid, 0xAA3333AA, "Rhys' Testing Script");
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
//City hall & Jobs
{
 if (strcmp("/jobs", cmdtext, true, 10) == 0)
	{
		if (IsPlayerInRangeOfPoint(playerid, 10, 363.4658,173.8406,1008.3828))
		ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST,"Available Employment","1)Trucker\n2)Pizzaboy\n3)Trashman","Select","Cancel");
		return 1;
	}
 if (strcmp("/enter", cmdtext, true, 10) ==0)
   	{
   	   if (IsPlayerInRangeOfPoint(playerid, 10,1481.0565,-1771.2000,18.7958))
	   SetPlayerPos(playerid,387.9753,173.5708,1008.3828);
	   SetPlayerInterior(playerid, 3);
       return 1;
	}
 if (strcmp("/exit", cmdtext,true, 10) ==0)
    {
	   if (IsPlayerInRangeOfPoint(playerid, 10,387.9753,173.5708,1008.3828))
	   SetPlayerPos(playerid,1481.0565,-1771.2000,18.7958);
	   SetPlayerInterior(playerid,0);
	   return 1;
	}
 if (strcmp("/jobhelp",cmdtext,true,10) ==0)
	{
	    if (job[playerid] == 1)
	    {
			SendClientMessage(playerid,0xAFAFAFAA,"-----------Trucker Job-----------");
			SendClientMessage(playerid,0xAFAFAFAA,"/jobbegin, /jobend");
			SendClientMessage(playerid,0xAFAFAFAA,"/helpme if you need any more assistance");
			return 1;
		}
		else if (job[playerid] == 2)
		{
		    SendClientMessage(playerid,0xAFAFAFAA,"-----------Pizzaboy Job-----------");
			SendClientMessage(playerid,0xAFAFAFAA,"/jobbegin, /jobend");
			SendClientMessage(playerid,0xAFAFAFAA,"/helpme if you need any more assistance");
			return 1;
		}
		else if (job[playerid] == 3)
		{
		    SendClientMessage(playerid,0xAFAFAFAA,"-----------Trashmaster Job-----------");
			SendClientMessage(playerid,0xAFAFAFAA,"/jobbegin, /jobend");
			SendClientMessage(playerid,0xAFAFAFAA,"/helpme if you need any more assistance");
			return 1;
        }
		else if (playerid == 0)
		{
		    SendClientMessage(playerid,0xAFAFAFAA,"You do not have an occupation. Please go to city hall to apply for a job.");
			return 1;
		}
	}
 return 0;
}

public OnPlayerPickUpPickup(playerid, pickupid)
//City hall & Jobs
{
	{
	if (pickupid == jobpickup)
	    {
	    GameTextForPlayer(playerid,"~g~ /jobs",5000,1);
	    }
	}
	{
	if(pickupid == cityhallenterpickup)
	    {
	    GameTextForPlayer(playerid,"~r~City Hall",2000,1);
	    }
	}
	{
	if (pickupid == cityhallexitpickup)
	    {
	    GameTextForPlayer(playerid,"~r~City Hall Exit",2000,1);
	    }
	}
	return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid==1 && response==1)
{
 switch(listitem)
 {
  case 0:
  {
   job[playerid] = 1;
   SendClientMessage(playerid, 0x33AA33AA, "Application accepted. Your new job as a Trucker is waiting! Use /jobhelp for assistance.");
  }
  case 1:
  {
   job[playerid] = 2;
   SendClientMessage(playerid, 0x33AA33AA, "Application accepted. Your new job as a Pizzaboy is waiting! Use /jobhelp for assistance.");
  }
  case 2:
  {
   job[playerid] = 3;
   SendClientMessage(playerid, 0x33AA33AA, "Application accepted. Your new job as a Trashman is waiting! Use /jobhelp for assistance.");
  }
 }
}

return 1;
}
zde5 is offline   Reply With Quote
Old 05/02/2013, 10:22 PM   #5
Jonesy96
Huge Clucker
 
Join Date: Jun 2011
Posts: 232
Reputation: 18
Default Re: If Statement/Case Statement assistance with /jobhelp

Works great! Thanks a lot. Could you explain this [MAXPLAYERS] thing to me please? Thanks
Jonesy96 is offline   Reply With Quote
Old 05/02/2013, 10:25 PM   #6
zde5
Little Clucker
 
Join Date: Jul 2009
Location: Croatia
Posts: 48
Reputation: 4
Default Re: If Statement/Case Statement assistance with /jobhelp

its an array with MAX_PLAYERS elements (500 by default) so each player has its own variable to store his job data (playerid 0 has variable job[0], playerid 1 has variable job[1] etc...)

http://wiki.sa-mp.com/wiki/Scripting_Basics#Arrays
zde5 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
error 002: only a single statement (or expression) can follow each "case" _Khaled_ Scripting Help 3 01/12/2019 12:57 PM
(22169) : error 002: only a single statement (or expression) can follow each "case" Adam_Hardy Scripting Help 3 16/08/2012 04:38 PM
"||" statement not working within if statement. Dokins Scripting Help 6 31/01/2012 01:56 PM
only a single statement (or expression) can follow each "case" DarkPower Help Archive 7 17/03/2010 06:03 PM
Only a single statement (or expression) can follow each "case" CaHbKo Help Archive 3 02/12/2009 04:10 PM


All times are GMT. The time now is 01:08 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.