SA-MP Forums Archive
Changing to another map - 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)
+--- Thread: Changing to another map (/showthread.php?tid=278450)

Pages: 1 2


Changing to another map - Michael@Belgium - 22.08.2011

hi all, i really need to fix this problem ... i can't fix it by my own :-/
You may know im making a derby server but ofcourse if the round ends, so the roundtimer = 0, then must EVERYONE go (random) to another map ...

This is what i currently have:

CLICK ME


I TRIED THESE TOO :
pawn Code:
forward NewMap();
public NewMap()
{
    foreach(Player,i) { //so everyone must do this ...
        DontSpectating(i);
        SetPlayerColor(i,COLOR_GREEN);
        CreateNewVehicles();//ignore
        SetPVarInt(i,"Missiles",0);
        PlayerJustConnected[i] = 0;
        new OtherSpawn = random(12);//i have 12 different maps, so 12 randoms
        switch (OtherSpawn)//switch statement...
        {
            case 0://map 1
            {
                print("Went to map 1");
                new rand1=random(30);
                PutPlayerInVehicle(i, CarMap1[rand1], 0);
                SendClientMessage(i, COLOR_ORANGE,"You were put randomly in a vehicle ...");
                SendRconCommand("mapname Arena 666");
                TextDrawSetString(Textdraw6,"~g~ Arena 666 ~w~ by ~y~ Michael@Belgium");
            }
                   //@ above: this i have untill "case 11:". Also a print, new rand1,rand2,...; Putplayerinvehicle ... etc.
        }
        TextDrawShowForAll(Textdraw6);//idk if that must be here ...
    }
    return 1;
}
And like gamer said: doesn't work too:
pawn Code:
forward NewMap();
public NewMap()
{
    new OtherSpawn = random(12);
    ResetVehicles();
    foreach(Player,i) {
        DontSpectating(i);
        SetPlayerColor(i,COLOR_GREEN);
        CreateNewVehicles();
        SetPVarInt(i,"Missiles",0);
        PlayerJustConnected[i] = 0;
        switch (OtherSpawn)
        {
            case 0:
            {
                print("Went to map 1");
                PutPlayerInVehicle(i, CarMap1[GetRandomVehicleID(0)], 0);
                SendClientMessage(i, COLOR_ORANGE,"You were put randomly in a vehicle ...");
                SendRconCommand("mapname Arena 666");
                TextDrawSetString(Textdraw6,"~g~ Arena 666 ~w~ by ~y~ Michael@Belgium");
            }
            case 1:
            {
                print("Went to map 2");
                PutPlayerInVehicle(i, CarMap2[GetRandomVehicleID(1)], 0);
                SendClientMessage(i, COLOR_ORANGE,"You were put randomly in a vehicle ...");
                SendRconCommand("mapname Destruction Farm");
                TextDrawSetString(Textdraw6,"~g~ Destruction Farm ~w~ by ~y~ Michael@Belgium");
            }
            case 2:
            {
                print("Went to map 3");
                PutPlayerInVehicle(i, CarMap3[GetRandomVehicleID(2)], 0);
                SendClientMessage(i, COLOR_ORANGE,"You were put randomly in a vehicle ...");
                SendRconCommand("mapname Don't fall in the water !");
                TextDrawSetString(Textdraw6,"~g~ Don't Fall In The Water ~w~ by ~y~ Michael@Belgium");
            }
            case 3:
            {
                print("Went to map 4");
                PutPlayerInVehicle(i, CarMap4[GetRandomVehicleID(3)],0);
                SendClientMessage(i,COLOR_ORANGE,"You were put randomly in a vehicle ...");
                SendRconCommand("mapname Bus derby");
                TextDrawSetString(Textdraw6,"~g~ Bus Derby ~w~ by ~y~ [AS]Samuel[CR]");
            }
            case 4:
            {
                print("Went to map 5");
                PutPlayerInVehicle(i, CarMap5[GetRandomVehicleID(4)],0);
                SendClientMessage(i,COLOR_ORANGE,"You were put randomly in a vehicle ...");
                SendRconCommand("mapname The Dead Place");
                TextDrawSetString(Textdraw6,"~g~ The Dead Place ~w~ by ~y~ Remce");
            }
            case 5:
            {
                print("Went to map 6");
                PutPlayerInVehicle(i, CarMap6[GetRandomVehicleID(5)],0);
                SendClientMessage(i,COLOR_ORANGE,"You were put randomly in a vehicle ...");
                SendRconCommand("mapname Your Worst Nightmare !");
                TextDrawSetString(Textdraw6,"~g~ Your Worst Nightmare ~w~ by ~y~ Remce");
            }
            case 6:
            {
                print("Went to map 7");
                PutPlayerInVehicle(i,CarMap7[GetRandomVehicleID(6)],0);
                SendClientMessage(i,COLOR_ORANGE,"You were put randomly in a vehicle ...");
                SendRconCommand("mapname The Disaster");
                TextDrawSetString(Textdraw6,"~g~ The Disaster ~w~ by ~y~ [AS]Samuel[CR]");
            }
            case 7:
            {
                print("Went to map 8");
                PutPlayerInVehicle(i,CarMap8[GetRandomVehicleID(7)],0);
                SendClientMessage(i,COLOR_ORANGE,"You were put randomly in a vehicle ...");
                SendRconCommand("mapname Up In The Air");
                TextDrawSetString(Textdraw6,"~g~ Up In The Air ~w~ by ~y~ Michael@Belgium");
            }
            case 8:
            {
                print("Went to map 9");
                PutPlayerInVehicle(i,CarMap9[GetRandomVehicleID(8)],0);
                SendClientMessage(i,COLOR_ORANGE,"You were put randomly in a vehicle ...");
                SendRconCommand("mapname A Trip To Future Egypt");
                TextDrawSetString(Textdraw6,"~g~ A Trip To Future Egypt ~w~ by ~y~ Justsomeguy");
            }
            case 9:
            {
                print("Went to map 10");
                PutPlayerInVehicle(i,CarMap10[GetRandomVehicleID(9)],0);
                SendRconCommand("mapname Sumo");
                TextDrawSetString(Textdraw6,"~g~ Sumo ~w~ by ~y~ [BP]Tony");
            }
            case 10:
            {
                print("Went to map 12");
                PutPlayerInVehicle(i,CarMap12[GetRandomVehicleID(11)],0);
                SendRconCommand("mapname 0.3c Derby");
                TextDrawSetString(Textdraw6,"~g~ 0.3c Derby ~w~ by ~y~ [RsM]XpLoD");
            }
            case 11:
            {
                print("Went to map 11");
                PutPlayerInVehicle(i,CarMap11[GetRandomVehicleID(10)],0);
                SendRconCommand("mapname Unknown");
                TextDrawSetString(Textdraw6,"~g~ Unknown ~w~ by ~y~ Lisa_love");
             }
        }
        TextDrawShowForAll(Textdraw6);
    }
    return 1;
}

stock GetRandomVehicleID(map)
{
    switch(map)
    {
        case 0:
        {
            for(new i = 0;i<29;i++)
            {
                if(!VehicleUsed[i])
                {
                    VehicleUsed[i] = true;
                    return i;
                }
            }
        }
       
        case 1:
        {
            for(new i = 0;i<30;i++)
            {
                if(!VehicleUsed[i])
                {
                    VehicleUsed[i] = true;
                    return i;
                }
            }
        }

        case 2:
        {
            for(new i = 0;i<28;i++)
            {
                if(!VehicleUsed[i])
                {
                    VehicleUsed[i] = true;
                    return i;
                }
            }
        }
        case 3:
        {
            for(new i = 0;i<30;i++)
            {
                if(!VehicleUsed[i])
                {
                    VehicleUsed[i] = true;
                    return i;
                }
            }
        }
        case 4:
        {
            for(new i = 0;i<30;i++)
            {
                if(!VehicleUsed[i])
                {
                    VehicleUsed[i] = true;
                    return i;
                }
            }
        }
        case 5:
        {
            for(new i = 0;i<30;i++)
            {
                if(!VehicleUsed[i])
                {
                    VehicleUsed[i] = true;
                    return i;
                }
            }
        }
        case 6:
        {
            for(new i = 0;i<30;i++)
            {
                if(!VehicleUsed[i])
                {
                    VehicleUsed[i] = true;
                    return i;
                }
            }
        }
        case 7:
        {
            for(new i = 0;i<30;i++)
            {
                if(!VehicleUsed[i])
                {
                    VehicleUsed[i] = true;
                    return i;
                }
            }
        }
        case 8:
        {
            for(new i = 0;i<29;i++)
            {
                if(!VehicleUsed[i])
                {
                    VehicleUsed[i] = true;
                    return i;
                }
            }
        }
        case 9:
        {
            for(new i = 0;i<29;i++)
            {
                if(!VehicleUsed[i])
                {
                    VehicleUsed[i] = true;
                    return i;
                }
            }
        }
        case 10:
        {
            for(new i = 0;i<30;i++)
            {
                if(!VehicleUsed[i])
                {
                    VehicleUsed[i] = true;
                    return i;
                }
            }
        }
        case 11:
        {
            for(new i = 0;i<30;i++)
            {
                if(!VehicleUsed[i])
                {
                    VehicleUsed[i] = true;
                    return i;
                }
            }
        }
    }
    return -1; //no vehicles left
}
And here another thing that doesn't work too:
pawn Code:
forward NewMap();
public NewMap()
{
    new OtherSpawn = random(12);
    ResetVehicles();
    foreach(Player,i) {
        DontSpectating(i);
        SetPlayerColor(i,COLOR_GREEN);
        CreateNewVehicles();
        SetPVarInt(i,"Missiles",0);
        PlayerJustConnected[i] = 0;
        switch (OtherSpawn)
        {
            case 0:
            {
                print("Went to map 1");
                RandomVehicle(1);
                SendClientMessage(i, COLOR_ORANGE,"You were put randomly in a vehicle ...");
                SendRconCommand("mapname Arena 666");
                TextDrawSetString(Textdraw6,"~g~ Arena 666 ~w~ by ~y~ Michael@Belgium");
            }
//...
}
//---------------------------------------------------------
stock RandomVehicle(map)
{
    foreach(Player,i)
    {
        new b,bool:c1[sizeof(CarMap1)];
        new bool:c2[sizeof(CarMap2)];
        new bool:c3[sizeof(CarMap3)];
        new bool:c4[sizeof(CarMap4)];
        new bool:c5[sizeof(CarMap5)];
        new bool:c6[sizeof(CarMap6)];
        new bool:c7[sizeof(CarMap7)];
        new bool:c8[sizeof(CarMap8)];
        new bool:c9[sizeof(CarMap9)];
        new bool:c10[sizeof(CarMap10)];
        new bool:c11[sizeof(CarMap11)];
        new bool:c12[sizeof(CarMap12)];
        switch(map)
        {
            case 1:
            {
                for(new z;z<sizeof(CarMap1);z++)
                {
                    b = random(sizeof(CarMap1));
                    if(c1[b])
                    {
                        z--;
                        continue;
                    }
                    PutPlayerInVehicle(i,b,0);
                    c1[b]++;
                    break;
                }
            }
            case 2:
            {
                for(new z;z<sizeof(CarMap2);z++)
                {
                    b = random(sizeof(CarMap2));
                    if(c2[b])
                    {
                        z--;
                        continue;
                    }
                    PutPlayerInVehicle(i,b,0);
                    c2[b]++;
                    break;
                }
            }
            case 3:
            {
                for(new z;z<sizeof(CarMap3);z++)
                {
                    b = random(sizeof(CarMap3));
                    if(c3[b])
                    {
                        z--;
                        continue;
                    }
                    PutPlayerInVehicle(i,b,0);
                    c3[b]++;
                    break;
                }
            }
            case 4:
            {
                for(new z;z<sizeof(CarMap4);z++)
                {
                    b = random(sizeof(CarMap4));
                    if(c4[b])
                    {
                        z--;
                        continue;
                    }
                    PutPlayerInVehicle(i,b,0);
                    c4[b]++;
                    break;
                }
            }
            case 5:
            {
                for(new z;z<sizeof(CarMap5);z++)
                {
                    b = random(sizeof(CarMap5));
                    if(c5[b])
                    {
                        z--;
                        continue;
                    }
                    PutPlayerInVehicle(i,b,0);
                    c5[b]++;
                    break;
                }
            }
            case 6:
            {
                for(new z;z<sizeof(CarMap6);z++)
                {
                    b = random(sizeof(CarMap6));
                    if(c6[b])
                    {
                        z--;
                        continue;
                    }
                    PutPlayerInVehicle(i,b,0);
                    c6[b]++;
                    break;
                }
            }
            case 7:
            {
                for(new z;z<sizeof(CarMap7);z++)
                {
                    b = random(sizeof(CarMap7));
                    if(c7[b])
                    {
                        z--;
                        continue;
                    }
                    PutPlayerInVehicle(i,b,0);
                    c7[b]++;
                    break;
                }
            }
            case 8:
            {
                for(new z;z<sizeof(CarMap8);z++)
                {
                    b = random(sizeof(CarMap8));
                    if(c8[b])
                    {
                        z--;
                        continue;
                    }
                    PutPlayerInVehicle(i,b,0);
                    c8[b]++;
                    break;
                }
            }
            case 9:
            {
                for(new z;z<sizeof(CarMap9);z++)
                {
                    b = random(sizeof(CarMap9));
                    if(c9[b])
                    {
                        z--;
                        continue;
                    }
                    PutPlayerInVehicle(i,b,0);
                    c9[b]++;
                    break;
                }
            }
            case 10:
            {
                for(new z;z<sizeof(CarMap10);z++)
                {
                    b = random(sizeof(CarMap10));
                    if(c10[b])
                    {
                        z--;
                        continue;
                    }
                    PutPlayerInVehicle(i,b,0);
                    c10[b]++;
                    break;
                }
            }
            case 11:
            {
                for(new z;z<sizeof(CarMap11);z++)
                {
                    b = random(sizeof(CarMap11));
                    if(c11[b])
                    {
                        z--;
                        continue;
                    }
                    PutPlayerInVehicle(i,b,0);
                    c11[b]++;
                    break;
                }
            }
            case 12:
            {
                for(new z;z<sizeof(CarMap12);z++)
                {
                    b = random(sizeof(CarMap12));
                    if(c12[b])
                    {
                        z--;
                        continue;
                    }
                    PutPlayerInVehicle(i,b,0);
                    c12[b]++;
                    break;
                }
            }
        }
    }
}
The problem:
-> Ok everything is fine untill when everyone must change to another map..

=> SOME PLAYERS DON'T SPAWN/TELEPORTS TO ANOTHER/THE SAME MAP !

PLZ help me asap, and who helped me i'll give reps


Re: Changing to another map ! *NEED HELP ASAP* - [MWR]Blood - 22.08.2011

pawn Code:
CarMap1[rand1]
What's the rand1 for?


Re: Changing to another map ! *NEED HELP ASAP* - Michael@Belgium - 22.08.2011

Quote:
Originally Posted by Delux13
View Post
pawn Code:
CarMap1[rand1]
What's the rand1 for?
Put the player in a random vehicle in map 1 (
pawn Code:
new CarMap1[29]
)


Re: Changing to another map ! *NEED HELP ASAP* - [MWR]Blood - 22.08.2011

You said they teleport to another or the same map.
When they do, are they in the vehicle they are supposed to be put in?


Re: Changing to another map ! *NEED HELP ASAP* - Lenny the Cup - 22.08.2011

Do you want them to spawn on the same map or every player on a different map?


Re: Changing to another map ! *NEED HELP ASAP* - Michael@Belgium - 22.08.2011

Quote:
Originally Posted by Delux13
View Post
You said they teleport to another or the same map.
When they do, are they in the vehicle they are supposed to be put in?
Quote:
Originally Posted by Lenny the Cup
View Post
Do you want them to spawn on the same map or every player on a different map?
Well ... all to the same map + they must putted in a vehicle when they go to another map


Re: Changing to another map ! *NEED HELP ASAP* - [MWR]Blood - 22.08.2011

Try first setting their position.


Re: Changing to another map ! *NEED HELP ASAP* - Lenny the Cup - 22.08.2011

They are given different maps because you randomize the mapnumber for each player.


Re: Changing to another map ! *NEED HELP ASAP* - Michael@Belgium - 22.08.2011

Quote:
Originally Posted by Delux13
View Post
Try first setting their position.
of what? xp the cars ? x)

Quote:
Originally Posted by Lenny the Cup
View Post
They are given different maps because you randomize the mapnumber for each player.
huh ? :S how mean.. how should i do that then ?


Re: Changing to another map ! *NEED HELP ASAP* - wups - 22.08.2011

pawn Code:
forward NewMap();
public NewMap()
{
    new OtherSpawn = random(12);//i have 12 different maps, so 12 randoms
    foreach(Player,i) { //so everyone must do this ...
        DontSpectating(i);
        SetPlayerColor(i,COLOR_GREEN);
        CreateNewVehicles();//ignore
        SetPVarInt(i,"Missiles",0);
        PlayerJustConnected[i] = 0;
        switch (OtherSpawn)//switch statement...
        {
            case 0://map 1
            {
                print("Went to map 1");
                new rand1=random(30);
                PutPlayerInVehicle(i, CarMap1[rand1], 0);
                SendClientMessage(i, COLOR_ORANGE,"You were put randomly in a vehicle ...");
                SendRconCommand("mapname Arena 666");
                TextDrawSetString(Textdraw6,"~g~ Arena 666 ~w~ by ~y~ Michael@Belgium");
            }
                   //@ above: this i have untill "case 11:". Also a print, new rand1,rand2,...; Putplayerinvehicle ... etc.
        }
        TextDrawShowForAll(Textdraw6);//idk if that must be here ...
    }
    return 1;
}



Re: Changing to another map ! *NEED HELP ASAP* - Michael@Belgium - 22.08.2011

Quote:
Originally Posted by wups
View Post
pawn Code:
forward NewMap();
public NewMap()
{
    new OtherSpawn = random(12);//i have 12 different maps, so 12 randoms
    foreach(Player,i) { //so everyone must do this ...
        DontSpectating(i);
        SetPlayerColor(i,COLOR_GREEN);
        CreateNewVehicles();//ignore
        SetPVarInt(i,"Missiles",0);
        PlayerJustConnected[i] = 0;
        switch (OtherSpawn)//switch statement...
        {
            case 0://map 1
            {
                print("Went to map 1");
                new rand1=random(30);
                PutPlayerInVehicle(i, CarMap1[rand1], 0);
                SendClientMessage(i, COLOR_ORANGE,"You were put randomly in a vehicle ...");
                SendRconCommand("mapname Arena 666");
                TextDrawSetString(Textdraw6,"~g~ Arena 666 ~w~ by ~y~ Michael@Belgium");
            }
                   //@ above: this i have untill "case 11:". Also a print, new rand1,rand2,...; Putplayerinvehicle ... etc.
        }
        TextDrawShowForAll(Textdraw6);//idk if that must be here ...
    }
    return 1;
}
nope :-/ don't work


Re: Changing to another map ! *NEED HELP ASAP* - Michael@Belgium - 22.08.2011

plz help me further


Re: Changing to another map ! *NEED HELP ASAP* - Michael@Belgium - 23.08.2011

Plz x( (asap)


Re: Changing to another map ! *NEED HELP ASAP* - Jochemd - 26.08.2011

What is ACTUALLY your problem now? It didn't become clear to me, sorry.


Re: Changing to another map ! *NEED HELP ASAP* - Michael@Belgium - 26.08.2011

The players don't spawn/teleport to another (random) map :-/


Re: Changing to another map ! *NEED HELP ASAP* - Jochemd - 26.08.2011

I'd like to see the CreateNewVehicle stocks


Re: Changing to another map ! *NEED HELP ASAP* - Michael@Belgium - 26.08.2011

Quote:
Originally Posted by Jochemd
View Post
I'd like to see the CreateNewVehicle stocks
pawn Code:
stock CreateNewVehicles()
{
    LoopEx(i,0,sizeof(CarMap1)) SetVehicleToRespawn(CarMap1[i]);
    //for each map ...
        LoopEx(i,0,sizeof(CarMap2)) SetVehicleToRespawn(CarMap2[i]);
         //etc ...
}



Re: Changing to another map ! *NEED HELP ASAP* - Lorenc_ - 26.08.2011

pawn Code:
switch (OtherSpawn)//switch statement...
        {
            case 0://map 1
            {
                print("Went to map 1");
                new rand1=random(30);
                PutPlayerInVehicle(i, CarMap1[rand1], 0);
                SendClientMessage(i, COLOR_ORANGE,"You were put randomly in a vehicle ...");
                SendRconCommand("mapname Arena 666");
                TextDrawSetString(Textdraw6,"~g~ Arena 666 ~w~ by ~y~ Michael@Belgium");
            }
                   //@ above: this i have untill "case 11:". Also a print, new rand1,rand2,...; Putplayerinvehicle ... etc.
        }
^ Does that respond? Or it's just simply not loading?


Re: Changing to another map ! *NEED HELP ASAP* - Michael@Belgium - 26.08.2011

Quote:
Originally Posted by Lorenc_
View Post
pawn Code:
switch (OtherSpawn)//switch statement...
        {
            case 0://map 1
            {
                print("Went to map 1");
                new rand1=random(30);
                PutPlayerInVehicle(i, CarMap1[rand1], 0);
                SendClientMessage(i, COLOR_ORANGE,"You were put randomly in a vehicle ...");
                SendRconCommand("mapname Arena 666");
                TextDrawSetString(Textdraw6,"~g~ Arena 666 ~w~ by ~y~ Michael@Belgium");
            }
                   //@ above: this i have untill "case 11:". Also a print, new rand1,rand2,...; Putplayerinvehicle ... etc.
        }
^ Does that respond? Or it's just simply not loading?
Well i see in the console "Went to map x" but in-game i just don't go there ... and if i spawn it's ALWAYS in the first map and not others ..


Re: Changing to another map ! *NEED HELP ASAP* - Pinguinn - 26.08.2011

Uhm....

Code:
/rcon mapname [name] - change the map name text (example: /rcon mapname San Andreas).
I don't think it changes the actual map
Instead this might work?

Code:
/rcon changemode [mode] - This command will change the current gamemode to the given one (example: if you want to play sftdm: /rcon changemode sftdm)