Created
November 9, 2014 10:51
-
-
Save dennorske/f9fad51993361325038a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
new cp[2]; | |
new Float:checkpoint[1][4]= //start checkpoint for the positions | |
{ | |
{1004.9775,2141.5452,10.3123,183.2651} //first in meat factory | |
}; | |
new indexRace; //to increase the startPosition | |
CMD:testrace(playerid, params[]) | |
{ | |
SendClientMessage(playerid, green, "Test for Meat Factory race, CAR: Sultan"); | |
cp[0] = CreateDynamicRaceCP(0,1004.9775,2141.5452,10.3123,1005.6807,2093.2520,10.3124 ,5, -1, -1, -1, 600.0); | |
cp[1] = CreateDynamicRaceCP(0,1005.6807,2093.2520,10.3124,1018.2676,2051.8679,10.3229 ,5, -1, -1, -1, 600.0); | |
GetXYForRacer(checkpoint[0][0], checkpoint[0][1], checkpoint[0][3], indexRace+1); | |
SetPlayerPos(playerid, checkpoint[0][0], checkpoint[0][1], checkpoint[0][2]+1); | |
SetPlayerFacingAngle(playerid, checkpoint[0][3]); | |
if(indexRace == 20) | |
indexRace = -1; | |
indexRace ++; | |
return 1; | |
} | |
//startPosition: | |
//1 2 3 | |
//4 5 6 | |
//7 8 9 | |
//... | |
stock GetXYForRacer(&Float:x, &Float:y, Float:a, startPosition) | |
{ | |
//x and y should contain the start checkpoint location, a should be the angle of the cars | |
new raceSpawnOffsets[2]; | |
if(((startPosition+1) % 3) == 0) | |
{ //Middle | |
GetXYAtAngleFromPos(raceSpawnOffsets[0], raceSpawnOffsets[1], a-180.00, 5.0); | |
x += raceSpawnOffsets[0] * (((startPosition-1)/3)+1); | |
y += raceSpawnOffsets[1] * (((startPosition-1)/3)+1); | |
} | |
else | |
{ //Sides | |
GetXYAtAngleFromPos(raceSpawnOffsets[0], raceSpawnOffsets[1], originalAngle+90.00, 3.0); | |
if((startPosition % 3) == 0) | |
{ //Right side | |
x += raceSpawnOffsets[0]; | |
y += raceSpawnOffsets[1]; | |
} | |
else | |
{ //Left Side | |
x -= raceSpawnOffsets[0]; | |
y -= raceSpawnOffsets[1]; | |
} | |
} | |
} | |
stock GetXYAtAngleFromPos(&Float:x, &Float:y, Float:a, Float:distance) | |
{ | |
x += (distance * floatsin(-a, degrees)); | |
y += (distance * floatcos(-a, degrees)); | |
} | |
public OnPlayerEnterDynamicRaceCP(playerid, checkpointid) | |
{ | |
SendClientMessage(playerid,-1, "Remember the heading and the surroundings when placing the first time!"); | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment