Help with my job system. /jobstart not recognised -
First off - sorry for the messy coding :L I'm new to it so that's why it's messy. Now, I've been working on a job system. I've created a command to do /jobstart which at this moment in time, is only to work within my trucker job. It then goes around a series of checkpoints etc. The problem is, whenever I enter the Tanker (first trucker vehicle) the command does nothing and when I enter the Linerunner (second trucker vehicle) it actually ejects me saying "You do not have the trucker job", which is only supposed to come up when the player doesn't have the trucker job, obviously. Can anyone help me out please? Code below:
Re: Help with my job system. /jobstart not recognised -
Think I may have fixed it for you. You had an extra } at the end of your coding that was PMed to me.
Re: Help with my job system. /jobstart not recognised -
Re: Help with my job system. /jobstart not recognised -
Fixed the problem. You had the OnPlayerEnterCheckpoint with in the command and didn't actually call for it.
Re: Help with my job system. /jobstart not recognised -
It's correction... Please show me your job #define....
Re: Help with my job system. /jobstart not recognised -
Some editing has been done, but the problem remains the same, if anyone can help:
Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
#include <a_samp>
//Cityhall & Jobs
new jobpickup; ///jobs pickup
new cityhallenterpickup; // /enter for city hall pickup
new cityhallexitpickup; // /exit for cityhall pickup
new job[MAX_PLAYERS]=0; // job variable
new truckerCP[MAX_PLAYERS]; // Trucker Job Checkpoint Variable
#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, 5) == 0) // /jobs
{
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, 6) ==0) // city hall /enter
{
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, 5) ==0) // city hall/exit
{
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,8) ==0) // /jobhelp
{
if (job[playerid] == 1)
{
SendClientMessage(playerid,0xAFAFAFAA,"-----------Trucker Job-----------");
SendClientMessage(playerid,0xAFAFAFAA,"/jobstart, /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,"/jobstart, /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,"/jobstart, /jobend");
SendClientMessage(playerid,0xAFAFAFAA,"/helpme if you need any more assistance");
return 1;
}
else if (job[playerid] == 0)
{
SendClientMessage(playerid,0xAFAFAFAA,"You do not have an occupation. Please go to city hall to apply for a job.");
return 1;
}
return 1;
}
if (strcmp("/jobstart",cmdtext,true,9)==0)
{
new JobvModel;
JobvModel = GetVehicleModel(GetPlayerVehicleID(playerid));
if (job[playerid] == 1){
if (JobvModel == 403 || JobvModel == 514){
truckerCP[playerid] = 1;
SetPlayerCheckpoint(playerid, 2114.2888,-2092.0613,13.5544, 4.0);
SendClientMessage(playerid, 0x33AA33AA, "You have succesfully started your trucker job. Head to the checkpoint to pick up your trailer.");
}
}
}
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
{
new vModel = GetVehicleModel(GetPlayerVehicleID(playerid));
if (vModel== 403 || vModel==514)
{
if (job[playerid]!=1)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid,0xAA3333AA,"You do not have the trucker job");
}
}
else if (vModel== 448 && job[playerid]!=2)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid,0xAA3333AA,"You do not have the pizza-boy job");
}
else if (vModel== 408 && job[playerid]!=3)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid,0xAA3333AA,"You do not have the trashmaster job");
}
}
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
if(truckerCP[playerid] ==1)
{
DisablePlayerCheckpoint(playerid);
SendClientMessage(playerid,0x00EEADDF,"You have reached the trailers. Now connect your truck up to one of the trailers and head to the next checkpoint.");
SetPlayerCheckpoint(playerid, 2510.4958,-2111.0754,13.5469, 4.0);
}
if(truckerCP[playerid] ==2)
{
new TrailerAttached =IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid));
if(TrailerAttached == 1)
{
DisablePlayerCheckpoint(playerid);
SetPlayerCheckpoint(playerid, -575.4124,-486.3466,25.5234, 4.0);
SendClientMessage(playerid,0x00EEADDF,"You have reached the transport pickup point. Items have been added to your trailer.");
}
else if(TrailerAttached == 0)
{
SendClientMessage(playerid,0x660000AA,"How can you pickup your goods without a trailer? Go back and pick one up.");
}
}
if(truckerCP[playerid]==3)
{
new TrailerAttached=IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid));
if(TrailerAttached == 1)
{
DisablePlayerCheckpoint(playerid);
SetPlayerCheckpoint(playerid, -169.5069,-318.4261,1.4297, 4.0);
SendClientMessage(playerid,0x00EEADDF,"You have reached the drop-off point. Items have been removed from your trailer.");
}
else if(TrailerAttached == 0)
{
SendClientMessage(playerid,0x660000AA,"No trailer, no goods, no money. Come back with the trailer of goods.");
}
}
if(truckerCP[playerid]==4)
{
new TrailerAttached=IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid));
if (TrailerAttached == 1)
{
DisablePlayerCheckpoint(playerid);
SendClientMessage(playerid,0x00EEADDF,"You have reached the trailer drop-off point. Please remove your trailer.");
GivePlayerMoney(playerid, 200);
}
else if(TrailerAttached == 0)
{
SendClientMessage(playerid,0x660000AA,"You are not getting paid until you've got my trailer back!");
}
}
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:
{
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;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
EDIT: THE FIRST ORIGINAL CODE I POSTED IS IRRELEVANT. I GAVE YOU THE WRONG PART -_-
Re: Help with my job system. /jobstart not recognised -
Re: Help with my job system. /jobstart not recognised -
Please don't use strcmp to process commands..
Anyways... : do some prints throughout the command
See what the console outputs then you can see were the command fails to process.
Re: Help with my job system. /jobstart not recognised -
You did "vModel== 403 || vModel==514 && job[playerid] != 1" but that won't work, as it will always say "You do not have the trucker job" when a player enters vehicle model 403, trucker or not.
This will fix the 2nd problem, I don't think it'll fix the first problem but your command "/jobstart" looks fine.
I checked the "/jobstart" code to be sure, a good indentation is important so always make sure you do it well. This is what I made of it and I think it looks good:
Re: Help with my job system. /jobstart not recognised -