question
#1

how to create random spawn?
Reply
#2

pawn Код:
new Float:RandomSpawn[][4] =
{
    // Positions, (X, Y, Z and Facing Angle)
    {-2796.9854, 1224.8180, 20.5429, 192.0335},
    {-2454.2170, 503.8759, 30.0790, 267.2932},
    {-2669.7322, -6.0874, 6.1328, 89.8853}
};
pawn Код:
public OnPlayerSpawn(playerid)
{
    new rand = random(sizeof(RandomSpawn));
 
    // SetPlayerPos to the random spawn data
    SetPlayerPos(playerid, RandomSpawn[rand][0], RandomSpawn[rand][1],RandomSpawn[rand][2]);
 
    // SetPlayerFacingAngle to the random facing angle data
    SetPlayerFacingAngle(playerid, RandomSpawn[rand][3]);
    return 1;
}
https://sampwiki.blast.hk/wiki/Random
Reply
#3

I dont understand this
Reply
#4

Quote:
Originally Posted by Christian_Bojic
Посмотреть сообщение
I dont understand this
Put this somewhere in your script:
pawn Код:
new Float:RandomSpawn[][4] =
{
    // add your own co-ords and facing angles here
    {-2796.9854, 1224.8180, 20.5429, 192.0335},
    {-2454.2170, 503.8759, 30.0790, 267.2932},
    {-2669.7322, -6.0874, 6.1328, 89.8853}
};

Put these functions under the OnPlayerSpawn callback
pawn Код:
new rand = random(sizeof(RandomSpawn));
    SetPlayerPos(playerid, RandomSpawn[rand][0], RandomSpawn[rand][1],RandomSpawn[rand][2]);
    SetPlayerFacingAngle(playerid, RandomSpawn[rand][3]);
    return 1;
Reply
#5

but I again dont understand, I know where to set it, but I dont know how to set spawn place

pawn Код:
new Float:RandomSpawn[][4] =
{
    // add your own co-ords and facing angles here
    {-2796.9854, 1224.8180, 20.5429, 192.0335},
    {-2454.2170, 503.8759, 30.0790, 267.2932},
    {-2669.7322, -6.0874, 6.1328, 89.8853}
};
what is, first cordinates, what second, what third?

pawn Код:
new rand = random(sizeof(RandomSpawn));
    SetPlayerPos(playerid, RandomSpawn[rand][0], RandomSpawn[rand][1],RandomSpawn[rand][2]);
    SetPlayerFacingAngle(playerid, RandomSpawn[rand][3]);
    return 1;
what is RandomSpawn[rand][0] ? what 1 what 2 what 3?
Reply
#6

Quote:
Originally Posted by Christian_Bojic
Посмотреть сообщение
but I again dont understand, I know where to set it, but I dont know how to set spawn place

pawn Код:
new Float:RandomSpawn[][4] =
{
    // add your own co-ords and facing angles here
    {-2796.9854, 1224.8180, 20.5429, 192.0335},
    {-2454.2170, 503.8759, 30.0790, 267.2932},
    {-2669.7322, -6.0874, 6.1328, 89.8853}
};
what is, first cordinates, what second, what third?

pawn Код:
new rand = random(sizeof(RandomSpawn));
    SetPlayerPos(playerid, RandomSpawn[rand][0], RandomSpawn[rand][1],RandomSpawn[rand][2]);
    SetPlayerFacingAngle(playerid, RandomSpawn[rand][3]);
    return 1;
what is RandomSpawn[rand][0] ? what 1 what 2 what 3?
Example:

pawn Код:
{-2796.9854, 1224.8180, 20.5429, 192.0335},
-2796.9854 = X
1224.8190 = Y
20.5429 = Z
192.0335 = Facing angle http://www.upload.ee/image/281985/as...asdasdcord.PNG



pawn Код:
RandomSpawn[rand][0]
is for this one:
pawn Код:
{-2796.9854, 1224.8180, 20.5429, 192.0335},
---------------------------------------------------------------------

pawn Код:
RandomSpawn[rand][1]
for this one:
pawn Код:
{-2454.2170, 503.8759, 30.0790, 267.2932},

----------------------------------------------------------------------

pawn Код:
RandomSpawn[rand][2]
is for this one:
pawn Код:
{-2669.7322, -6.0874, 6.1328, 89.8853}

--------------------------------------------------------------

if you add more spawns to this list:
pawn Код:
{-2796.9854, 1224.8180, 20.5429, 192.0335},
    {-2454.2170, 503.8759, 30.0790, 267.2932},
    {-2669.7322, -6.0874, 6.1328, 89.8853}
(example:
pawn Код:
{-2796.9854, 1224.8180, 20.5429, 192.0335},
    {-2454.2170, 503.8759, 30.0790, 267.2932},
{-3784.2170, 503.8759, 30.0790, 267.2932},
    {-2669.7322, -6.0874, 6.1328, 89.8853}
)

then also keep adding:
pawn Код:
RandomSpawn[rand][3]
pawn Код:
RandomSpawn[rand][4]
etc.

goodluck,

-J
Reply
#7

ooo thanks man, my general question is what is, randomspawn[rand] xD
Reply
#8

Quote:
Originally Posted by Christian_Bojic
Посмотреть сообщение
ooo thanks man, my general question is what is, randomspawn[rand] xD
You mean in
pawn Код:
SetPlayerPos(playerid, RandomSpawn[rand][0], RandomSpawn[rand][1],RandomSpawn[rand][2]);
?

(example) RandomSpawn[rand][o] redirects to {-2796.9854, 1224.8180, 20.5429, 192.0335},

dunno how to explain -.-

goodluck!
Reply
#9

omg

E:\SErver\gamemodes\SFRJ.pwn(104) : error 017: undefined symbol "RandomSpawn"
E:\SErver\gamemodes\SFRJ.pwn(104) : error 029: invalid expression, assumed zero
E:\SErver\gamemodes\SFRJ.pwn(104) : warning 215: expression has no effect
E:\SErver\gamemodes\SFRJ.pwn(106) : error 017: undefined symbol "RandomSpawn"
E:\SErver\gamemodes\SFRJ.pwn(106) : warning 215: expression has no effect
E:\SErver\gamemodes\SFRJ.pwn(106) : error 001: expected token: ";", but found "]"
E:\SErver\gamemodes\SFRJ.pwn(106) : error 029: invalid expression, assumed zero
E:\SErver\gamemodes\SFRJ.pwn(106) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


6 Errors.

help
Reply
#10

Quote:
Originally Posted by Christian_Bojic
Посмотреть сообщение
omg

E:\SErver\gamemodes\SFRJ.pwn(104) : error 017: undefined symbol "RandomSpawn"
E:\SErver\gamemodes\SFRJ.pwn(104) : error 029: invalid expression, assumed zero
E:\SErver\gamemodes\SFRJ.pwn(104) : warning 215: expression has no effect
E:\SErver\gamemodes\SFRJ.pwn(106) : error 017: undefined symbol "RandomSpawn"
E:\SErver\gamemodes\SFRJ.pwn(106) : warning 215: expression has no effect
E:\SErver\gamemodes\SFRJ.pwn(106) : error 001: expected token: ";", but found "]"
E:\SErver\gamemodes\SFRJ.pwn(106) : error 029: invalid expression, assumed zero
E:\SErver\gamemodes\SFRJ.pwn(106) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


6 Errors.

help
Csn you post lines 104/106 here?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)