Random text - 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: Random text (
/showthread.php?tid=314789)
Random text -
BGMike - 31.01.2012
Hello, is there any scripting function for random text or how to make a function that randomly selects one of these texts:
Streetrace1
Streetrace2
Streetrace3
Re: Random text -
lamarr007 - 31.01.2012
pawn Код:
new randmsg = random(3)
switch(randmsg)
{
case 0: SendClientMessage(playerid, color, "Streetrace1");
case 1: SendClientMessage(playerid, color, "Streetrace2");
case 2: SendClientMessage(playerid, color, "Streetrace3");
}
Re: Random text -
Konstantinos - 31.01.2012
pawn Код:
// At The Top
new
RandomText[ ][ ] =
{
"Streetrace1",
"Streetrace2",
"Streetrace3"
}
// There you want to get it random
new
rand = random( sizeof( RandomText ) );
SendClientMessage( playerid, -1, RandomText[ rand ] );
Re: Random text -
doreto - 31.01.2012
PHP код:
forward SendMSG();//--
forward close();--//-- at top
new RandomMSG[][] =//--
{
"Streetrace1",
"Streetrace2",
"Streetrace3"
};//--
public SendMSG()
{
new randMSG = random(sizeof(RandomMSG));
SendClientMessageToAll(0x8739C6FF, RandomMSG[randMSG]);
return 1;
}
// past there were you wont
Re: Random text -
BGMike - 31.01.2012
Actually I want to make a race mission and there is my codes:
Код:
new srrm, rchoosen;
new Float: srx1, Float: sry1, Float: srz1, Float: srx2, Float: sry2, Float: srz2;
new RandomRace[][] =
{
"Streetrace1",
"Streetrace2"
};
new Float:Streetrace1[4][3] = {
{2066.7275,852.1683,6.2950},
{2067.2214,977.6674,10.1318},
{2068.9685,1090.7994,10.2382},
{2069.7595,1187.7134,10.2384}
};
new Float:Streetrace2[4][3] = {
{2046.0261,1275.2041,10.2410},
{2046.0046,1184.4506,10.2371},
{2045.7842,1061.9788,10.2382},
{2045.3105,943.6448,9.4538}
};
forward StartStreetrace();
public StartStreetrace()
{
srrm = random(sizeof(RandomRace));
rchoosen = RandomRace[srrm]; // line 8425
srx1 = rchoosen[0][0]; // line 8426
sry1 = rchoosen[0][1];
srz1 = rchoosen[0][2];
GameTextForAll("~w~Mission ~n~~b~Streetrace", 5000, 1);
Streetraceactive = 1;
for(new i = 0; i <= MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
SetPlayerRaceCheckpoint(i, 0, srx1, sry1, srz1, srx2, sry2, srz2, 8.0);
}
}
return 1;
}
And there is the errors:
Код:
construction.pwn(8425) : error 006: must be assigned to an array
construction.pwn(8426) : error 028: invalid subscript (not an array or too many subscripts): "rchoosen"
construction.pwn(8426) : warning 215: expression has no effect
construction.pwn(8426) : error 001: expected token: ";", but found "]"
construction.pwn(8426) : error 029: invalid expression, assumed zero
construction.pwn(8426) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
5 Errors.
What to do ?
Re: Random text -
Konstantinos - 31.01.2012
Replace
pawn Код:
srrm = random(sizeof(RandomRace));
To
pawn Код:
new srrm = random(sizeof(RandomRace));
And This
pawn Код:
rchoosen = RandomRace[srrm]; // line 8425
srx1 = rchoosen[0][0]; // line 8426
sry1 = rchoosen[0][1];
srz1 = rchoosen[0][2];
To
pawn Код:
RandomRace[srrm][0], RandomRace[srrm][1], RandomRace[srrm][2]
Not sure, because I check the code quickly.