22.02.2013, 01:06
I made a system that makes a dynamic cp in game with text and pickup.
This is how it loads:
As you can see the 'total+1' I made this because DynamicCP begins to count from 1 not 0.
That's my EnterDynamicCP:
My question is: How can I prevent collision with other dynamic CP's.
This is how it loads:
As you can see the 'total+1' I made this because DynamicCP begins to count from 1 not 0.
Код:
public LoadDynamicCPT() { new rows, fields, str[256]; new total = 0; cache_get_data(rows, fields); if(rows) { while(total < rows) { new temp[12]; cache_get_row(total, 0, temp), CPTInfo[total+1][cID] = strval(temp); cache_get_row(total, 1, temp), CPTInfo[total+1][cPosX] = floatstr(temp); cache_get_row(total, 2, temp), CPTInfo[total+1][cPosY] = floatstr(temp); cache_get_row(total, 3, temp), CPTInfo[total+1][cPosZ] = floatstr(temp); cache_get_row(total, 4, CPTInfo[total+1][cLabelText]); cache_get_row(total, 5, CPTInfo[total+1][cCPInfo]); CPTInfo[total+1][cInfoOn] = 1; format(str, sizeof(str), ""EMBED_GREEN"["EMBED_RED"Info"EMBED_GREEN"]\n"EMBED_WHITE"%s.", CPTInfo[total+1][cLabelText]); CPTInfo[total+1][cLabel] = CreateDynamic3DTextLabel(str, -1, CPTInfo[total+1][cPosX], CPTInfo[total+1][cPosY], CPTInfo[total+1][cPosZ], 20.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0); CPTInfo[total+1][cPickUp] = CreateDynamicPickup(1239, 1, CPTInfo[total+1][cPosX], CPTInfo[total+1][cPosY], CPTInfo[total+1][cPosZ], -1, -1, -1, 100.0); CPTInfo[total+1][cCheckPoint] = CreateDynamicCP(CPTInfo[total+1][cPosX], CPTInfo[total+1][cPosY], CPTInfo[total+1][cPosZ], 1.0, -1, -1, -1, 100.0); total++; } } format(str,sizeof(str), "Loaded %d dynamic infos from MySQL.", total); printf(str); return 1; }
Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid) { new str[256]; if(CPTInfo[checkpointid][cInfoOn] == 1) { format(str, sizeof(str), "%s", CPTInfo[checkpointid][cCPInfo]); SCM(playerid, -1, str); } return 1; }