[Ajuda] Oq tem de errado?...
#1

Bom peguei um fs de piloto automatico, mais quando eu aperto a tecla aparece, ativado e desativado no chat ao mesmo tempo..

PHP код:
#include <a_samp>
#define COLOR_MESSAGE_YELLOW 0xFFDD00AA
#define COLOR_GREY 0xAFAFAFAA
new Float:PlayerCruiseSpeed[MAX_PLAYERS];
new 
Float:PlayerHeadingAngle[MAX_PLAYERS];
new 
CCKey KEY_ACTION//Cruise Control Key - change this if you need
/*  keys that can be used:
        KEY_ACTION (LCTRL)
        KEY_FIRE (mouse click)
        KEY_SUBMISSION (2)
        KEY_LOOK_BEHIND
        or others you know
*/
forward CruiseControl(playerid);
public 
OnFilterScriptInit()
{
        print(
"[Cruise Control system by Mick88: LOADED]");
        return 
1;
}
public 
OnFilterScriptExit()
{
        return 
1;
}
public 
OnPlayerCommandText(playeridcmdtext[])
{
    new 
cmd[256];
        new 
idx;
        
cmd strtok(cmdtextidx);
        if (
strcmp(cmd"/cc"true) == 0)
        {
        
SendClientMessage(playeridCOLOR_MESSAGE_YELLOW":: Piloto automбtico feito pelos .:XTREME's:. ::");
        
SendClientMessage(playeridCOLOR_MESSAGE_YELLOW"*Piloto automбtico vai ajudar vocк ficar em uma mesma velocidade apertando o botгo de atalho");
        
SendClientMessage(playeridCOLOR_MESSAGE_YELLOW"*Para usar, verefique a sua velocidade desejada no carro e segure o botгo de atalho (CTRL'ESQUERDO).");
        
SendClientMessage(playeridCOLOR_MESSAGE_YELLOW"*Segurando apertado vocк pode virar seu carro avontade, subir montanhas e etc.");
        
SendClientMessage(playeridCOLOR_MESSAGE_YELLOW"*E para voltar ao normal apenas solte o botгo de atalho (CTRL'ESQUERDO).");
        return 
1;
    }
        return 
0;
}
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
        if ((
newkeys CCKey) && !(oldkeys CCKey) && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            new 
vid GetPlayerVehicleID(playerid);
                if (
GetVehicleSpeed(vid) == 0) return false;
                new 
Float:xFloat:yFloat:z;
                
GetVehicleVelocity(vidxyz);
                
GetVehicleZAngle(vidPlayerHeadingAngle[playerid]);
                
DistanceFlat(00xyPlayerCruiseSpeed[playerid]);
            
SetTimerEx("CruiseControl"100false"d"playerid);
            
SendClientMessage(playeridCOLOR_GREY"* Piloto automбtico {00ff00}Ativado"); // === Remove this if not needed ===
        
}
        else if (
PlayerCruiseSpeed[playerid] != 0.00 && (newkeys KEY_HANDBRAKE))
        {
            
PlayerCruiseSpeed[playerid] = 0.00;
        }
        return 
1;
}
GetVehicleSpeed(vehicleid)
{
        new 
Float:VxFloat:VyFloat:Vz;
        
GetVehicleVelocity(vehicleidVxVyVz);
    new 
Float:rtn;
    
rtn floatsqroot(floatpower(Vx*100,2) + floatpower(Vy*100,2));
    
rtn floatsqroot(floatpower(rtn,2) + floatpower(Vz*100,2));
    return 
floatround(rtn);
}
DistanceFlat(Float:axFloat:ayFloat:bx,Float:by, &Float:distance)
{
        
distance floatsqroot(floatpower(bx-ax,2)+floatpower(by-ay,2));
        return 
floatround(distance);
}
public 
CruiseControl(playerid)
{
    new 
vid GetPlayerVehicleID(playerid);
    new 
Float:xFloat:yFloat:z;
        
GetVehicleVelocity(vidxyz);
        new 
keysudlr;
        
GetPlayerKeys(playeridkeysudlr);
        new 
Float:angleFloat:headingFloat:speed;
        
GetVehicleZAngle(vidangle);
        
GetVehicleHeadingAngle(vidheading);
        
DistanceFlat(00xyspeed);
        if (!(
keys CCKey) || PlayerCruiseSpeed[playerid] == 0.00 || //If player released LCTRL or CruiseSpeed got cancelled by other means (spacebar press)
        
GetPlayerState(playerid) != PLAYER_STATE_DRIVER ||
        (
speed 0.7 PlayerCruiseSpeed[playerid]) || //if player slowed down too much
        
|| //if car is going upwards too fast
        
(floatabs(angle heading) > 50 && floatabs(angle heading) < 310))//if vehicle goes sideways
        
{                                   //Cruise control will turn off:
            
PlayerCruiseSpeed[playerid] = 0.00;
            
SendClientMessage(playeridCOLOR_GREY"* Piloto automбtico {ff0000}Desativado"); // === Remove this if not needed ===
                
return false;
        }
        
GetVehicleZAngle(vidPlayerHeadingAngle[playerid]);
        
GetXYVelocity(vidxyPlayerCruiseSpeed[playerid]);
        
SetVehicleVelocity(vidxyz);
        return 
SetTimerEx("CruiseControl"100false"d"playerid);
}
GetXYVelocity(vehicleid, &Float:x, &Float:yFloat:speed)
{
        new 
Float:a;
        
0.0;
        
0.0;
        
GetVehicleZAngle(vehicleida);
        
+= (speed floatsin(-adegrees));
        
+= (speed floatcos(-adegrees));
}
GetAngleToXY(Float:XFloat:YFloat:CurrentXFloat:CurrentY, &Float:Angle)
{
    
Angle atan2(Y-CurrentYX-CurrentX);
    
Angle floatsub(Angle90.0);
    if(
Angle 0.0Angle floatadd(Angle360.0);
}
GetVehicleHeadingAngle(vehicleid, &Float:a)
{
        new 
Float:xFloat:yFloat:z;
        
GetVehicleVelocity(vehicleidxyz);
        
GetAngleToXY(xy00a);
}
strtok(const string[], &index)
{
        new 
length strlen(string);
        while ((
index length) && (string[index] <= ' '))
        {
                
index++;
        }
        new 
offset index;
        new 
result[20];
        while ((
index length) && (string[index] > ' ') && ((index offset) < (sizeof(result) - 1)))
        {
                
result[index offset] = string[index];
                
index++;
        }
        
result[index offset] = EOS;
        return 
result;

Reply
#2

Usa o Fs que vem no plugin routeconnector, impossнvel fazer um piloto automбtico q preste sem um pathfinding.
Reply
#3

Mais uma duvida pra nao criar outro topico..

PHP код:
//-------------------------------------------------
//
//  NPC initialisation for Grand Larceny
//
//-------------------------------------------------

#pragma tabsize 0
#include <a_samp>

//-------------------------------------------------

public OnFilterScriptInit()
{
    
ConnectNPC("TrainDriverLV","train_lv");
    
ConnectNPC("TrainDriverLS","train_ls");
    
ConnectNPC("TrainDriverSF","train_sf");
    
    
ConnectNPC("PilotLV","at400_lv");
    
ConnectNPC("PilotSF","at400_sf");
    
ConnectNPC("PilotLS","at400_ls");

    
// Testing
    //ConnectNPC("TestIdle","onfoot_test");
    //ConnectNPC("TaxiTest","mat_test");
    
    
return 1;
}

//-------------------------------------------------
// IMPORTANT: This restricts NPCs connecting from
// an IP address outside this server. If you need
// to connect NPCs externally you will need to modify
// the code in this callback.

public OnPlayerConnect(playerid)
{
    if(
IsPlayerNPC(playerid)) {
        new 
ip_addr_npc[64+1];
        new 
ip_addr_server[64+1];
        
GetServerVarAsString("bind",ip_addr_server,64);
        
GetPlayerIp(playerid,ip_addr_npc,64);
        
        if(!
strlen(ip_addr_server)) {
            
ip_addr_server "127.0.0.1";
        }
        
        if(
strcmp(ip_addr_npc,ip_addr_server,true) != 0) {
            
// this bot is remote connecting
            
printf("NPC: Got a remote NPC connecting from %s and I'm kicking it.",ip_addr_npc);
            
Kick(playerid);
            return 
0;
        }
        
printf("NPC: Connection from %s is allowed.",ip_addr_npc);
    }
    
    return 
1;
}

//-------------------------------------------------

public OnPlayerRequestClass(playeridclassid)
{
    if(!
IsPlayerNPC(playerid)) return 1// We only deal with NPC players in this script
    
    
new playername[64];
    
GetPlayerName(playerid,playername,64);

     if(!
strcmp(playername,"TrainDriverLV",true)) {
        
SetSpawnInfo(playerid,69,255,1462.0745,2630.8787,10.8203,0.0,-1,-1,-1,-1,-1,-1);
    }
    else if(!
strcmp(playername,"TrainDriverSF",true)) {
        
SetSpawnInfo(playerid,69,255,-1942.7950,168.4164,27.0006,0.0,-1,-1,-1,-1,-1,-1);
    }
    else if(!
strcmp(playername,"TrainDriverLS",true)) {
        
SetSpawnInfo(playerid,69,255,1700.7551,-1953.6531,14.8756,0.0,-1,-1,-1,-1,-1,-1);
    }
    else if(!
strcmp(playername,"PilotLV",true)) {
        
SetSpawnInfo(playerid,69,61,0.0,0.0,0.0,0.0,-1,-1,-1,-1,-1,-1);
    }
    else if(!
strcmp(playername,"PilotSF",true)) {
        
SetSpawnInfo(playerid,69,61,0.0,0.0,0.0,0.0,-1,-1,-1,-1,-1,-1);
    }
    else if(!
strcmp(playername,"PilotLS",true)) {
        
SetSpawnInfo(playerid,69,61,0.0,0.0,0.0,0.0,-1,-1,-1,-1,-1,-1);
    }
    else if(!
strcmp(playername,"TestIdleDriver",true)) {
        
SetSpawnInfo(playerid,69,61,0.0,0.0,0.0,0.0,-1,-1,-1,-1,-1,-1);
    }
    else if(!
strcmp(playername,"TaxiTest",true)) {
        
SetSpawnInfo(playerid,69,61,0.0,0.0,0.0,0.0,-1,-1,-1,-1,-1,-1);
    }

    return 
0;
}

//-------------------------------------------------

public OnPlayerSpawn(playerid)
{
    if(!
IsPlayerNPC(playerid)) return 1// We only deal with NPC players in this script

    
new playername[64];
    
GetPlayerName(playerid,playername,64);

    if(!
strcmp(playername,"TrainDriverLV",true)) {
        
PutPlayerInVehicle(playerid,1,0);
        
SetPlayerColor(playerid,0xFFFFFFFF);
     }
    else if(!
strcmp(playername,"TrainDriverSF",true)) {
        
PutPlayerInVehicle(playerid,5,0);
        
SetPlayerColor(playerid,0xFFFFFFFF);
    }
    else if(!
strcmp(playername,"TrainDriverLS",true)) {
        
PutPlayerInVehicle(playerid,9,0);
        
SetPlayerColor(playerid,0xFFFFFFFF);
    }
    else if(!
strcmp(playername,"PilotLV",true)) {
        
PutPlayerInVehicle(playerid,13,0);
        
SetPlayerColor(playerid,0xFFFFFFFF);
    }
    else if(!
strcmp(playername,"PilotSF",true)) {
        
PutPlayerInVehicle(playerid,14,0);
        
SetPlayerColor(playerid,0xFFFFFFFF);
    }
    else if(!
strcmp(playername,"PilotLS",true)) {
        
PutPlayerInVehicle(playerid,15,0);
        
SetPlayerColor(playerid,0xFFFFFFFF);
    }
    else if(!
strcmp(playername,"TestIdleDriver",true)) {
        
PutPlayerInVehicle(playerid,43,0);
        
SetPlayerColor(playerid,0xFFFFFFFF);
    }
    else if(!
strcmp(playername,"TaxiTest",true)) {
        
PutPlayerInVehicle(playerid,968,0);
        
SetPlayerColor(playerid,0xFFFFFFFF);
    }

    return 
1;
}

//-------------------------------------------------
// EOF 
Isto й funcional?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)