SA-MP Forums Archive
Derby Script - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Derby Script (/showthread.php?tid=66494)



Derby Script - Headshot1108 - 22.02.2009

Hey guys, i got a little problem.
i'm scripting at the moment on a derby and i can't go on, because when the players are spawning they should spawn at different spots and noone should have the same, but they spawn all exactly at the same place.
My Codes:

/derby:
pawn Код:
if(strcmp(cmdtext, "/derby",true)==0)
    {
    GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
    format(string, sizeof(string), "%s is going to Derby!", playername);
    SendClientMessageToAll(blue,string);
    if(derbytime == 0)
    {
    ShowMenuForPlayer(derbymenu,playerid);
    derbycheck[playerid]++;
    SetPlayerCameraPos(playerid,-2072.1663,-121.7532,35.3296);
    SetPlayerCameraLookAt(playerid,-2072.1663,-121.7532,35.3296);
    TogglePlayerControllable(playerid,0);
    SetTimerEx("DerbyGo",7000,false,"i",playerid);
    }
    return 1;
    }
Menu:
pawn Код:
if (Current == derbymenu)
{
switch(row)
{
case 0:
{
new string[256];
if(derbycheck[playerid] > 0)
{
driveschool[playerid]++;
GetPlayerName(playerid, playername, sizeof(playername));
format(string, sizeof(string), "%s select SF Driveschool", playername);
SendClientMessageToAll(gelb,string);
return 1;
}
}
DerbyGo:
pawn Код:
forward DerbyGo(playerid);
public DerbyGo(playerid)
{
if(derbycheck[playerid] > 0)
{
SpawnPlayer(playerid);
}
}
OnPlayerSpawn:
pawn Код:
if(derbycheck[playerid] > 0)
    {
    if(driveschool[playerid] == 1)
    {
    new vid = CreateVehicle(504,-2058.2822,-107.3824,35.3203,180.00,0,0,60);
    PutPlayerInVehicle(playerid, vid, 0);
    LinkVehicleToInterior(vid, GetPlayerInterior(playerid));
    VehiclesToDestroy[vid] = 1;
    ResetPlayerWeapons(playerid);
    return 1;
    }
    if(driveschool[playerid] == 2)
    {
    new vid = CreateVehicle(504,-2068.8708,-107.0806,35.3225,180.00,0,0,60);
    PutPlayerInVehicle(playerid, vid, 0);
    LinkVehicleToInterior(vid, GetPlayerInterior(playerid));
    VehiclesToDestroy[vid] = 1;
    ResetPlayerWeapons(playerid);
    return 1;
    }
    if(driveschool[playerid] == 3)
    {
    new vid = CreateVehicle(504,-2078.1958,-107.0035,35.3203,180.00,0,0,60);
    PutPlayerInVehicle(playerid, vid, 0);
    LinkVehicleToInterior(vid, GetPlayerInterior(playerid));
    VehiclesToDestroy[vid] = 1;
    ResetPlayerWeapons(playerid);
    return 1;
    }
    }

till now it's like this: if i spawn every player is given the variable driveschool == 1.
i know why, cause every playerid gets ++ (+1).
How can i do it that every player gets one different spot doesn't depending on how much players?


Re: derby - Headshot1108 - 22.02.2009

*bump*

plz help


Re: derby - lavamike - 22.02.2009

You mean you just want a few spawns and then they will get a random spawn there? Here is an example.

pawn Код:
new Float:LolSpawn[13][3] = {
{596.3462,1715.8889,13200.8818},
{672.0673,1634.6731,13181.5068},
{684.0848,1647.6111,13180.9922},
{701.1727,1720.1597,13140.5029},
{765.8998,1713.5703,13131.2129},
{746.9452,1590.9337,13153.1445},
{747.1368,1682.0662,13140.3506},
{695.3058,1715.1122,13143.4805},
{697.5287,1630.9753,13179.5107},
{630.8890,1710.9944,13190.5703},
{704.0422,1594.6122,13144.7500},
{738.2070,1578.1777,13147.8926},
{755.6571,1639.2150,13151.2041}
};
just place the coords you want to use for the spawn in there and then do something like this to pick a random one..

pawn Код:
public SpawnLol(playerid)
{
    new rand = random(sizeof(LolSpawn));
    SetPlayerPos(playerid, LolSpawn[rand][0], LolSpawn[rand][1], LolSpawn[rand][2]);
}



Re: derby - Headshot1108 - 22.02.2009

thx for your answer, but i want to do it like this. every player gets a spawnpont which has only him, cause they cant have the same random spawn and then they cant move cause one player is on the other.


Re: derby - Headshot1108 - 23.02.2009

please help


Re: Derby Script - Headshot1108 - 23.02.2009

*bump*