All pastes #629317 Raw Edit

help for checkpoint troubles

public text v1 · immutable
·published 2007-07-22 04:00 UTC
rendered paste body
//These are the parts of the script you may need to look at


//These are the commands i used to collect the Coords and change them ingame... for references sake //so you know its not my commands fault... you can use the comands in your own scripts if you wish

if (strcmp(cmd, "/savecp", true)==0) {
	tmp = strtok(cmdtext,idx);
	if (!strlen(tmp)) {
	    SendClientMessage(playerid,COLOR_RED,"Needs a name");
	    return 1;
	}
        new Float:x,Float:y,Float:z;
	GetPlayerPos(playerid, x, y, z);
	format(string,sizeof(string),"Positions:%f,%f,%f",x,y,z);
	SendClientMessage(playerid,COLOR_GREY,string);
	if (!dini_Exists(udb_encode("PROP_POS"))) {
	    dini_Create(udb_encode("PROP_POS"));
	}
	dini_Set(udb_encode("PROP_POS"),string,tmp);
	SendClientMessage(playerid,COLOR_GREEN,"CP Saved");
	return 1;
}
if (strcmp(cmd, "/changecp", true)==0) {
    new Float:x,Float:y,Float:z;
	GetPlayerPos(playerid, x, y, z);
	tmp = strtok(cmdtext,idx);
	new val = strval(tmp);
	CheckPoints[val][0] = x;
	CheckPoints[val][1] = y;
	CheckPoints[val][2] = z;
	SendClientMessage(playerid,COLOR_GREEN,"Checkpoint created");
	return 1;
}

//--------------------------------------------------------------------------------------
// now for the timer that handles to cp stuff and the PropDistance Function that i made
//--------------------------------------------------------------------------------------

public UpdateCP() {
	new a=0;
	for(new i=0; i<MAX_PROPS; i++) {
	    for(new o=0; o<MAX_PLAYERS; o++) {
	        if (IsPlayerConnected(o)) {
		     if (PropDistance(i,o)< 20) {
			 DisablePlayerCheckpoint(o);
	                        SetPlayerCheckpoint(o,Float:CheckPoints[i][0],Float:CheckPoints[i][1],Float:CheckPoints[i][2],3);
			a++;
	             }
		}
		if (a==0) {
	    	      DisablePlayerCheckpoint(o);
 	        }
	    }
	}
}

Float:PropDistance(i,o) {
	new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
	GetPlayerPos(o,x1,y1,z1);
 	x2 = CheckPoints[i][0];
 	y2 = CheckPoints[i][1];
 	z2 = CheckPoints[i][2];
	return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}

//-------------------------------
//Finally the checkpoin co'ords
//-------------------------------

#define MAX_PROPS 67

new Float:CheckPoints[MAX_PROPS][3] = {
(2181.832763,1116.188598,12.246953),
(2236.303222,1285.402465,10.415165),
(2200.922607,1391.104003,10.405926),
(2089.277587,1450.600952,10.418743),
(2012.658325,1165.629760,10.414234),
(1993.189086,1017.915100,994.890625),
(2001.739624,1544.387939,13.182739),
(2235.756835,1677.172363,1008.359375),
(1970.743652,1623.410156,12.860788),
(2222.900390,1838.037597,10.403603),
(2028.776733,1916.832031,11.906086),
(2469.870849,1960.718505,10.302840),
(2368.677734,1983.810302,10.411641),
(2368.065917,2122.709228,10.424820),
(2371.579101,2166.109375,10.422879),
(2510.496826,2121.873535,10.432173),
(2500.251953,2241.259033,10.418126),
(2620.851806,2343.844238,10.412732),
(2368.024658,2322.352539,7.733417),
(230.825469,161.896072,1003.023437),//20-Venturas PD
(2124.659179,2366.072998,10.413705),
(774.007629,-72.285552,1000.648437),
(774.007629,-72.285552,1000.648437),
(1938.599731,2405.134277,10.417898),
(2386.555908,2467.477539,10.412192),
(2446.124755,2375.970947,11.760129),
(207.725921,-104.225250,1005.257812),
(364.809295,-6.323143,1001.851562),
(161.362350,-88.095672,1001.804687),
(368.042541,-119.596961,1001.492187),
(2108.808349,2170.074951,10.407282),
(-103.653350,-21.346416,1000.718750),
(-202.633880,-41.973049,1002.273437),
(418.371337,-80.624580,1001.804687),
(1944.313598,2069.294921,10.416982),
(373.166198,-65.900039,1001.507812),
(1774.429809,2066.405029,10.416990),
(1694.327392,2205.461914,10.473646),
(1658.677734,2196.330810,10.410462),
(1939.557250,2184.565429,10.417020),//40-Venturas Pay-n-Spray
(1479.245849,2249.302001,10.621255),
(1434.317749,2619.748291,10.987221),
(2493.271972,2772.949951,10.400426),
(2515.828369,2033.398559,10.411191),
(289.838806,-83.991195,1001.515625),
(2519.660644,2334.616210,10.820312),
(2490.694824,2063.489013,10.413472),
(503.343322,-74.321075,998.765075),
(2622.187011,1824.542236,10.604866),
(2446.773925,1662.772094,10.419054),
(2511.445800,1244.656860,10.820312),
(2575.382080,1058.998046,10.411310),
(357.754608,173.794647,1008.384094),
(1716.469604,1261.894287,10.412559),
(1687.902465,1433.853149,10.360718),
(1599.780151,1817.480712,10.417121),
(1094.908447,1602.250488,12.139533),
(1136.557617,1366.825073,10.384091),
(1088.820190,1074.272094,10.392851),
(818.426635,854.031860,10.899397),//60-Venturas Hunter Quarry
(291.009735,1403.586181,9.859109),
(698.253540,1948.578002,5.103334),
(2908.529052,2475.842529,10.627732),
(2862.706542,2429.598876,10.633043),
(204.381561,-127.456466,1003.507812),
(224.339050,-11.396966,1002.210937),
(203.617416,-40.450767,1001.804687)//67-Venturas Sub-Urban
};