SA-MP Forums Archive
HELP PLEASE! - 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: HELP PLEASE! (/showthread.php?tid=657816)



HELP PLEASE! - SapMan - 15.08.2018

Hello! I have a problem with the derby system created by adri1, the problem is that when you are on foot and you put the command / derby, the vehicle does not appear, and neither are the positions executed, only the texts appear and I am in the same place When I'm in a vehicle and I put / derby, it just works normally, the problem happens when you're standing. I realized that the problem is in "OnPlayerStateChange". Please help.

NOTE: I HAVE NOT TOUCHED ANYTHING OF THE DERBY SYSTEM, THE ERROR WAS PRACTICALLY CREATED "ONLY".

PHP Code:
public OnPlayerStateChange(playeridnewstateoldstate)
{
      switch(
PI[playerid][P_GAMEMODE])
    {
        case 
M_DERBY:
        {
            if(
oldstate == PLAYER_STATE_DRIVER//I think this is the problem
            
{
                if(
PI[playerid][P_STATUS] == STATUS_SPAWNED && PI[playerid][P_DERBY_STATUS] == PD_NORMAL)
                {
                    if(!
IsValidVehicle(PI[playerid][P_DERBY_VEHICLEID]) && PI[playerid][P_DERBY_VEHICLEID] != INVALID_VEHICLE_ID)
                    {
                        if(
IsValidVehicle(PI[playerid][P_DERBY_VEHICLEID]) && PI[playerid][P_DERBY_VEHICLEID] != INVALID_VEHICLE_ID)
                        {
                            
DestroyVehicle(PI[playerid][P_DERBY_VEHICLEID]);
                            
PI[playerid][P_DERBY_VEHICLEID] = INVALID_VEHICLE_ID;
                        }
                        
PI[playerid][P_DERBY_VEHICLEID] = CreateVehicle(DI[MODELID], DERBY_SPAWN_POSPI[playerid][P_DERBY_SLOT] ][0], DERBY_SPAWN_POSPI[playerid][P_DERBY_SLOT] ][1], DERBY_SPAWN_POSPI[playerid][P_DERBY_SLOT] ][2] + 2.0DERBY_SPAWN_POSPI[playerid][P_DERBY_SLOT] ][3], -1, -1, -1false);
                        
SetVehicleVirtualWorld(PI[playerid][P_DERBY_VEHICLEID], DERBY_VW);
                        
SetVehicleParamsEx(PI[playerid][P_DERBY_VEHICLEID], VEHICLE_PARAMS_OFFVEHICLE_PARAMS_OFFVEHICLE_PARAMS_OFF1000); 
                        
PutPlayerInVehicle(playeridPI[playerid][P_DERBY_VEHICLEID], 0);
                        return 
1;
                    }
                    
PutPlayerInVehicle(playeridPI[playerid][P_DERBY_VEHICLEID], 0);
                }
            }
            return 
1;
        }
}
return 
1;




Re: HELP PLEASE! - SapMan - 16.08.2018

HELP ME, PLEASE!


Re: HELP PLEASE! - RedRex - 16.08.2018

Can you show us derby command?


Re: HELP PLEASE! - SapMan - 16.08.2018

Quote:
Originally Posted by RedRex
View Post
Can you show us derby command?
Here it is

PHP Code:
        case ENTER_DERBY:
        {
            
PI[playerid][P_DERBY_VEHICLEID] = INVALID_VEHICLE_ID;
            switch(
DI[STATUS])
            {
                case 
DERBY_CLOSED:
                {
                    if(
TOTAL_DERBYS == 0) return 1;
                    if(
TOTAL_DERBYS_OK == 0) return 1;
                    new 
foundid DI[MAP_ID];
                    while(!
found)
                    {
                        if(
id >= TOTAL_DERBYSid 0;
                        if(
DERBY_FILE_INFO[id][DERBY_FILE_VALID])
                        {
                            
found true;
                            
DI[MAP_ID] = id;
                            break;
                        }
                        
id ++;
                    }
                    if(!
LoadDerby(DERBY_FILE_INFODI[MAP_ID] ][DERBY_NAME]))
                    {
                        
CloseDerby();
                        return 
1;
                    }
                    
DI[STATUS] = DERBY_WAIT;
                    
DI[PLAYERS] = 0;
                    
DI[COUNTDOWN_COUNTER] = 11;
                    
KillTimer(DI[COUNTDOWN_TIMER]); 
                    
DI[COUNTDOWN_TIMER] = SetTimer("DerbyCountdown"900true);
                    
PI[playerid][PR_DERBY_SLOT] = GetDerbyVehicleSlot();
                    if(
PI[playerid][PR_DERBY_SLOT] == -1)
                    {
                         
KickPlayerFromDerby(playerid);
                         
EnterPlayerMode(playeridENTER_FREEROAM);
                         return 
1;
                     }
                    
DI[PLAYERS] ++;
                    
DERBY_SLOT_USEDPI[playerid][PR_DERBY_SLOT] ] = true;
                    
PI[playerid][P_GAMEMODE] = M_DERBY;
                    
SetPlayerHealth(playerid100.0);
                    
SetPlayerArmour(playerid0.0);
                    
SetPlayerInterior(playerid0);
                    
ResetPlayerWeapons(playerid);
                    
SetPlayerVirtualWorld(playeridDERBY_WORLD);
                    if(
IsValidVehicle(PI[playerid][P_DERBY_VEHICLEID]) && PI[playerid][P_DERBY_VEHICLEID] != INVALID_VEHICLE_ID)
                    {
                        
DestroyVehicle(PI[playerid][P_DERBY_VEHICLEID]);
                        
PI[playerid][P_DERBY_VEHICLEID] = INVALID_VEHICLE_ID;
                    }
                    
TogglePlayerControllable(playeridtrue);
                    
PI[playerid][P_DERBY_STATUS] = PD_NORMAL;
                    
PI[playerid][P_DERBY_VEHICLEID] = CreateVehicle(DI[MODELID], DERBY_SPAWN_POSPI[playerid][PR_DERBY_SLOT] ][0], DERBY_SPAWN_POSPI[playerid][PR_DERBY_SLOT] ][1], DERBY_SPAWN_POSPI[playerid][PR_DERBY_SLOT] ][2] + 2.0DERBY_SPAWN_POSPI[playerid][PR_DERBY_SLOT] ][3], -1, -1, -1false);
                    
SetVehicleParamsEx(PI[playerid][P_DERBY_VEHICLEID], VEHICLE_PARAMS_OFFVEHICLE_PARAMS_OFFVEHICLE_PARAMS_OFF1000);
                    
SetVehicleVirtualWorld(PI[playerid][P_DERBY_VEHICLEID], DERBY_WORLD);
                    
PutPlayerInVehicle(playeridPI[playerid][P_DERBY_VEHICLEID], 0);
                    
TextDrawShowForPlayer(playeridTD_DERBY[9]);
                    new 
str[24]; format(strsizeof(str), "~w~%s"DI[NAME]);
                    
GameTextForPlayer(playeridstr3000,1);
                }
                case 
DERBY_WAIT:
                {
                    
PI[playerid][PR_DERBY_SLOT] = GetDerbyVehicleSlot();
                    if(
PI[playerid][PR_DERBY_SLOT] == -1)
                    {
                        
KickPlayerFromDerby(playerid);
                        
EnterPlayerMode(playeridENTER_FREEROAM);
                        return 
1;
                    }
                    
DI[PLAYERS] ++;
                    
DERBY_SLOT_USEDPI[playerid][PR_DERBY_SLOT] ] = true;
                    
PI[playerid][P_GAMEMODE] = M_DERBY;
                    
SetPlayerHealth(playerid100.0);
                    
SetPlayerArmour(playerid0.0);
                    
SetPlayerInterior(playerid0);
                    
ResetPlayerWeapons(playerid);
                    
SetPlayerVirtualWorld(playeridDERBY_WORLD);
                    if(
IsValidVehicle(PI[playerid][P_DERBY_VEHICLEID]) && PI[playerid][P_DERBY_VEHICLEID] != INVALID_VEHICLE_ID)
                    {
                        
DestroyVehicle(PI[playerid][P_DERBY_VEHICLEID]);
                        
PI[playerid][P_DERBY_VEHICLEID] = INVALID_VEHICLE_ID;
                    }
                    
TogglePlayerControllable(playeridtrue);
                    
PI[playerid][P_DERBY_STATUS] = PD_NORMAL;
                    
PI[playerid][P_DERBY_VEHICLEID] = CreateVehicle(DI[MODELID], DERBY_SPAWN_POSPI[playerid][PR_DERBY_SLOT] ][0], DERBY_SPAWN_POSPI[playerid][PR_DERBY_SLOT] ][1], DERBY_SPAWN_POSPI[playerid][PR_DERBY_SLOT] ][2] + 2.0DERBY_SPAWN_POSPI[playerid][PR_DERBY_SLOT] ][3], -1, -1, -1false);
                    
SetVehicleParamsEx(PI[playerid][P_DERBY_VEHICLEID], VEHICLE_PARAMS_OFFVEHICLE_PARAMS_OFFVEHICLE_PARAMS_OFF1000);
                    
SetVehicleVirtualWorld(PI[playerid][P_DERBY_VEHICLEID], DERBY_WORLD);
                    
PutPlayerInVehicle(playeridPI[playerid][P_DERBY_VEHICLEID], 0);
                    
TextDrawShowForPlayer(playeridTD_DERBY[9]);
                    new 
str[24]; format(strsizeof(str), "~w~%s"DI[NAME]);
                    
GameTextForPlayer(playeridstr3000,1);
                }
                case 
DERBY_RUNNING:
                {
                    
DI[PLAYERS] ++;
                    
SetPlayerVirtualWorld(playeridDERBY_WORLD);
                    
PI[playerid][P_DERBY_STATUS] = PD_NORMAL;
                    
PI[playerid][P_GAMEMODE] = M_DERBY;
                    
SetPlayerHealth(playerid100.0);
                    
SetPlayerArmour(playerid0.0);
                    
SetPlayerInterior(playerid0);
                    
ResetPlayerWeapons(playerid);
                    
SetPlayerVirtualWorld(playeridDERBY_WORLD);
                    if(
IsValidVehicle(PI[playerid][P_DERBY_VEHICLEID]) && PI[playerid][P_DERBY_VEHICLEID] != INVALID_VEHICLE_ID)
                    {
                        
DestroyVehicle(PI[playerid][P_DERBY_VEHICLEID]);
                        
PI[playerid][P_DERBY_VEHICLEID] = INVALID_VEHICLE_ID;
                    }
                    
TogglePlayerControllable(playeridtrue);
                    
TextDrawShowForPlayer(playeridTD_DERBY[10]);
                    
TextDrawShowForPlayer(playeridTD_DERBY[9]);
                    
PI[playerid][P_DERBY_STATUS] = PD_DEAD;
                    for(new 
0GetPlayerPoolSize(); <= ji++)
                    {
                        if(
IsPlayerConnected(i))
                        {
                            if(
PI[i][P_GAMEMODE] == M_DERBY)
                            {
                                if(
PI[i][P_DERBY_STATUS] == PD_NORMAL)
                                {
                                    
PI[playerid][PR_DERBY_SPEC] = i;
                                    break;
                                }
                            }
                        }
                    }
                    
TogglePlayerSpectating(playeridtrue);
                    
PlayerSpectateVehicle(playeridPIPI[playerid][PR_DERBY_SPEC] ][P_DERBY_VEHICLEID]);
                    
TextDrawSetString(TD_DERBY[9], "~w~Presiona_~g~intro_~w~para cambiar de jugador");
                    return 
1;
                }
            }
            return 
1;
        } 



Re: HELP PLEASE! - RedRex - 16.08.2018

You said you have created a Command such as /derby right? If Yes give me the code of command /derby.


Re: HELP PLEASE! - SapMan - 16.08.2018

PHP Code:
CMD:derby(playeridparams[])
{
    if(
PI[playerid][P_GAMEMODE] == M_DERBY) return 1;    
    if(
DI[PLAYERS] >= MAX_DERBY_PLAYERS)  
    {
        
SendClientMessage(playerid, -1"COMPLETE! 20/20.");
        return 
1;
    }
    
ExitPlayerGameMode(playerid);
    
JoinPlayerGameMode(playeridGAME_DERBY);
    return 
1;

The code that I mentioned before is from: JoinPlayerGameMode


Re: HELP PLEASE! - Sew_Sumi - 16.08.2018

Any filterscripts that you are running?

Link to the derby system?


Re: HELP PLEASE! - SapMan - 16.08.2018

Quote:
Originally Posted by Sew_Sumi
View Post
Any filterscripts that you are running?

Link to the derby system?
Nop.


Re: HELP PLEASE! - SapMan - 16.08.2018

I see that the problem is "PutPlayerInVehicle" when I put a timer the function is executed well.

some solution for that?

PHP Code:
SetTimerEx("test"3000false"i"playerid); //In the code
forward test(playerid);
public 
test(playerid)
{
    
PutPlayerInVehicle(playeridPI[playerid][P_DERBY_VEHICLEID], 0);
    return 
1;




Re: HELP PLEASE! - Sew_Sumi - 16.08.2018

If you haven't touched anything, I'd make sure by starting again maybe.

Even though there are no reports of an issue in the English release, it could be that simply no-one checked it.


Have you ever had it working?


That's not so much a solution, as simply forcing them in, as the original method still needs looking into as to why it's not working.


Re: HELP PLEASE! - SapMan - 16.08.2018

Yes, the before worked normally, even on Saturday I entered the / derby and it was fine. 2 days later when I went back into the / derby, this did not work, I thought I had done something wrong or moved something without meaning to, but no. I even looked for other versions of the game mode (one version was from Friday and the other from the same Saturday). But when I try those versions, the / derby does not work either.

Edit: The weirdest thing is that the "/ vehicle" command uses that function, and it runs normally.