23.02.2013, 13:22
(
Последний раз редактировалось AaronFarley; 24.02.2013 в 12:16.
)
Last problem (hopefully) The last checkpoint seems to be unresponsive when it is entered.
pawn Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
//fishing
forward FishCatchTimer(playerid);
new HasRod[MAX_PLAYERS], HasBait[MAX_PLAYERS], Fishing[MAX_PLAYERS], Fish[MAX_PLAYERS][5];
//mining
forward DigTimer(playerid);
new HasShovel[MAX_PLAYERS], Rock[MAX_PLAYERS][5], Digging[MAX_PLAYERS];
//Stages
enum {
STAGE_NONE,
STAGE_PICKUP,
STAGE_ONROUTE,
STAGE_COMPLETE
}
new MissionStage[MAX_PLAYERS];
//COLORS
#define COLOR_ORANGE 0xFFA500FF
#define COLOR_LIMEGREEN 0x32CD32FF
#define COLOR_ROYALBLUE 0x4169E1FF
#define COLOR_PINK 0xFA8072FF
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define TEAM_TRUCKER 0
//Garbage CheckPoints
new Float:Gcheckpoints[5][4] =
{
{ 2798.1702,-1576.2926,10.9272, 10.0 },
{ 2060.4375,-2091.2126,13.5469, 10.0 },
{ 070.8125,-2384.6160,13.5469, 10.0 },
{ 900.7358,-1204.0779,16.9832, 10.0 },
{ 800.1103,-1542.8258,13.5526, 10.0 }
};
main()
{
}
public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
SetGameModeText("Life Of Transport");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
//Server Vehicles
CreateVehicle(455, 0, 0, 12.2887, 82.2873, -1, -1, 60);
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnPlayerConnect(playerid)
{
//You will want to add the following:
//fishing crap
Fishing[playerid] = 0;
HasBait[playerid] = 0;
HasRod[playerid] = 0;
Fish[playerid][1] = 0;
Fish[playerid][2] = 0;
Fish[playerid][3] = 0;
Fish[playerid][4] = 0;
//Mining crap
Digging[playerid] = 0;
HasShovel[playerid]= 0;
Rock[playerid][1] = 0;
Rock[playerid][2] = 0;
Rock[playerid][3] = 0;
Rock[playerid][4] = 0;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
//fishing crap
Fishing[playerid] = 0;
HasBait[playerid] = 0;
HasRod[playerid] = 0;
Fish[playerid][1] = 0;
Fish[playerid][2] = 0;
Fish[playerid][3] = 0;
Fish[playerid][4] = 0;
//Mining crap
Digging[playerid] = 0;
HasShovel[playerid]= 0;
Rock[playerid][1] = 0;
Rock[playerid][2] = 0;
Rock[playerid][3] = 0;
Rock[playerid][4] = 0;
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
//Lose fish on death
Fish[playerid][1] = 0;
Fish[playerid][2] = 0;
Fish[playerid][3] = 0;
Fish[playerid][4] = 0;
//Lose Rocks On Death
Rock[playerid][1] = 0;
Rock[playerid][2] = 0;
Rock[playerid][3] = 0;
Rock[playerid][4] = 0;
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/work", cmdtext, true, 10) == 0) {
//Garbage Mission
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 455) {
if (MissionStage[playerid] != STAGE_NONE) {
SendClientMessage(playerid, COLOR_RED, "You are already doing the rubbish truck driving Mission!");
return 1;
}
MissionStage[playerid] = STAGE_PICKUP;
new rand = random(sizeof(Gcheckpoints));
SetPlayerCheckpoint(playerid, Gcheckpoints[rand][0], Gcheckpoints[rand][1], Gcheckpoints[rand][2], Gcheckpoints[rand][3]);
GameTextForPlayer(playerid, "~g~You started the job, good luck!", 3000, 3);
new name[MAX_PLAYER_NAME], string[48];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s is now doing the Rubbish mission.", name );
return SendClientMessageToAll(COLOR_YELLOW, string);
}
return SendClientMessage(playerid, COLOR_RED, "You have to be in a truck to start the job");
//Garbage mission ends
}
return 0;
}
public OnPlayerEnterCheckpoint(playerid)
{
DisablePlayerCheckpoint(playerid);
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 455) {
if(STAGE_PICKUP == MissionStage[playerid]) {
SendClientMessage(playerid, COLOR_RED, "Loading Rubbish");
SetPlayerCheckpoint(playerid, 0, 0, 0, 0);
GameTextForPlayer(playerid, "~g~Go drop off the rubbish!", 3000, 3);
MissionStage[playerid] = STAGE_ONROUTE;
}
else if(STAGE_ONROUTE == MissionStage[playerid]) {
DisablePlayerCheckpoint(playerid);
SendClientMessage(playerid, COLOR_RED, "Unloading Rubbish");
GameTextForPlayer(playerid, "~g~You Completed The Mission", 3000, 3);
SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
GivePlayerMoney(playerid, 5000);
new name[MAX_PLAYER_NAME], string[48];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s has Completed A Rubbish Mission!", name );
MissionStage[playerid] = STAGE_NONE;
}
}
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
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)
{
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[])
{
switch(dialogid)
{
case 1:
{
if(!response) return 1;
else
{
switch(listitem)
{
case 0:
{
SendClientMessage(playerid, COLOR_YELLOW, "You have purchased a fishing rod!");
GivePlayerMoney(playerid, -2000);
HasRod[playerid] = 1;
}
case 1:
{
SendClientMessage(playerid, COLOR_YELLOW, "You have purchased some fishing bait!");
GivePlayerMoney(playerid, -250);
HasBait[playerid] = 1;
}
case 3:
{
SendClientMessage(playerid, COLOR_YELLOW, "You have purchased A Shovel!!");
GivePlayerMoney(playerid, -2000);
HasShovel[playerid] = 1;
}
}
}
return 1;
}
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
stock pName(PN)
{
new PX[MAX_PLAYER_NAME];
GetPlayerName(PN, PX, sizeof(PX));
return PX;
}
public DigTimer(playerid)
{
Digging[playerid] = 0;
switch(random(13))
{
case 0:
{
if(Rock[playerid][1] < 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You Have Dug Up Some Iron Ore!");
Rock[playerid][4] = 150;
}
else if(Rock[playerid][2] < 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You Have Dug Up Some Iron Ore!");
Rock[playerid][4] = 41;
}
else if(Rock[playerid][3] < 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You Have Dug Up Some Iron Ore!");
Rock[playerid][4] = 41;
}
else if(Rock[playerid][4] < 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You Have Dug Up Some Iron Ore!");
Rock[playerid][4] = 41;
}
else return 1;
}
case 1:
{
if(Rock[playerid][1] < 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You Have Dug Up A GIANT Diamond!");
Rock[playerid][1] = 25000;
}
else if(Rock[playerid][2] < 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You Have Dug Up A GIANT Diamond!");
Rock[playerid][2] = 25000;
}
else if(Rock[playerid][3] < 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You Have Dug Up A GIANT Diamond!");
Rock[playerid][3] = 25000;
}
else if(Rock[playerid][4] < 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You Have Dug Up A GIANT Diamond!");
Rock[playerid][4] = 25000;
}
else return 1;
}
case 2:
{
if(Rock[playerid][1] < 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You Have Dug Up Some Haydztanium!");
Rock[playerid][1] = 1337;
}
else if(Rock[playerid][2] < 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You Have Dug Up Some Haydztanium!");
Rock[playerid][2] = 1337;
}
else if(Fish[playerid][3] < 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You Have Dug Up Some Haydztanium!");
Rock[playerid][3] = 1337;
}
else if(Fish[playerid][4] < 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You Have Dug Up Some Haydztanium!");
Rock[playerid][4] = 1337;
}
}
case 3:
{
SendClientMessage(playerid, COLOR_RED, "You Have Dug Up Some Rubbish.");
GameTextForPlayer(playerid, "~r~Rubbish thrown away.", 3000, 5);
}
case 4:
{
SendClientMessage(playerid, COLOR_RED, "You Have Dug Up A Nuclear Bomb. OH NO!");
GameTextForPlayer(playerid, "~r~The Bomb Exploded!.", 3000, 5);
SetPlayerHealth(playerid, 0);
}
case 5:
{
SendClientMessage(playerid, COLOR_RED, "You Have Dug Up A Body. Good Job It Isnt Yours!");
}
case 6:
{
SendClientMessage(playerid, COLOR_ORANGE, "You Have Found Some Buried Treasure!");
GameTextForPlayer(playerid, "~G~KA-CHING.", 3000, 5);
GivePlayerMoney(playerid, 22500);
}
case 7:
{
SendClientMessage(playerid, COLOR_WHITE, "You Didnt Find Anything!");
}
case 8:
{
SendClientMessage(playerid, COLOR_RED, "You Were Attacked By A Mole!!");
GameTextForPlayer(playerid, "~r~Attacked By A Mole!.", 3000, 5);
SetPlayerHealth(playerid, 50);
}
case 9:
{
SendClientMessage(playerid, COLOR_WHITE, "You have found some dirt!");
}
case 10:
{
SendClientMessage(playerid, COLOR_RED, "OH NO, A Cave In! You Have Lost Your Rocks!!");
GameTextForPlayer(playerid, "~r~Rocks Lost!.", 3000, 5);
Rock[playerid][1] = 0;
Rock[playerid][2] = 0;
Rock[playerid][3] = 0;
Rock[playerid][4] = 0;
}
case 11:
{
SendClientMessage(playerid, COLOR_RED, "You Were Attacked By A Zombie!");
GameTextForPlayer(playerid, "~r~A Zombie Attacked You!.", 3000, 5);
SetPlayerHealth(playerid, 0);
}
case 12:
{
SendClientMessage(playerid, COLOR_RED, "The Rock Fell Down A Ravine");
GameTextForPlayer(playerid, "~r~You Lost The Rock.", 3000, 5);
}
}
return 1;
}
command(dig, playerid, params[])
{
//old coords -2105.3228, -124.2982, 37.2531
if(IsPlayerInRangeOfPoint(playerid, 100.0, 0, 0, 0))
{
if(Digging[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "You are already digging!");
if(Rock[playerid][1] >= 1 && Rock[playerid][2] >= 1 && Rock[playerid][3] >= 1 && Rock[playerid][4] >= 1) return SendClientMessage(playerid, COLOR_WHITE, "You have too many rocks. Sell some! ");
if(HasShovel[playerid] == 1)
{
Digging[playerid] = 1;
SendClientMessage(playerid, COLOR_WHITE, "You have started to Dig. Please wait 5 seconds.");
SetTimerEx("DigTimer", 5000, false, "i", playerid);
}
else return SendClientMessage(playerid, COLOR_RED, "You haven't got a shovel!!");
}
else return SendClientMessage(playerid, COLOR_RED, "You cannot dig here!");
return 1;
}
public FishCatchTimer(playerid)
{
Fishing[playerid] = 0;
switch(random(13))
{
case 0:
{
if(Fish[playerid][1] < 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You have caught a 41 pound catfish!");
Fish[playerid][4] = 41;
}
else if(Fish[playerid][2] < 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You have caught a 41 pound catfish!");
Fish[playerid][4] = 41;
}
else if(Fish[playerid][3] < 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You have caught a 41 pound catfish!");
Fish[playerid][4] = 41;
}
else if(Fish[playerid][4] < 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You have caught a 41 pound catfish!");
Fish[playerid][4] = 41;
}
else return 1;
}
case 1:
{
if(Fish[playerid][1] < 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You have caught a mammoth whale! It weighs 12552 pound!");
Fish[playerid][1] = 12552;
}
else if(Fish[playerid][2] < 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You have caught a mammoth whale! It weighs 12552 pound!");
Fish[playerid][2] = 12552;
}
else if(Fish[playerid][3] < 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You have caught a mammoth whale! It weighs 12552 pound!");
Fish[playerid][3] = 12552;
}
else if(Fish[playerid][4] < 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You have caught a mammoth whale! It weighs 12552 pound!");
Fish[playerid][4] = 12552;
}
else return 1;
}
case 2:
{
if(Fish[playerid][1] < 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You have caught a Haydz Fish! It weighs 1337 pound!");
Fish[playerid][1] = 1337;
}
else if(Fish[playerid][2] < 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You have caught a Haydz Fish! It weighs 1337 pound!");
Fish[playerid][2] = 1337;
}
else if(Fish[playerid][3] < 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You have caught a Haydz Fish! It weighs 1337 pound!");
Fish[playerid][3] = 1337;
}
else if(Fish[playerid][4] < 1)
{
SendClientMessage(playerid, COLOR_GREEN, "You have caught a Haydz Fish! It weighs 1337 pound!");
Fish[playerid][4] = 1337;
}
}
case 3:
{
SendClientMessage(playerid, COLOR_RED, "You have caught a tin-can and threw it away.");
GameTextForPlayer(playerid, "~r~Can thrown away.", 3000, 5);
}
case 4:
{
SendClientMessage(playerid, COLOR_RED, "You have caught a Nuclear Bomb. OH NO!");
GameTextForPlayer(playerid, "~r~The Bomb Exploded!.", 3000, 5);
SetPlayerHealth(playerid, 0);
}
case 5:
{
SendClientMessage(playerid, COLOR_RED, "You have caught a used tyre and threw it away.");
GameTextForPlayer(playerid, "~r~Used tyre thrown away.", 3000, 5);
}
case 6:
{
SendClientMessage(playerid, COLOR_YELLOW, "You have found some pirate treasure!");
GameTextForPlayer(playerid, "~G~KA-CHING.", 3000, 5);
GivePlayerMoney(playerid, 22500);
}
case 7:
{
SendClientMessage(playerid, COLOR_RED, "You have found a used condomn. Eww!");
GameTextForPlayer(playerid, "~r~Used Condomn Thrown Away.", 3000, 5);
}
case 8:
{
SendClientMessage(playerid, COLOR_RED, "You were attacked by a crab!");
GameTextForPlayer(playerid, "~r~Attacked By A Crab.", 3000, 5);
SetPlayerHealth(playerid, 50);
}
case 9:
{
SendClientMessage(playerid, COLOR_WHITE, "You have found nothing!");
}
case 10:
{
SendClientMessage(playerid, COLOR_RED, "OH NO, Greenpeace stole your fish!");
GameTextForPlayer(playerid, "~r~Fish Stolen.", 3000, 5);
Fish[playerid][1] = 0;
Fish[playerid][2] = 0;
Fish[playerid][3] = 0;
Fish[playerid][4] = 0;
}
case 11:
{
SendClientMessage(playerid, COLOR_RED, "You Were Attacked By Jaws!");
GameTextForPlayer(playerid, "~r~Jaws Attacked You!.", 3000, 5);
SetPlayerHealth(playerid, 0);
}
case 12:
{
SendClientMessage(playerid, COLOR_RED, "The Fish Got Away");
GameTextForPlayer(playerid, "~r~You lost the fish.", 3000, 5);
}
}
return 1;
}
command(fish, playerid, params[])
{
//old coords -2105.3228, -124.2982, 37.2531
if(IsPlayerInRangeOfPoint(playerid, 100.0, 0, 0, 0))
{
if(Fishing[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "You are already fishing!");
if(Fish[playerid][1] >= 1 && Fish[playerid][2] >= 1 && Fish[playerid][3] >= 1 && Fish[playerid][4] >= 1) return SendClientMessage(playerid, COLOR_WHITE, "You have too many fish to fish again.");
if(HasRod[playerid] == 1)
{
if(HasBait[playerid] == 1)
{
Fishing[playerid] = 1;
SendClientMessage(playerid, COLOR_WHITE, "You have started to fish. Please wait 5 seconds.");
SetTimerEx("FishCatchTimer", 5000, false, "i", playerid);
}
else return SendClientMessage(playerid, COLOR_RED, "You don't have any bait!");
}
else return SendClientMessage(playerid, COLOR_RED, "You haven't got a fishing rod!");
}
else return SendClientMessage(playerid, COLOR_RED, "You cannot fish here!");
return 1;
}
command(buy, playerid, params[])
{
if(IsPlayerInRangeOfPoint(playerid, 100.0, 0, 0, 0))
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Shop", "Fishing Rod ($2000)\nFishing Bait($250 Each)\nShovel($2000)", "Buy", "Cancel");
}
else SendClientMessage(playerid, COLOR_RED, "You Are Not In A Shop");
return 1;
}
command(sellfish, playerid, params[])
{
if(IsPlayerInRangeOfPoint(playerid, 100.0, 0, 0, 0))
{
new fishslot, string[256];
if(sscanf(params, "i", fishslot)) return SendClientMessage(playerid, COLOR_WHITE, "Server: /sell [fish slot(1-4)]");
{
if(fishslot > 4 || fishslot < 1) return SendClientMessage(playerid, COLOR_WHITE, "Fish slots are from 1 - 4.");
else
{
if(Fish[playerid][fishslot] > 1)
{
GivePlayerMoney(playerid, Fish[playerid][fishslot] * 2);
format(string, sizeof(string), "You have sold a fish out of slot %d for $%d!", fishslot, Fish[playerid][fishslot] * 2);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "~g~+$%d", Fish[playerid][fishslot] * 2);
GameTextForPlayer(playerid, string, 3000, 5);
}
}
}
}
else SendClientMessage(playerid, COLOR_RED, "You Are Not In A Shop");
return 1;
}
command(sellrock, playerid, params[])
{
new rockslot, string[256];
if(sscanf(params, "i", rockslot)) return SendClientMessage(playerid, COLOR_WHITE, "Server: /sell [rock slot(1-4)]");
{
if(rockslot > 4 || rockslot < 1) return SendClientMessage(playerid, COLOR_WHITE, "Rock slots are from 1 - 4.");
else
{
if(Rock[playerid][rockslot] > 1)
{
GivePlayerMoney(playerid, Rock[playerid][rockslot] * 2);
format(string, sizeof(string), "You have sold a rock out of slot %d for $%d!", rockslot, Rock[playerid][rockslot] * 2);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "~g~+$%d", Rock[playerid][rockslot] * 2);
GameTextForPlayer(playerid, string, 3000, 5);
}
}
}
return 1;
}