Random Events
#1

pawn Код:
C:\Users\Stunt Paradise\Desktop\SAMP R4\pawno\include\cps.inc(140) : warning 208: function with tag result used before definition, forcing reparse
C:\Users\Stunt Paradise\Desktop\SAMP R4\gamemodes\SPV4.pwn(4264) : error 017: undefined symbol "RandomEvent"
C:\Users\Stunt Paradise\Desktop\SAMP R4\gamemodes\SPV4.pwn(4265) : error 017: undefined symbol "RandomEvent"
C:\Users\Stunt Paradise\Desktop\SAMP R4\gamemodes\SPV4.pwn(4271) : error 017: undefined symbol "RandomEvent"
C:\Users\Stunt Paradise\Desktop\SAMP R4\gamemodes\SPV4.pwn(4277) : error 017: undefined symbol "RandomEvent"
C:\Users\Stunt Paradise\Desktop\SAMP R4\gamemodes\SPV4.pwn(4283) : error 017: undefined symbol "RandomEvent"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


5 Errors.
pawn Код:
public Events()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            RandomEvent = random(4);
            if (RandomEvent == 0)
            {
            GivePlayerWeapon(i, 38, 1);
                GameTextForAll("~r~~h~Minigun~n~~h~Fight!",15000,5);
            print("Debug Minigun");
            }
            if (RandomEvent == 1)
            {
                GivePlayerWeapon(i, 16, 5);
                GameTextForAll("~r~~h~Grenade~n~~h~Fight!",15000,5);
                print("Debug Grenade");
            }
            if (RandomEvent == 2)
            {
                GivePlayerWeapon(i, 9, 1);
                GameTextForAll("~r~~h~Chainsaw~n~~h~Fight!",15000,5);
                print("Debug Chainsaw");
            }
            if (RandomEvent == 3)
            {
                GivePlayerWeapon(i, 35, 3);
                GameTextForAll("~r~~h~Rocket~n~~h~Fight!",15000,5);
                print("Debug Rocket");
            }
        }
    }
}
Reply
#2

top of gamemode/filterscript :

new RandomEvent;

that will fix the 5 errors , but for the warning its something wrong in ur .inc file not the pwn
Reply
#3

Quote:
Originally Posted by Etch
top of gamemode/filterscript :

new RandomEvent;
Wow, I was so stupid I didn't realize it. Thanks
Reply
#4

np
Reply
#5

This is for everyone..

There is another problem.
It only shows

Grenade
and..
Rocket

Any solutions?

Код:
Debug Rocket
Debug Grenade
Debug Rocket
Debug Rocket
Debug Grenade
Reply
#6

i am sorry dude , but i am just a new scripter , can't help sorry
Reply
#7

That should be random as it is, try testing it a bit more and see if you get different random.
Oh and for efficiency, you might want to either use
else if or a switch instead of if, if, if
because it has to evaluate all the if's each time, where as the others it only evaluates till it finds a match.

Reply
#8

Quote:
Originally Posted by HydraX
pawn Код:
C:\Users\Stunt Paradise\Desktop\SAMP R4\pawno\include\cps.inc(140) : warning 208: function with tag result used before definition, forcing reparse
C:\Users\Stunt Paradise\Desktop\SAMP R4\gamemodes\SPV4.pwn(4264) : error 017: undefined symbol "RandomEvent"
C:\Users\Stunt Paradise\Desktop\SAMP R4\gamemodes\SPV4.pwn(4265) : error 017: undefined symbol "RandomEvent"
C:\Users\Stunt Paradise\Desktop\SAMP R4\gamemodes\SPV4.pwn(4271) : error 017: undefined symbol "RandomEvent"
C:\Users\Stunt Paradise\Desktop\SAMP R4\gamemodes\SPV4.pwn(4277) : error 017: undefined symbol "RandomEvent"
C:\Users\Stunt Paradise\Desktop\SAMP R4\gamemodes\SPV4.pwn(4283) : error 017: undefined symbol "RandomEvent"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


5 Errors.
pawn Код:
public Events()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            RandomEvent = random(4);
            if (RandomEvent == 0)
            {
            GivePlayerWeapon(i, 38, 1);
                GameTextForAll("~r~~h~Minigun~n~~h~Fight!",15000,5);
            print("Debug Minigun");
            }
            if (RandomEvent == 1)
            {
                GivePlayerWeapon(i, 16, 5);
                GameTextForAll("~r~~h~Grenade~n~~h~Fight!",15000,5);
                print("Debug Grenade");
            }
            if (RandomEvent == 2)
            {
                GivePlayerWeapon(i, 9, 1);
                GameTextForAll("~r~~h~Chainsaw~n~~h~Fight!",15000,5);
                print("Debug Chainsaw");
            }
            if (RandomEvent == 3)
            {
                GivePlayerWeapon(i, 35, 3);
                GameTextForAll("~r~~h~Rocket~n~~h~Fight!",15000,5);
                print("Debug Rocket");
            }
        }
    }
}
Let me improve your code:

pawn Код:
public Events()
{
    for( new i = 0; i < MAX_PLAYERS; i++ )
    {
        if( IsPlayerConnected( i ) )
        {
            RandomEvent = random( 4 );
           
            switch( RandomEvent )
            {
              case 0:
              {
                GameTextForPlayer( i, "~r~~h~Minigun~n~~h~Fight!", 15000, 5 );
                GivePlayerWeapon( i, 38, 1 );
                print( "Debug Minigun" );
              }
              case 1:
              {
                    GivePlayerWeapon( i, 16, 5 );
                    GameTextForPlayer( i, "~r~~h~Grenade~n~~h~Fight!", 15000, 5 );
                    print( "Debug Grenade" );
              }
              case 2:
              {
                    GivePlayerWeapon( i, 9, 1 );
                    GameTextForPlayer( i, "~r~~h~Chainsaw~n~~h~Fight!", 15000, 5 );
                    print( "Debug Chainsaw" );
              }
              case 3:
              {
                    GivePlayerWeapon( i, 35, 3 );
                    GameTextForPlayer( i, "~r~~h~Rocket~n~~h~Fight!", 15000, 5 );
                    print( "Debug Rocket" );
              }
              default:
              {
                printf( "No event could be executed, as RandomEvent = %d.", RandomEvent );
              }
            }
        }
    }
    return 1;
}
Since you were looping GameTextForAll, I thought instead of creating ANOTHER switch. And anyway, your system would show a different event for EACH player, so looping the text for ALL would be pretty stupid.

Quote:
Originally Posted by mansonh
That should be random as it is, try testing it a bit more and see if you get different random.
Oh and for efficiency, you might want to either use
else if or a switch instead of if, if, if
because it has to evaluate all the if's each time, where as the others it only evaluates till it finds a match.

^ this again.
Reply
#9

I want the random event to show for EVERY player.
Reply
#10

Quote:
Originally Posted by HydraX
I want the random event to show for EVERY player.
Yes, but you don't understand that your code will loop. Meaning a DIFFERENT EVENT will occur for EACH player as you get a NEW RandomEvent every player loop.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)