PDA

View Full Version : Race Postion Ingame (Rep +2)


sameer419
19/01/2012, 12:18 PM
Hello everyone! i am currently working on race gm, and my aim is to make like this..:
Screen taken from Adrenaline (Racing)
http://i44.tinypic.com/qofw5x.jpg

The position which i am, ex:1 ,2, 3
Need help in that, rep ++ for best ans.


// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
new gTotalRacers;
new Text:MPlayers[MAX_PLAYERS];
new Text:RPos;
new PCar1;
new PCar2;
new PCar3;
new PCar4;
new PCar5;
new Racer[MAX_PLAYERS];

main()
{
print("\n----------------------------------");
print(" Race GameMode");
print("----------------------------------\n");
}

public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
SetGameModeText("Race");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);

RPos = TextDrawCreate(534.000000, 335.000000, "0");
TextDrawBackgroundColor(RPos, 255);
TextDrawFont(RPos, 1);
TextDrawLetterSize(RPos, 0.529999, 3.799998);
TextDrawColor(RPos, -470031446);
TextDrawSetOutline(RPos, 1);
TextDrawSetProportional(RPos, 1);

PCar1 = AddStaticVehicleEx(596,825.70001221,-1981.80004883,12.69999981,0.00000000,-1,-1,999999); //Police Car (LSPD)
PCar2 = AddStaticVehicleEx(596,830.00000000,-1981.69995117,12.69999981,0.00000000,-1,-1,999999); //Police Car (LSPD)
PCar3 = AddStaticVehicleEx(596,834.50000000,-1981.69995117,12.69999981,0.00000000,-1,-1,999999); //Police Car (LSPD)
PCar4 = AddStaticVehicleEx(596,839.59997559,-1981.50000000,12.69999981,0.00000000,-1,-1,999999); //Police Car (LSPD)
PCar5 = AddStaticVehicleEx(596,844.40002441,-1981.40002441,12.69999981,0.00000000,-1,-1,999999); //Police Car (LSPD)

for(new playerid; playerid < MAX_PLAYERS; playerid++)
{
MPlayers[playerid] = TextDrawCreate(551.000000, 358.000000, " /32");
TextDrawAlignment(MPlayers[playerid], 2);
TextDrawBackgroundColor(MPlayers[playerid], 255);
TextDrawFont(MPlayers[playerid], 1);
TextDrawLetterSize(MPlayers[playerid], 0.440000, 1.300000);
TextDrawColor(MPlayers[playerid], -1);
TextDrawSetOutline(MPlayers[playerid], 0);
TextDrawSetProportional(MPlayers[playerid], 1);
TextDrawSetShadow(MPlayers[playerid], 1);
}
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)
{
gTotalRacers++;
new tmp[5];
format(tmp,5,"/%d",gTotalRacers);
TextDrawSetString(MPlayers[playerid],tmp);
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
gTotalRacers--;
new tmp[5];
format(tmp,5,"/%d",gTotalRacers);
TextDrawSetString(MPlayers[playerid],tmp);
return 1;
}

public OnPlayerSpawn(playerid)
{
TextDrawShowForPlayer(playerid, MPlayers[playerid]);
TextDrawShowForPlayer(playerid, RPos);
SetPlayerRaceCheckpoint(playerid, 0,835.374389,-1859.481933,12.587397,812.102172,-1774.344116,13.203566,10);
Racer[playerid] = 1;
if(playerid == 0)
{
PutPlayerInVehicle(playerid,PCar1, 0);
}
else if(playerid == 1)
{
PutPlayerInVehicle(playerid,PCar2, 0);
}
else if(playerid == 2)
{
PutPlayerInVehicle(playerid,PCar3, 0);
}
else if(playerid == 3)
{
PutPlayerInVehicle(playerid,PCar4, 0);
}
else if(playerid == 4)
{
PutPlayerInVehicle(playerid,PCar5, 0);
}
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
switch(Racer[playerid])
{
case 1:
{
DisablePlayerRaceCheckpoint(playerid);
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
SetPlayerRaceCheckpoint(playerid, 0,812.102172,-1774.344116,13.203566,813.857421,-1645.215332,13.103794,10);
Racer[playerid] = 2;
return 1;
}
case 2:
{
DisablePlayerRaceCheckpoint(playerid);
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
SetPlayerRaceCheckpoint(playerid, 0,813.857421,-1645.215332,13.103794,879.339782,-1575.621704,13.099643,10);
Racer[playerid] = 3;
return 1;
}
case 3:
{
DisablePlayerRaceCheckpoint(playerid);
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
SetPlayerRaceCheckpoint(playerid, 0,879.339782,-1575.621704,13.099643,1036.568481,-1572.104003,13.110089,10);
Racer[playerid] = 4;
return 1;
}
case 4:
{
DisablePlayerRaceCheckpoint(playerid);
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
SetPlayerRaceCheckpoint(playerid, 0,1036.568481,-1572.104003,13.110089,1288.525878,-1569.905395,13.107045,10);
Racer[playerid] = 5;
return 1;
}
case 5:
{
DisablePlayerRaceCheckpoint(playerid);
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
SetPlayerRaceCheckpoint(playerid, 0,1288.525878,-1569.905395,13.107045,1310.379760,-1548.127563,13.188509,10);
Racer[playerid] = 6;
return 1;
}
}
return 1;
}

Min
19/01/2012, 12:29 PM
k, I join this question. I was searching for this 'function' a long time ago, and found nothing. :|

Vince
19/01/2012, 12:56 PM
Ok, let me put this out in pseudo code:


new racepos[MAX_PLAYERS];

Max player loop
if (current player checkpoint > current idx checkpoint) && racepos player != 1
racepos playerid --
else if current player checkpoint < current idx checkpoint
racepos playerid ++
else
get pos of the active checkpoint
get distance of player to checkpoint
get distance of idx to checkpoint

if (distance player < distance idx) && racepos player != 1
racepos player --
else
racepos player ++

sameer419
19/01/2012, 01:04 PM
Ok, let me put this out in pseudo code:


new racepos[MAX_PLAYERS];

Max player loop
if (current player checkpoint > current idx checkpoint) && racepos player != 1
racepos playerid --
else if current player checkpoint < current idx checkpoint
racepos playerid ++
else
get pos of the active checkpoint
get distance of player to checkpoint
get distance of idx to checkpoint

if (distance player < distance idx) && racepos player != 1
racepos player --
else
racepos player ++


pseudo code ??
i m working on pawn code, can u make that in pawn code??

Vince
19/01/2012, 01:07 PM
Pseudocode (sometimes written as pseudo-code) is a form of source code that is written for humans, not machines, to read. It is often written to show how an algorithm works.

It's up to you to make it, I'm not your slave.

sameer419
19/01/2012, 01:12 PM
ohh thanks i know that you are not slave :P lol
how to get distance of player??

sameer419
19/01/2012, 01:29 PM
Vince, you should release this script, a ton of scripters were trying to script this thing and most of them failed. SHARE THE SCRIPT, PLZZZZZZZZZZZZZZZZZZ

sameer419
19/01/2012, 02:44 PM
@***** i didnt understand, can you code me how to set the inrace positons of players via textdraw...

milanosie
19/01/2012, 02:47 PM
Sameer.. just read their tips, then read samp wiki and put some effort in it.

sameer419
19/01/2012, 03:01 PM
actually where are the tips??
i didnt find any..

Stigg
19/01/2012, 04:09 PM
There is some good examples of what you need in these filterscripts:

http://forum.sa-mp.com/showthread.php?t=5236&highlight=Adrenaline+%28Racing%29+switch

http://forum.sa-mp.com/showthread.php?t=143764&highlight=rRace

Look at the race checkpoint processing code.

Konstantinos
19/01/2012, 04:26 PM
I suggest you to learn to search!
From there you got the screen, check how he use it
SetRaceText(playerid, pos)
{

//HideAllRaceText(playerid);
new append[5];
switch (pos)
{
case 1,21,31,41,51,61,71,81,91: format(append, sizeof(append), "ST");
case 2,22,32,42,52,62,72,82,92: format(append, sizeof(append), "ND");
case 3,23,33,43,53,63,73,83,93: format(append, sizeof(append), "RD");
default: format(append, sizeof(append), "TH");
}
new tmp[5];
format(tmp,5,"%d", pos);
TextDrawSetString(Tposition[playerid],tmp);
TextDrawSetString(Tappend[playerid],append);

return 1;
}

sameer419
19/01/2012, 06:15 PM
@Stigg i already did what you said, but he did on dynamic race fs, and i m on static race fs,

@Dwane already tried that, didnt worked..scroll up and see this lines

RaceCheckpoints[gPlayerProgress[playerid]][3]++;
gRacePosition[playerid]=floatround(RaceCheckpoints[gPlayerProgress[playerid]][3],floatround_floor);
SetRaceText(playerid, gRacePosition[playerid]); //Set the race textdraws

sameer419
19/01/2012, 08:08 PM
anyone knows how to do this??