SA-MP Forums Archive
Player spawns - 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: Player spawns (/showthread.php?tid=213777)



Player spawns - ToPhrESH - 19.01.2011

I am working on a saimple game mode just because I am bored. I went to test out and every team spawns in grove's coordinates.
pawn Код:
SetPlayerTeamFromClass(playerid, classid)
{
    if (classid == 0 || 1 || 2 || 3)
    {
        gTeam[playerid] = TEAM_GROVE;
    }
    else if(classid == 4 || 5 || 6)
    {
        gTeam[playerid] = TEAM_AZTECAS;
    }
    else if(classid == 7 || 8 || 9)
    {
        gTeam[playerid] = TEAM_COPS;
    }
    else if(classid == 10 || 11 || 12 || 13)
    {
        gTeam[playerid] = TEAM_BALLAS;
    }
    else if(classid == 14 || 15 || 16)
    {
        gTeam[playerid] = TEAM_VAGOS;
    }
    else if(classid == 17 || 18 || 19)
    {
        gTeam[playerid] = TEAM_BIKERS;
    }
    else if(classid == 20 || 21)
    {
        gTeam[playerid] = TEAM_SKATERS;
    }
    else if(classid == 22 || 23 || 24 || 25)
    {
        gTeam[playerid] = TEAM_RED;
    }
}
Here is the spawn..

pawn Код:
public OnPlayerSpawn(playerid)
{
    TextDrawHideForPlayer(playerid, grove0);
    TextDrawHideForPlayer(playerid, grove1);
    TextDrawHideForPlayer(playerid,aztec0);
    TextDrawHideForPlayer(playerid,aztec1);
    TextDrawHideForPlayer(playerid,cop0);
    TextDrawHideForPlayer(playerid,cop1);
    TextDrawHideForPlayer(playerid,balla0);
    TextDrawHideForPlayer(playerid,balla1);
    TextDrawHideForPlayer(playerid,vago0);
    TextDrawHideForPlayer(playerid,vago1);
    TextDrawHideForPlayer(playerid,skate0);
    TextDrawHideForPlayer(playerid,skate1);
    TextDrawHideForPlayer(playerid,bike0);
    TextDrawHideForPlayer(playerid,bike1);
    TextDrawHideForPlayer(playerid,red0);
    TextDrawHideForPlayer(playerid,red1);
    ClearAnimations(playerid);
    PlayerPlaySound(playerid, 1186, 0.0, 0.0, 0.0);
    SetPlayerHealth(playerid, 100);
    if(gTeam[playerid] == TEAM_GROVE)
    {
        SetPlayerColor(playerid, COLOR_GREEN);
        GivePlayerWeapon(playerid, 24, 150);
        GivePlayerWeapon(playerid, 27, 200);
        GivePlayerWeapon(playerid, 31, 300);
        GivePlayerWeapon(playerid, 32, 50);
        GivePlayerWeapon(playerid, 16, 5);
        new rand = random(sizeof(gRandomSpawns));
        SetPlayerPos(playerid, gRandomSpawns[rand][0], gRandomSpawns[rand][1], gRandomSpawns[rand][2]);
    }
    else if(gTeam[playerid] == TEAM_BALLAS)
    {
        SetPlayerColor(playerid, COLOR_PURPLE);
        GivePlayerWeapon(playerid, 24, 200);
        GivePlayerWeapon(playerid, 25, 200);
        GivePlayerWeapon(playerid, 34, 50);
        GivePlayerWeapon(playerid, 18, 5);
        GivePlayerWeapon(playerid, 28, 400);
        new rand = random(sizeof(bRandomSpawns));
        SetPlayerPos(playerid, bRandomSpawns[rand][0], bRandomSpawns[rand][1], bRandomSpawns[rand][2]);
    }
    else if(gTeam[playerid] == TEAM_VAGOS)
    {
        GivePlayerWeapon(playerid, 24, 200);
        GivePlayerWeapon(playerid, 26, 210);
        GivePlayerWeapon(playerid, 33, 50);
        GivePlayerWeapon(playerid, 18, 5);
        new rand = random(sizeof(vRandomSpawns));
        SetPlayerPos(playerid, vRandomSpawns[rand][0], vRandomSpawns[rand][1], vRandomSpawns[rand][2]);
    }
    else if(gTeam[playerid] == TEAM_AZTECAS)
    {
        GivePlayerWeapon(playerid, 22, 250);
        GivePlayerWeapon(playerid, 26, 210);
        GivePlayerWeapon(playerid, 29, 300);//9mm Pistol~n~Sawn-Offs~n~MP5~n~Sniper Rifle~n~grenades
        GivePlayerWeapon(playerid, 34, 50);
        GivePlayerWeapon(playerid, 16, 5);
        new rand = random(sizeof(aRandomSpawns));
        SetPlayerPos(playerid, aRandomSpawns[rand][0], aRandomSpawns[rand][1], aRandomSpawns[rand][2]);
    }
    else if(gTeam[playerid] == TEAM_COPS)
    {
        GivePlayerWeapon(playerid, 22, 250);
        GivePlayerWeapon(playerid, 25, 200);
        GivePlayerWeapon(playerid, 29, 300);
        GivePlayerWeapon(playerid, 31, 300);
        GivePlayerWeapon(playerid, 16, 5);
        new rand = random(sizeof(cRandomSpawns));
        SetPlayerPos(playerid, cRandomSpawns[rand][0], cRandomSpawns[rand][1], cRandomSpawns[rand][2]);
    }
    else if(gTeam[playerid] == TEAM_SKATERS)
    {
        GivePlayerWeapon(playerid, 24, 200);
        GivePlayerWeapon(playerid, 26, 200);
        GivePlayerWeapon(playerid, 28, 350);
        GivePlayerWeapon(playerid, 34, 50);
        new rand = random(sizeof(sRandomSpawns));
        SetPlayerPos(playerid, sRandomSpawns[rand][0], sRandomSpawns[rand][1], sRandomSpawns[rand][2]);
    }
    else if(gTeam[playerid] == TEAM_BIKERS)
    {
        GivePlayerWeapon(playerid, 22, 200);
        GivePlayerWeapon(playerid, 28, 350);
        GivePlayerWeapon(playerid, 30, 350);
        GivePlayerWeapon(playerid, 25, 200);
        GivePlayerWeapon(playerid, 18, 5);
        new rand = random(sizeof(biRandomSpawns));
        SetPlayerPos(playerid, biRandomSpawns[rand][0], biRandomSpawns[rand][1], biRandomSpawns[rand][2]);
    }
    else if(gTeam[playerid] == TEAM_RED)
    {
        GivePlayerWeapon(playerid, 24, 150);
        GivePlayerWeapon(playerid, 26, 250);
        GivePlayerWeapon(playerid, 32, 250);
        GivePlayerWeapon(playerid, 34, 50);
        new rand = random(sizeof(rRandomSpawns));
        SetPlayerPos(playerid, rRandomSpawns[rand][0], rRandomSpawns[rand][1], rRandomSpawns[rand][2]);
    }
    return 1;
}
Any help please?


Re: Player spawns - admantis - 19.01.2011

What do you need help with?


Re: Player spawns - ToPhrESH - 19.01.2011

I seperated them into teams. I want the teams to spawn in their own coordinates. But when I run this if I choose any team they will spawn in the Grove coordinates.

i.e
I choose Aztecas, but the Azteca will spawn in 1 of the 4 Grove Street Families spawn instead of their El Corona Azteca spawns.

I choose Skaters, but the Skater will spawn in other coordinates of the Grove Street Families instead of their Ganton Skatepark coordinates. Get the idea?

No need with urgent help, but do need help!


Re: Player spawns - Krx17 - 19.01.2011

Your if statements are structured wrong.
pawn Код:
if (classid == 0 || 1 || 2 || 3) //Wrong
if (classid == 0 || classid == 1 || classid == 2 || classid == 3) //Right
Use a switch statement, it will be cleaner code.
pawn Код:
//Example
switch(classid)
{
    case 1..3: gTeam[playerid] = TEAM_GROVE;
    case 4..6: gTeam[playerid] = TEAM_AZTECAS;
    //and so on
}



Re: Player spawns - admantis - 19.01.2011

Quote:
Originally Posted by Krx17
Посмотреть сообщение
Your if statements are structured wrong.
pawn Код:
if (classid == 0 || 1 || 2 || 3) //Wrong
if (classid == 0 || classid == 1 || classid == 2 || classid == 3) //Right
Use a switch statement, it will be cleaner code.
pawn Код:
//Example
switch(classid)
{
    case 1..3: gTeam[playerid] = TEAM_GROVE;
    case 4..6: gTeam[playerid] = TEAM_AZTECAS;
    //and so on
}
What I was going to say


Re: Player spawns - ToPhrESH - 19.01.2011

Quote:
Originally Posted by Krx17
Посмотреть сообщение
Your if statements are structured wrong.
pawn Код:
if (classid == 0 || 1 || 2 || 3) //Wrong
if (classid == 0 || classid == 1 || classid == 2 || classid == 3) //Right
Use a switch statement, it will be cleaner code.
pawn Код:
//Example
switch(classid)
{
    case 1..3: gTeam[playerid] = TEAM_GROVE;
    case 4..6: gTeam[playerid] = TEAM_AZTECAS;
    //and so on
}
ok thankss