SA-MP Forums Archive
Engine. - 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: Engine. (/showthread.php?tid=412621)



Engine. - dorperez - 02.02.2013

Hey Guys,

I created this script:
pawn Код:
if(newkeys == KEY_FIRE)
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
    switch(randaa)
    {
        case Suc:
        {
                TogglePlayerControllable(playerid, 1);
                engineOn[vehicle] = 1;
                SendClientMessage(playerid, COLOR_RED, "The engine started normaly.");
               
        }
        case Fail:
        {
                engineOn[vehicle] = 0;
                SendClientMessage(playerid, COLOR_RED, "The engine didn't start,try again.");
        }
    }
    }
    return 1;
}
The script suppost to start the engine when the player press LMB and it should randomly choose if the engine start or not,but when I press LMB(fire key) nothing happened.

Help guys,tnx ))


Re: Engine. - T0pAz - 02.02.2013

Show me the code where this variable has been used.

pawn Код:
randaa



Re: Engine. - dorperez - 02.02.2013

Quote:
Originally Posted by T0pAz
Посмотреть сообщение
Show me the code where this variable has been used.

pawn Код:
randaa
pawn Код:
enum randaa
{
        Suc,
        Fail
};
and in my script

Tnx for replay


Re: Engine. - T0pAz - 02.02.2013

You can try doing something like this.

pawn Код:
if(newkeys == KEY_FIRE)
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            new rndNum = Random(1);
    switch(rndNum)
    {
        case 1: // Success
        {
                TogglePlayerControllable(playerid, 1);
                engineOn[vehicle] = 1;
                SendClientMessage(playerid, COLOR_RED, "The engine started normaly.");
               
        }
        case 0: // Fail
        {
                engineOn[vehicle] = 0;
                SendClientMessage(playerid, COLOR_RED, "The engine didn't start,try again.");
        }
    }
    }
    return 1;
}



Re: Engine. - dorperez - 02.02.2013

Quote:
Originally Posted by T0pAz
Посмотреть сообщение
You can try doing something like this.

pawn Код:
if(newkeys == KEY_FIRE)
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            new rndNum = Random(1);
    switch(rndNum)
    {
        case 1: // Success
        {
                TogglePlayerControllable(playerid, 1);
                engineOn[vehicle] = 1;
                SendClientMessage(playerid, COLOR_RED, "The engine started normaly.");
               
        }
        case 0: // Fail
        {
                engineOn[vehicle] = 0;
                SendClientMessage(playerid, COLOR_RED, "The engine didn't start,try again.");
        }
    }
    }
    return 1;
}
I get 1 error bro:
pawn Код:
C:\GTA - San Andreas\Server\gamemodes\Rp11Back.pwn(56438) : error 017: undefined symbol "Random"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
The line:
pawn Код:
new rndNum = Random(1);



Re: Engine. - dorperez - 08.02.2013

Help .. ? :\


Re: Engine. - Riddick94 - 08.02.2013

lowercase 'R'. And that's a bad way of checking key, read SA-MP Wiki.


Re: Engine. - dorperez - 08.02.2013

Quote:
Originally Posted by Riddick94
Посмотреть сообщение
lowercase 'R'. And that's a bad way of checking key, read SA-MP Wiki.
But I don't know what is the problem P: I am here to learn P:


Re: Engine. - ThePhenix - 08.02.2013

The problem is that "Random" is invalid. It's case sensitive.

It's not the same "Random" than "random".

PHP код:
if(newkeys == KEY_FIRE)
    {
        if(
GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            new 
rndNum random(1);//"R" Lowercase.
    
switch(rndNum)
    {
        case 
1// Success
        
{
                
TogglePlayerControllable(playerid1);
                
engineOn[vehicle] = 1;
                
SendClientMessage(playeridCOLOR_RED"The engine started normaly.");
               
        }
        case 
0// Fail
        
{
                
engineOn[vehicle] = 0;
                
SendClientMessage(playeridCOLOR_RED"The engine didn't start,try again.");
        }
    }
    }
    return 
1;




Re: Engine. - dorperez - 08.02.2013

Quote:
Originally Posted by ThePhenix
Посмотреть сообщение
The problem is that "Random" is invalid. It's case sensitive.

It's not the same "Random" than "random".

PHP код:
if(newkeys == KEY_FIRE)
    {
        if(
GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            new 
rndNum random(1);//"R" Lowercase.
    
switch(rndNum)
    {
        case 
1// Success
        
{
                
TogglePlayerControllable(playerid1);
                
engineOn[vehicle] = 1;
                
SendClientMessage(playeridCOLOR_RED"The engine started normaly.");
               
        }
        case 
0// Fail
        
{
                
engineOn[vehicle] = 0;
                
SendClientMessage(playeridCOLOR_RED"The engine didn't start,try again.");
        }
    }
    }
    return 
1;

Pawno... O_o