SA-MP Forums Archive
їComo soluciono esto? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Español/Spanish (https://sampforum.blast.hk/forumdisplay.php?fid=29)
+---- Thread: їComo soluciono esto? (/showthread.php?tid=594109)



їComo soluciono esto? - teamz - 13.11.2015

Al utilizar muchas veces йste comando puede floodear los autos.. Como se puede solucionar
pawn Код:
if (!strcmp("/Landstalker", cmdtext, true))
{
        new Float:X,Float:Y,Float:Z,Float:ROT;
        GetPlayerPos(playerid,X,Y,Z);
        GetPlayerFacingAngle (playerid,ROT);
        SpawnAuto[playerid] = CreateVehicle(400,x,y,z,ROT, -1, -1, 60); SetVehiclePos(SpawnAuto[playerid], X, Y, Z);
        PutPlayerInVehicle(playerid,SpawnAuto[playerid],0);
        GameTextForPlayer(playerid,"~h~~w~Landstalker~n~~h~~w~ID:~h~~r~400",2500,1);
        return 1;
}



Respuesta: їComo soluciono esto? - INKISICION - 13.11.2015

Quote:
Originally Posted by teamz
Посмотреть сообщение
Al utilizar muchas veces йste comando puede floodear los autos.. Como se puede solucionar
pawn Код:
if (!strcmp("/Landstalker", cmdtext, true))
{
        new Float:X,Float:Y,Float:Z,Float:ROT;
        GetPlayerPos(playerid,X,Y,Z);
        GetPlayerFacingAngle (playerid,ROT);
        SpawnAuto[playerid] = CreateVehicle(400,x,y,z,ROT, -1, -1, 60); SetVehiclePos(SpawnAuto[playerid], X, Y, Z);
        PutPlayerInVehicle(playerid,SpawnAuto[playerid],0);
        GameTextForPlayer(playerid,"~h~~w~Landstalker~n~~h~~w~ID:~h~~r~400",2500,1);
        return 1;
}
https://sampwiki.blast.hk/wiki/DestroyVehicle


Respuesta: їComo soluciono esto? - teamz - 13.11.2015

Al sentenciar йso:

if(SpawnedVehicles[playerid] != 0) DestroyVehicle(SpawnedVehicles[playerid]);

ocurre un bug infernal donde despues de sacar 50 o menos vehнculos se remueven y si uno saca un infernus y otro una nrg se desparecen.


Respuesta: їComo soluciono esto? - Goncho28 - 13.11.2015

Crea una variable por ejemplo "CreoVehiculo" donde 1 sea si ya creу un coche y 0 si no creу ninguno.

Al usar el CMD solo lo podrбn usar quienes tengan la variable en 0, y cuando se creй el coche la pones en 1, al destruir el coche en 0.


Respuesta: їComo soluciono esto? - teamz - 14.11.2015

pawn Код:
if (!strcmp("/Landstalker", cmdtext, true))
{
        if(CreoVehiculo[playerid] == 1)
          {
           DestroyVehicle(playerid);
           CreoVehiculo[playerid] = 1;
           new Float:X,Float:Y,Float:Z,Float:ROT;
           GetPlayerPos(playerid,X,Y,Z);
           GetPlayerFacingAngle (playerid,ROT);
           SpawnAuto[playerid] = CreateVehicle(400,X,Y,Z,ROT, -1, -1, 60); SetVehiclePos(SpawnAuto[playerid], X, Y, Z);
           PutPlayerInVehicle(playerid,SpawnAuto[playerid],0);
           return 1;
          }
         
        if(CreoVehiculo[playerid] == 0)
        {
        CreoVehiculo[playerid] = 1;
        new Float:X,Float:Y,Float:Z,Float:ROT;
        GetPlayerPos(playerid,X,Y,Z);
        GetPlayerFacingAngle (playerid,ROT);
        SpawnAuto[playerid] = CreateVehicle(400,X,Y,Z,ROT, -1, -1, 60); SetVehiclePos(SpawnAuto[playerid], X, Y, Z);
        PutPlayerInVehicle(playerid,SpawnAuto[playerid],0);
        return 1;
        }
}



Respuesta: їComo soluciono esto? - x3378 - 14.11.2015

No hace falta aсadir otra variable.

Код:
#if !defined IsValidVehicle
    native IsValidVehicle(vehicleid);
#endif

public OnPlayerConnect(playerid)
{
    SpawnAuto[playerid] = INVALID_VEHICLE_ID;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    if(IsValidVehicle(SpawnAuto[playerid]))
    {
        DestroyVehicle(SpawnAuto[playerid]);
    }
    return 1;
}

if(!strcmp("/landstalker", cmdtext, true))
{
    new Float:fX, Float:fY, Float:fZ, Float:fAngle;
	
    GetPlayerPos(playerid, fX, fY, fZ);
    GetPlayerFacingAngle(playerid, fAngle);
	
    if(IsValidVehicle(SpawnAuto[playerid])) DestroyVehicle(SpawnAuto[playerid]);
	
    SpawnAuto[playerid] = CreateVehicle(400, fX, fY, fZ, fAngle, random(258), random(258), -1);
	
    LinkVehicleToInterior(SpawnAuto[playerid], GetPlayerInterior(playerid));
    SetVehicleVirtualWorld(SpawnAuto[playerid], GetPlayerVirtualWorld(playerid));
	
    PutPlayerInVehicle(playerid, SpawnAuto[playerid], 0);
    GameTextForPlayer(playerid, "~h~~w~Landstalker~n~~h~~w~ID:~h~~r~400", 2500, 1);
}



Respuesta: їComo soluciono esto? - Th3Cr4k3r - 14.11.2015

Quote:
Originally Posted by x3378
Посмотреть сообщение
No hace falta aсadir otra variable.

Код:
#if !defined IsValidVehicle
    native IsValidVehicle(vehicleid);
#endif

public OnPlayerConnect(playerid)
{
    SpawnAuto[playerid] = INVALID_VEHICLE_ID;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    if(IsValidVehicle(SpawnAuto[playerid]))
    {
        DestroyVehicle(SpawnAuto[playerid]);
    }
    return 1;
}

if(!strcmp("/landstalker", cmdtext, true))
{
    new Float:fX, Float:fY, Float:fZ, Float:fAngle;
	
    GetPlayerPos(playerid, fX, fY, fZ);
    GetPlayerFacingAngle(playerid, fAngle);
	
    if(IsValidVehicle(SpawnAuto[playerid])) DestroyVehicle(SpawnAuto[playerid]);
	
    SpawnAuto[playerid] = CreateVehicle(400, fX, fY, fZ, fAngle, random(258), random(258), -1);
	
    LinkVehicleToInterior(SpawnAuto[playerid], GetPlayerInterior(playerid));
    SetVehicleVirtualWorld(SpawnAuto[playerid], GetPlayerVirtualWorld(playerid));
	
    PutPlayerInVehicle(playerid, SpawnAuto[playerid], 0);
    GameTextForPlayer(playerid, "~h~~w~Landstalker~n~~h~~w~ID:~h~~r~400", 2500, 1);
}
Asн es, como dice x3378 no es necesario aсadir otra variable cuando lo puedes hacer de estб manera... Si aсades otra variable lo que estarбs sobrecargando la GM innecesariamente.


Respuesta: їComo soluciono esto? - Zume - 14.11.2015

Obviamente que sн, no es necesario y es mejor trabajar ese cуdigo sin la variable extra, pero la palabra "sobrecargando" en este caso es muy extremista..


Respuesta: їComo soluciono esto? - DesingMyCry - 14.11.2015

Un programador, no piensa asн Zume.


Respuesta: їComo soluciono esto? - teamz - 14.11.2015

Muchas gracias, sн sabнa que no estaba tan optimizado de йsa manera, otra pregunta que es INVALID_VEHICLE_ID a quй se refiere