SA-MP Forums Archive
How to set spawn locations on command. - 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: How to set spawn locations on command. (/showthread.php?tid=487387)



How to set spawn locations on command. - ponagandlamanoj - 13.01.2014

Hello guys. I want to add derby map for my server for fun purpose during events. I've found a map but now i want to set random spawns when a player types the command to get into the derby location..

I want those random spawns to be linked to this command

Код HTML:
if (strcmp("/DD3", cmdtext, true, 10) == 0)
	{
		SendClientMessage(playerid, COLOR_BLUE, "You just got Teleported to Derby Map!");
		return 1;
	}
the co-ordinates are

Код HTML:
{2580.9543,-2922.2375,1003.8871},{2580.9353,-3040.3372,1003.8871},{2620.9497,-2980.4980,1003.8871},
{2662.5625,-2922.4089,1003.8871},{2682.1228,-2959.8835,1003.8871},{2663.1399,-2999.8201,1003.8871},
{2581.3845,-2962.0913,1003.8871},{2606.0146,-2995.0747,1003.8871},{2601.6973,-2941.1292,1003.8871},
{2581.7783,-2959.8501,1003.8871}

{3811.2156,-2453.5735,1002.5284},{3828.2717,-2437.7588,1002.5284},{3797.6394,-2471.6860,1002.5284},
{3778.0747,-2452.8750,1002.5284},{3848.7319,-2453.9375,1002.5284},{3828.6216,-2453.9402,1015.5284},
{3797.5637,-2453.8789,1015.5284},{3855.7751,-2472.6580,1015.5284},{3770.3140,-2436.6235,1015.5284},
{3811.2190,-2436.3999,1015.5284}



Re: How to set spawn locations on command. - JeaSon - 13.01.2014

SetPlayerPos

always use ****** coz ****** is your friend

THIS

pawn Код:
if (strcmp("/DD3", cmdtext, true, 10) == 0)
{      
        SetPlayerPos(playerid,2580.9543,-2922.2375,1003.8871);
        SendClientMessage(playerid, COLOR_BLUE, "You just got Teleported to Derby Map!");
    return 1;
}



Re: How to set spawn locations on command. - SilentSoul - 13.01.2014

Not tested but that should work.
pawn Код:
new Float:RandomSpawn[][] =
{
    {2580.9543,-2922.2375,1003.8871},
    {2580.9353,-3040.3372,1003.8871},
    {2620.9497,-2980.4980,1003.8871},
    {2662.5625,-2922.4089,1003.8871},
    {2682.1228,-2959.8835,1003.8871},
    {2663.1399,-2999.8201,1003.8871},
    {2581.3845,-2962.0913,1003.8871},
    {2606.0146,-2995.0747,1003.8871},
    {2601.6973,-2941.1292,1003.8871},
    {2581.7783,-2959.8501,1003.8871},
    {3811.2156,-2453.5735,1002.5284},
    {3828.2717,-2437.7588,1002.5284},
    {3797.6394,-2471.6860,1002.5284},
    {3778.0747,-2452.8750,1002.5284},
    {3848.7319,-2453.9375,1002.5284},
    {3828.6216,-2453.9402,1015.5284},
    {3797.5637,-2453.8789,1015.5284},
    {3855.7751,-2472.6580,1015.5284},
    {3770.3140,-2436.6235,1015.5284},
    {3811.2190,-2436.3999,1015.5284}
};
if (strcmp("/DD3", cmdtext, true, 10) == 0)
    {
        SendClientMessage(playerid, COLOR_BLUE, "You just got Teleported to Derby Map!");
        new Random = random(sizeof(RandomSpawn));
        SetPlayerPos(playerid, RandomSpawn[Random][0], RandomSpawn[Random][1], RandomSpawn[Random][2]);
        return 1;
    }



Re: How to set spawn locations on command. - ponagandlamanoj - 13.01.2014

Quote:
Originally Posted by SilentSoul
Посмотреть сообщение
Not tested but that should work.
pawn Код:
new Float:RandomSpawn[][] =
{
    {2580.9543,-2922.2375,1003.8871},
    {2580.9353,-3040.3372,1003.8871},
    {2620.9497,-2980.4980,1003.8871},
    {2662.5625,-2922.4089,1003.8871},
    {2682.1228,-2959.8835,1003.8871},
    {2663.1399,-2999.8201,1003.8871},
    {2581.3845,-2962.0913,1003.8871},
    {2606.0146,-2995.0747,1003.8871},
    {2601.6973,-2941.1292,1003.8871},
    {2581.7783,-2959.8501,1003.8871},
    {3811.2156,-2453.5735,1002.5284},
    {3828.2717,-2437.7588,1002.5284},
    {3797.6394,-2471.6860,1002.5284},
    {3778.0747,-2452.8750,1002.5284},
    {3848.7319,-2453.9375,1002.5284},
    {3828.6216,-2453.9402,1015.5284},
    {3797.5637,-2453.8789,1015.5284},
    {3855.7751,-2472.6580,1015.5284},
    {3770.3140,-2436.6235,1015.5284},
    {3811.2190,-2436.3999,1015.5284}
};
if (strcmp("/DD3", cmdtext, true, 10) == 0)
    {
        SendClientMessage(playerid, COLOR_BLUE, "You just got Teleported to Derby Map!");
        new Random = random(sizeof(RandomSpawn));
        SetPlayerPos(playerid, RandomSpawn[Random][0], RandomSpawn[Random][1], RandomSpawn[Random][2]);
        return 1;
    }
Bro!!... This error
Код HTML:
error 032: array index out of bounds (variable "RandomSpawn")



Re: How to set spawn locations on command. - SilentSoul - 13.01.2014

Quote:
Originally Posted by ponagandlamanoj
Посмотреть сообщение
Bro!!... This error
Код HTML:
error 032: array index out of bounds (variable "RandomSpawn")
Try this should work compiled.
pawn Код:
new Float:RandomSpawn[][] =
{
    {2580.9543,-2922.2375,1003.8871},
    {2580.9353,-3040.3372,1003.8871},
    {2620.9497,-2980.4980,1003.8871},
    {2662.5625,-2922.4089,1003.8871},
    {2682.1228,-2959.8835,1003.8871},
    {2663.1399,-2999.8201,1003.8871},
    {2581.3845,-2962.0913,1003.8871},
    {2606.0146,-2995.0747,1003.8871},
    {2601.6973,-2941.1292,1003.8871},
    {2581.7783,-2959.8501,1003.8871},
    {3811.2156,-2453.5735,1002.5284},
    {3828.2717,-2437.7588,1002.5284},
    {3797.6394,-2471.6860,1002.5284},
    {3778.0747,-2452.8750,1002.5284},
    {3848.7319,-2453.9375,1002.5284},
    {3828.6216,-2453.9402,1015.5284},
    {3797.5637,-2453.8789,1015.5284},
    {3855.7751,-2472.6580,1015.5284},
    {3770.3140,-2436.6235,1015.5284},
    {3811.2190,-2436.3999,1015.5284}
};
if (strcmp("/DD3", cmdtext, true, 10) == 0)
    {
        SendClientMessage(playerid, COLOR_BLUE, "You just got Teleported to Derby Map!");
        new Random = random(sizeof(RandomSpawn));
        SetPlayerPos(playerid, RandomSpawn[Random][0], RandomSpawn[Random][1], RandomSpawn[Random][2]);
        return 1;
    }



Re: How to set spawn locations on command. - ponagandlamanoj - 13.01.2014

Quote:
Originally Posted by SilentSoul
Посмотреть сообщение
Try this should work compiled.
pawn Код:
new Float:RandomSpawn[][] =
{
    {2580.9543,-2922.2375,1003.8871},
    {2580.9353,-3040.3372,1003.8871},
    {2620.9497,-2980.4980,1003.8871},
    {2662.5625,-2922.4089,1003.8871},
    {2682.1228,-2959.8835,1003.8871},
    {2663.1399,-2999.8201,1003.8871},
    {2581.3845,-2962.0913,1003.8871},
    {2606.0146,-2995.0747,1003.8871},
    {2601.6973,-2941.1292,1003.8871},
    {2581.7783,-2959.8501,1003.8871},
    {3811.2156,-2453.5735,1002.5284},
    {3828.2717,-2437.7588,1002.5284},
    {3797.6394,-2471.6860,1002.5284},
    {3778.0747,-2452.8750,1002.5284},
    {3848.7319,-2453.9375,1002.5284},
    {3828.6216,-2453.9402,1015.5284},
    {3797.5637,-2453.8789,1015.5284},
    {3855.7751,-2472.6580,1015.5284},
    {3770.3140,-2436.6235,1015.5284},
    {3811.2190,-2436.3999,1015.5284}
};
if (strcmp("/DD3", cmdtext, true, 10) == 0)
    {
        SendClientMessage(playerid, COLOR_BLUE, "You just got Teleported to Derby Map!");
        new Random = random(sizeof(RandomSpawn));
        SetPlayerPos(playerid, RandomSpawn[Random][0], RandomSpawn[Random][1], RandomSpawn[Random][2]);
        return 1;
    }
Yea bro.. Compiled.. Thank you... You got my Rep+


Re: How to set spawn locations on command. - ponagandlamanoj - 13.01.2014

I am sorry for telling this.. but i forgot to ask something.. Please make those spawns with cars bro. not just the person. Spawns with infernus. Please don't mind and help me.. :/


Re: How to set spawn locations on command. - SilentSoul - 13.01.2014

pawn Код:
new Float:RandomSpawn[][] =
{
    {2580.9543,-2922.2375,1003.8871},
    {2580.9353,-3040.3372,1003.8871},
    {2620.9497,-2980.4980,1003.8871},
    {2662.5625,-2922.4089,1003.8871},
    {2682.1228,-2959.8835,1003.8871},
    {2663.1399,-2999.8201,1003.8871},
    {2581.3845,-2962.0913,1003.8871},
    {2606.0146,-2995.0747,1003.8871},
    {2601.6973,-2941.1292,1003.8871},
    {2581.7783,-2959.8501,1003.8871},
    {3811.2156,-2453.5735,1002.5284},
    {3828.2717,-2437.7588,1002.5284},
    {3797.6394,-2471.6860,1002.5284},
    {3778.0747,-2452.8750,1002.5284},
    {3848.7319,-2453.9375,1002.5284},
    {3828.6216,-2453.9402,1015.5284},
    {3797.5637,-2453.8789,1015.5284},
    {3855.7751,-2472.6580,1015.5284},
    {3770.3140,-2436.6235,1015.5284},
    {3811.2190,-2436.3999,1015.5284}
};
if (strcmp("/DD3", cmdtext, true, 10) == 0)
    {
        SendClientMessage(playerid, COLOR_BLUE, "You just got Teleported to Derby Map!");
        new Random = random(sizeof(RandomSpawn));
        SetPlayerPos(playerid, RandomSpawn[Random][0], RandomSpawn[Random][1], RandomSpawn[Random][2]);
        new Float:x,Float:y,Float:z,Float:a,vehicle;
        GetPlayerPos(playerid,x,y,z);
        GetPlayerFacingAngle(playerid,a);
        vehicle = CreateVehicle(411,x,y,z,a,-1,1,1);
        PutPlayerInVehicle(playerid,vehicle ,0);
        return 1;
    }
EDIT: Sorry i forgot to declare vehicle , copy new codes.


Re: How to set spawn locations on command. - ponagandlamanoj - 13.01.2014

Bro!!.. after doing this.. It just creates the vehicle in the place whr i am itself. I am not teleporting to the map location... Whats the problem?..


Re: How to set spawn locations on command. - ponagandlamanoj - 13.01.2014

I fixed it by myself bro!!.. I did this

Код HTML:
if (strcmp("/DD2", cmdtext, true, 10) == 0)
    {
        SendClientMessage(playerid, COLOR_BLUE, "You just got Teleported to Derby Map!");
        new Random = random(sizeof(RandomSpawn));
        SetPlayerPos(playerid, RandomSpawn[Random][0], RandomSpawn[Random][1], RandomSpawn[Random][2]);
        new Car = CreateVehicle(411,RandomSpawn[Random][0], RandomSpawn[Random][1], RandomSpawn[Random] [2],0,0,0,0);
        PutPlayerInVehicle(playerid,Car,0);
        SetPlayerInterior(playerid, 0);
    }
But thanks for your help too.