SA-MP Forums Archive
RP Deliver patiant Problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: RP Deliver patiant Problem (/showthread.php?tid=592996)



RP Deliver patiant Problem - eclipses - 31.10.2015

Having some problem with /deliverpt at point, it says "You are not near a deliver point - look out near the hospitals"
And i've added coords and text and createpickup, why dosent it work? :/

Here is the codes that i'm trying to make work

Код:
						else if(IsPlayerInRangeOfPoint(playerid, 5.0,1567.3102,-2167.7603,13.9169) || IsPlayerInRangeOfPoint(playerid, 5.0, 1567.3102,-2167.7603,13.9169))
						{
							SetPlayerVirtualWorld(giveplayerid, 4);
							PlayerInfo[giveplayerid][pVW] = 4;
						}
And here is the "Createpickup" and "CreateDynamic3dTextLabel"

Код:
	CreatePickup(1240, 23, 1567.3102,-2167.7603,13.9169, -1);
Код:
	CreateDynamic3DTextLabel("/deliverpt",COLOR_LIGHTRED,1567.3102,-2167.7603,13.9169+0.6,4.0);
Full command "deliverpt"

Код:
CMD:deliverpt(playerid, params[])
{
	if(gTeam[playerid] == TEAM_CYAN||PlayerInfo[playerid][pMember]==4||PlayerInfo[playerid][pLeader]==4 || (PlayerInfo[playerid][pMember] == 12 && PlayerInfo[playerid][pDivision] == 3))
	{
		if(IsPlayerInAnyVehicle(playerid))
		{
			new string[128], giveplayerid;
			if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /deliverpt [playerid]");

			new carid = GetPlayerVehicleID(playerid);
			new caridex = GetPlayerVehicleID(giveplayerid);
			if(IsAnAmbulance(carid) || IsATierraESCar(carid))
			{
				if(carid == caridex)
				{
					if(IsAtDeliverPatientPoint(playerid))
					{
						if(playerid == giveplayerid)
						{
							SendClientMessageEx(playerid, COLOR_GRAD2, "You cannot deliver yourself to the hospital!");
							return 1;
						}
						if(GetPVarInt(giveplayerid, "Injured") == 0)
						{
							return SendClientMessageEx(playerid, COLOR_GRAD2, "That player is not injured!");
						}
						if(playerTabbed[giveplayerid] == 1)
						{
							SendClientMessageEx(playerid, COLOR_GRAD2, "That player is paused, you can't currently deliver him!");
							return 1;
						}
						SetPlayerHealth(giveplayerid, 100);
						if(STDPlayer[giveplayerid] > 0)
						{
							STDPlayer[giveplayerid] = 0;
							SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, "* You are no longer infected with a STD anymore because of the hospital's help!");
						}
						GivePlayerCash(giveplayerid, -1000);
						Tax += 1000;
						GivePlayerCash(playerid,2500);
						KillEMSQueue(giveplayerid);
						SetPVarInt(giveplayerid, "MedicBill", 0);
						SendClientMessageEx(giveplayerid, TEAM_CYAN_COLOR, "Doc: Your medical bill comes in at $1000. Have a nice day!");
						format(string,sizeof(string),"You received $2500 for successfully delivering the patient!");
						SendClientMessageEx(playerid, TEAM_CYAN_COLOR, string);
						SetPlayerPos(giveplayerid, 1169.7588,-1351.5490,2423.0461);
						Streamer_UpdateEx(giveplayerid, 1169.7588,-1351.5490,2423.0461);
						SetPlayerInterior(giveplayerid, 1);
						PlayerInfo[giveplayerid][pInt] = 1;
						TogglePlayerControllable(giveplayerid, 0);
						GameTextForPlayer(giveplayerid, "Objects loading...", 4000, 5);
						SetPVarInt(giveplayerid, "LoadingObjects", 1);
						SetTimerEx("SafeLoadObjects", 4000, 0, "d", giveplayerid);
						PlayerInfo[playerid][pPatientsDelivered]++;
						format(string, sizeof(string), "EMS Driver %s has successfully delivered Patient %s to the hospital.",GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
						SendRadioMessage(4, TEAM_MED_COLOR, string);
						new Float:X, Float:Y, Float:Z;
						GetObjectPos(Carrier[0], X, Y, Z);
						if(IsPlayerInRangeOfPoint(playerid, 5.0,1142.4733,-1326.3633,13.6259) || IsPlayerInRangeOfPoint(playerid, 5.0, 1165.1564,-1368.8240,26.6502))
						{
							SetPlayerVirtualWorld(giveplayerid, 2);
							PlayerInfo[giveplayerid][pVW] = 2;
						}
						else if(IsPlayerInRangeOfPoint(playerid, 5.0,2027.0599,-1410.6870,16.9922) || IsPlayerInRangeOfPoint(playerid, 5.0, 2024.5742,-1382.7844,48.3359))
						{
							SetPlayerVirtualWorld(giveplayerid, 1);
							PlayerInfo[giveplayerid][pVW] = 1;
						}
						else if(IsPlayerInRangeOfPoint(playerid, 5.0,1227.2339,306.4730,19.7028) || IsPlayerInRangeOfPoint(playerid, 5.0, 1233.3384,316.4022,24.7578))
						{
							SetPlayerVirtualWorld(giveplayerid, 5);
							PlayerInfo[giveplayerid][pVW] = 5;
						}
						else if(IsPlayerInRangeOfPoint(playerid, 5.0,1567.3102,-2167.7603,13.9169) || IsPlayerInRangeOfPoint(playerid, 5.0, 1567.3102,-2167.7603,13.9169))
						{
							SetPlayerVirtualWorld(giveplayerid, 4);
							PlayerInfo[giveplayerid][pVW] = 4;
						}
						else if(IsPlayerInRangeOfPoint(playerid, 5.0,-2695.5725,639.4147,14.4531) || IsPlayerInRangeOfPoint(playerid, 5.0, -2656.0339,615.2567,66.0938))
						{
							SetPlayerVirtualWorld(giveplayerid, 6);
							PlayerInfo[giveplayerid][pVW] = 6;
						}
						else if(IsPlayerInRangeOfPoint(playerid, 250,X, Y, Z))
						{
							SetPlayerVirtualWorld(giveplayerid, 7);
							PlayerInfo[giveplayerid][pVW] = 7;
						}
						else if(IsPlayerInRangeOfPoint(playerid, 5.0,-1528.814331, 2540.706054, 55.835937))
						{
							SetPlayerVirtualWorld(giveplayerid, 99);
							PlayerInfo[giveplayerid][pVW] = 99;
						}
					}
					else
					{
						SendClientMessageEx(playerid, COLOR_GRAD2, "You are not near a deliver point - look out near the hospitals.");
					}
				}
				else
				{
					SendClientMessageEx(playerid, COLOR_GRAD2, "Patient must be in your car in order to deliver him.");
				}
			}
			else
			{
				SendClientMessageEx(playerid, COLOR_GRAD2, "You are not in an FDSA vehicle.");
			}
		}
	}
	return 1;
}



Re: RP Deliver patiant Problem - Vince - 31.10.2015

How to dissect code, for beginners. Step 1: locate the message that gets sent. Step 2: locate the corresponding if-else block.

PHP код:
if(IsAtDeliverPatientPoint(playerid))
{
    
// not important what's in here because it doesn't get executed, anway
}
else
{
    
SendClientMessageEx(playeridCOLOR_GRAD2"You are not near a deliver point - look out near the hospitals.");

Step 3: interpret logic. Clearly, IsAtDeliverPatientPoint is returning false or 0 which causes the "else" branch to execute. Step 4: deduction. The problem is with the function IsAtDeliverPatientPoint.


Re: RP Deliver patiant Problem - eclipses - 31.10.2015

Quote:
Originally Posted by Vince
Посмотреть сообщение
How to dissect code, for beginners. Step 1: locate the message that gets sent. Step 2: locate the corresponding if-else block.

PHP код:
if(IsAtDeliverPatientPoint(playerid))
{
    
// not important what's in here because it doesn't get executed, anway
}
else
{
    
SendClientMessageEx(playeridCOLOR_GRAD2"You are not near a deliver point - look out near the hospitals.");

Step 3: interpret logic. Clearly, IsAtDeliverPatientPoint is returning false or 0 which causes the "else" branch to execute. Step 4: deduction. The problem is with the function IsAtDeliverPatientPoint.
Thanks, i'll check in to it, otherwise i'll come back for more assistance