Few questions. -
okil - 02.01.2013
#1. How do I make so a specific vehicle respawns on player exit it?
#2. How do I make so 4 random checkpoints spawn one by one but only on fourth checkpoint the race stops? Like I get 4 coords and they should go one by one randomly.
Re: Few questions. -
Threshold - 02.01.2013
#1
https://sampwiki.blast.hk/wiki/OnPlayerExitVehicle
https://sampwiki.blast.hk/wiki/SetVehicleToRespawn
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(vehicleid == specificvehicle) //Replace this with your vehicle variable
{
SetVehicleToRespawn(vehicleid);
}
return 1;
}
EDIT:
#2
https://sampwiki.blast.hk/wiki/SetPlayerRaceCheckpoint
https://sampwiki.blast.hk/wiki/OnPlayerEnterRaceCheckpoint
pawn Код:
new Checkpointcount[MAX_PLAYERS]; //At the top of your script
new CheckNext[MAX_PLAYERS];
new Checks[MAX_CHECKPOINTS][3] = {
{x1, y1, z1},
{x2, y2, z2},
{x3, y3, z3},
//etc...
{x24, y24, z24}
};
public OnPlayerConnect(playerid)
{
Checkpointcount[playerid] = 0;
CheckNext[playerid] = -1;
return 1;
}
CMD:beginrace(playerid, params[])
{
if(Checkpointcount[playerid] > 0) return SendClientMessage(playerid, 0xFF0000FF, "You are already racing! Use /stoprace to end it.");
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, 0xFF0000FF, "You must be the driver of a vehicle to begin the race.");
Checkpointcount[playerid] = 1;
new rand = random(sizeof(Checks));
new rand2 = random(sizeof(Checks));
SetPlayerRaceCheckpoint(playerid, 0, Checks[rand][0], Checks[rand][1], Checks[rand][2], Checks[rand2][0], Checks[rand2][1], Checks[rand2][2], 5.0);
CheckNext[playerid] = rand2;
SendClientMessage(playerid, 0xFFFF00FF, "The race has begun!");
return 1;
}
CMD:stoprace(playerid, params[])
{
if(Checkpointcount[playerid] == 0) return SendClientMessage(playerid, 0xFF0000FF, "You are not racing! Type /beginrace to start.");
DisablePlayerRaceCheckpoint(playerid);
Checkpointcount[playerid] = 0;
CheckNext[playerid] = -1;
SendClientMessage(playerid, 0xFFFF00FF, "You are no longer racing.");
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
if(Checkpointcount[playerid] >= 4)
{
DisablePlayerRaceCheckpoint(playerid);
SendClientMessage(playerid, 0xFFFF00FF, "You have finished the race!");
//Give reward here, optional.
Checkpointcount[playerid] = 0;
return 1;
}
if(Checkpointcount[playerid] > 0 && Checkpointcount[playerid] < 3)
{
new rand = random(sizeof(Checks));
DisablePlayerRaceCheckpoint(playerid);
SetPlayerRaceCheckpoint(playerid, 0, Checks[CheckNext[playerid]][0], Checks[CheckNext[playerid]][1], Checks[CheckNext[playerid]][2], Checks[rand][0], Checks[rand][1], Checks[rand][2], 5.0);
Checkpointcount[playerid]++;
CheckNext[playerid] = rand;
return 1;
}
if(Checkpointcount[playerid] == 3)
{
DisablePlayerRaceCheckpoint(playerid);
SetPlayerRaceCheckpoint(playerid, 1, Checks[CheckNext[playerid]][0], Checks[CheckNext[playerid]][1], Checks[CheckNext[playerid]][2], 0.0, 0.0, 0.0, 5.0);
Checkpointcount[playerid]++;
CheckNext[playerid] = -1;
return 1;
}
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(Checkpointcount[playerid] > 0)
{
Checkpointcount[playerid] = 0;
CheckNext[playerid] = -1;
SendClientMessage(playerid, 0xFF0000FF, "You have left your vehicle and the race has ended!");
DisablePlayerRaceCheckpoint(playerid);
}
return 1;
}
This took me a really long time to make, because I had to do it in the quick reply box, so if there is any errors, I apologise, but other than changing the 'x1, y1, z1', 'x2, y2, z2' etc. with your own coordinates, everything here should work. (With the ZCMD includes of course)
Re: Few questions. -
JavoDiaz - 02.01.2013
#1. On callback OnPlayerExitVehicle:
pawn Код:
SetVehicleToRespawn(vehicleid);
#2. First you have to get the coords, you can make a command to simplify that:
(I will use ZCMD)
pawn Код:
CMD:getcoords(playerid, params[])
{
new Float:x, Float:y, Float:z, string[128];
GetPlayerPos(playerid, x, y, z);
format(string, 128, "X: %f, Y: %f, Z: %f", x, y, z);
SendClientMessage(playerid, -1, string);
return 1;
}
I have show the coords in a ClientMessage but you can put it into a file or anywhere!
Re: Few questions. -
okil - 02.01.2013
Thanks, too bad I can't give rep yet.
Re: Few questions. -
Babul - 02.01.2013
you can, at least 1 rep point:
your register date is more than 1 year ago, so expect to give +1. its a good habbit to get used to reward users - do it
(but not me, since i do not consider this response helping. its common knowledge.)
Re: Few questions. -
okil - 02.01.2013
Nope, rep not added, I think I should have atleast 50 posts to do it.
Re: Few questions. -
Threshold - 02.01.2013
Just post one more time and you will be able to give rep. And the reps you gave should add to the totals. xD