SA-MP Forums Archive
[SOLVED] What's wrong with this code? (random spawn at 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [SOLVED] What's wrong with this code? (random spawn at command) (/showthread.php?tid=73661)



[SOLVED] What's wrong with this code? (random spawn at command) - Coolman12 - 16.04.2009

pawn Код:
if (!strcmp (cmdtext,"/dm1", true))
    {
        new RandomSpawn;
        RandomSpawn = random(12);
        switch (RandomSpawn)
        {
          if(RandomSpawn == 0)
          {
                SetPlayerPos(playerid,2626.7993,2711.6313,36.5386);
                SetPlayerFacingAngle(playerid,40.9613);
            }
          if(RandomSpawn == 1)
            {
                SetPlayerPos(playerid,2618.1277,2777.4395,23.8222);
                SetPlayerFacingAngle(playerid,113.3420);
            }
          if(RandomSpawn == 2)
            {
                SetPlayerPos(playerid,2597.7422,2756.1919,23.8222);
                SetPlayerFacingAngle(playerid,269.0701);
            }
          if(RandomSpawn == 3)
            {
                SetPlayerPos(playerid,2610.8132,2709.1794,25.8222);
                SetPlayerFacingAngle(playerid,258.6882);
            }
          if(RandomSpawn == 4)
            {
                SetPlayerPos(playerid,2641.9697,2703.7573,25.8222);
                SetPlayerFacingAngle(playerid,350.5166);
            }
          if(RandomSpawn == 5)
            {
                SetPlayerPos(playerid,2649.1890,2733.6533,10.8203);
                SetPlayerFacingAngle(playerid,343.9342);
            }
          if(RandomSpawn == 6)
            {
                SetPlayerPos(playerid,2666.5576,2691.5994,10.8203);
                SetPlayerFacingAngle(playerid,28.6762);
            }
          if(RandomSpawn == 7)
            {
                SetPlayerPos(playerid,2668.2385,2780.0132,10.8203);
                SetPlayerFacingAngle(playerid,57.9209);
            }
          if(RandomSpawn == 8)
            {
                SetPlayerPos(playerid,2646.6970,2804.0791,10.8203);
                SetPlayerFacingAngle(playerid,112.7547);
            }
          if(RandomSpawn == 9)
            {
                SetPlayerPos(playerid,2611.2395,2811.6638,10.8203);
                SetPlayerFacingAngle(playerid,28.6762);
            }
          if(RandomSpawn == 10)
            {
                SetPlayerPos(playerid,2666.5576,2691.5994,10.8203);
                SetPlayerFacingAngle(playerid,66.9868);
            }
          if(RandomSpawn == 11)
            {
                SetPlayerPos(playerid,2593.1904,2807.6956,10.8203);
                SetPlayerFacingAngle(playerid,52.3644);
            }
            return 1;
        }
what's wrong?

i get:

Код:
E:\Spel\Sa-mp Server\gamemodes\skipcast-stunting.pwn(948) : error 002: only a single statement (or expression) can follow each "case"
E:\Spel\Sa-mp Server\gamemodes\skipcast-stunting.pwn(948 -- 949) : error 029: invalid expression, assumed zero
E:\Spel\Sa-mp Server\gamemodes\skipcast-stunting.pwn(1084) : warning 203: symbol is never used: "strtok"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.



Re: What's wrong with this code? (random spawn at command) - Jefff - 16.04.2009

Not
Код:
if(RandomSpawn == 0)
Код:
case 0:
case 1:
etc

or remove
Код:
switch (RandomSpawn)
{
and closing brace


Re: What's wrong with this code? (random spawn at command) - OmeRinG - 16.04.2009

if you used switch why the hell would you use "if blabla"...
just do:
case 1: {
code code code
}
case 2: {
code code code
}
and so on....

and the strtok error is not releated to the command


Re: What's wrong with this code? (random spawn at command) - Coolman12 - 16.04.2009

ah, why didn't i see that



thanks^^