Randomize spawning
#1

Hi
I have this stock
How can I make that it will randomize the positon of spawning when joining the derby


PHP код:
stock JoinDerby(playeridDerbyID)
{
if(
DerbyInfo[DerbyID][derbyjoinable] == false) return SendClientMessage(playerid, -1"Derby is currently not joinable!");
VehicleSpawner(playerid,DerbyInfo[DerbyID][derbyvehicle]);
new 
vehicleid GetPlayerVehicleID(playerid);
SetVehicleVirtualWorld(vehicleid23);
SetPlayerVirtualWorld(playerid23);
PutPlayerInVehicle(playeridvehicleid0);
SetVehiclePos(vehicleidDerbyInfo[DerbyID][spawnpointx], DerbyInfo[DerbyID][spawnpointy], DerbyInfo[DerbyID][spawnpointz]);
SetVehicleZAngle(vehicleidDerbyInfo[DerbyID][spawnpointa]);
return 
1;


Код:
new Derby1 = CreateDerby("Water Derby", 451);
AddSpawnToDerby(Derby1,3032.8792,536.6260,42.2847,276.6157);
AddSpawnToDerby(Derby1,2946.8621,388.5932,25.1934,324.0042);
AddSpawnToDerby(Derby1,2888.6335,528.7598,4.1510,268.8276);
AddSpawnToDerby(Derby1,2920.6140,494.4655,23.6494,359.9617);
AddSpawnToDerby(Derby1,2968.3506,430.4344,12.4151,358.0193);
Код:
CMD:derbys(playerid,params[])
{
new DerbyInfoString[600];
for(new x; x<currentderbyslot; x++)
{
if(DerbyInfo[x][derbyjoinable] == true) format(DerbyInfoString, sizeof(DerbyInfoString), "%s%s(ID:%d) {00FF00}[RACE JOINABLE]{FFFFFF}\n", DerbyInfoString, DerbyInfo[x][derbyname], x);
else if(DerbyInfo[x][derbyrunning] == true) format(DerbyInfoString, sizeof(DerbyInfoString), "%s%s(ID:%d) {FF0000}[RACE RUNNING]{FFFFFF}\n", DerbyInfoString, DerbyInfo[x][derbyname], x);
else format(DerbyInfoString, sizeof(DerbyInfoString), "%s%s(ID:%d) \n", DerbyInfoString, DerbyInfo[x][derbyname], x);
}
ShowPlayerDialog(playerid, 1236, DIALOG_STYLE_LIST, "LOL", DerbyInfoString, "Join", "Cancel");
return 1;
}
Код:
stock AddSpawnToDerby(DerbyID,Float:SpawnPointX, Float:SpawnPointY, Float:SpawnPointZ,Float:SpawnPointA)
{
DerbyInfo[DerbyID][spawnpointx] = SpawnPointX;
DerbyInfo[DerbyID][spawnpointy] = SpawnPointY;
DerbyInfo[DerbyID][spawnpointz] = SpawnPointZ;
DerbyInfo[DerbyID][spawnpointa] = SpawnPointA;
return 1;
}
Reply
#2

Show DerbyInfo
Reply
#3

I cant get a freaking idea how to make it....



PHP код:
enum dInfo
{
derbyname,
derbyvehicle,
bool:derbyrunning,
bool:derbyjoinable,
Float:spawnpointx,
Float:spawnpointy,
Float:spawnpointz,
Float:spawnpointa
};
new 
DerbyInfo[MAX_DERBYS][dInfo]; 
Reply
#4

pawn Код:
#define MAX_DERBYSPAWNS 50
new derbyspawns[MAX_DERBYS];

enum dInfo
{
    derbyname,
    derbyvehicle,
    bool:derbyrunning,
    bool:derbyjoinable,
    Float:spawnpointx[MAX_DERBYSPAWNS],
    Float:spawnpointy[MAX_DERBYSPAWNS],
    Float:spawnpointz[MAX_DERBYSPAWNS],
    Float:spawnpointa[MAX_DERBYSPAWNS]
};
new DerbyInfo[MAX_DERBYS][dInfo];

stock AddSpawnToDerby(DerbyID,Float:SpawnPointX, Float:SpawnPointY, Float:SpawnPointZ,Float:SpawnPointA)
{
    DerbyInfo[DerbyID][spawnpointx][derbyspawns[DerbyID]] = SpawnPointX;
    DerbyInfo[DerbyID][spawnpointy][derbyspawns[DerbyID]] = SpawnPointY;
    DerbyInfo[DerbyID][spawnpointz][derbyspawns[DerbyID]] = SpawnPointZ;
    DerbyInfo[DerbyID][spawnpointa][derbyspawns[DerbyID]] = SpawnPointA;
    derbyspawns[DerbyID]++;
    return 1;
}

stock JoinDerby(playerid, DerbyID)
{
    if(DerbyInfo[DerbyID][derbyjoinable] == false) return SendClientMessage(playerid, -1, "Derby is currently not joinable!");
    VehicleSpawner(playerid,DerbyInfo[DerbyID][derbyvehicle]);
    new vehicleid = GetPlayerVehicleID(playerid);
    SetVehicleVirtualWorld(vehicleid, 23);
    SetPlayerVirtualWorld(playerid, 23);
    PutPlayerInVehicle(playerid, vehicleid, 0);
    new spawnid=random(derbyspawns[DerbyID);
    SetVehiclePos(vehicleid, DerbyInfo[DerbyID][spawnpointx][spawnid], DerbyInfo[DerbyID][spawnpointy][spawnid], DerbyInfo[DerbyID][spawnpointz][spawnid]);
    SetVehicleZAngle(vehicleid, DerbyInfo[DerbyID][spawnpointa][spawnid]);
    return 1;
}
Here you go

If there's any problem, PM me.
Reply
#5

Thanks U! it works thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)