28.05.2014, 23:00
Calma nгo vim aqui pra pedir pra vc cria a classe pra mim , eu ja fiz tudo , estб quase tudo perfeito , como sou iniciante dos iniciantes em pawn eu tentei criar a classe medico enfin , conseguir fazer em base a classe Mecanico sу estou com 2 problemas , como nao sei muito de pawn , tentei arriscar buquei tudo mais restaurei , enfim й o seguinte :
Como eu pegue a classe de mecanico como base ele ta dando vida pro veiculo , olha aqui o PPC_MissionsMedico
eu quero o seguinte quando o player digita /medico funciona normal , manda aviso e tals , mais quando o medico vai atй o player , ele reparar o carro , nгo a vida e tambem queria q o o botгo esquerdo sirva para restaurar sua propia vida
O Segundo problema : quando eu digito /medico quando tem medico online funciona normal , mais quando nao tem ele age como tivesse
Comando /medico :
OBS: Eu nгo traduzir os comentarios , nem troquei Assistence por Medico
Como eu pegue a classe de mecanico como base ele ta dando vida pro veiculo , olha aqui o PPC_MissionsMedico
pawn Код:
// This timer is created every time a player changes his class to assistance
forward Medico_CheckPlayers(playerid);
public Medico_CheckPlayers(playerid)
{
// Scan through all players
for (new PlayerToCheck; PlayerToCheck < MAX_PLAYERS; PlayerToCheck++)
{
// check if this player is connected
if (IsPlayerConnected(PlayerToCheck))
{
//Check if that player needs assistance
if (APlayerData[PlayerToCheck][MedicoNeeded] == true)
SetPlayerMarkerForPlayer(playerid, PlayerToCheck, 0xFF0000FF); // Make that player red to the assistance-player
else
{
// Reset the playercolor based on the player's class
switch (APlayerData[PlayerToCheck][PlayerClass])
{
case ClassTruckDriver: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassTruckDriver);
case ClassBusDriver: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassBusDriver);
case ClassPilot: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassPilot);
case ClassPolice: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassPolice);
case ClassMafia: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassMafia);
case ClassCourier: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassCourier);
case ClassAssistance: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassAssistance);
case ClassMedico: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassMedico);
}
}
}
}
}
// This function lets the assistance player repair and refuel another player's vehicle if he called for assistance
Medico_FixVehicle(playerid)
{
// Setup local variables
new vid, Float:vhealth, Float:FPayment, Payment, Float:x, Float:y, Float:z, Name[24], AssistName[24], Msg[128];
// Get the assistance player's name
GetPlayerName(playerid, AssistName, sizeof(AssistName));
// Loop through all players
for (new OtherPlayer; OtherPlayer < MAX_PLAYERS; OtherPlayer++)
{
// Check if this player is online
if (IsPlayerConnected(OtherPlayer))
{
// Check if this player isn't the assistance player
if (OtherPlayer != playerid)
{
// Check if this player needs assistance
if (APlayerData[OtherPlayer][MedicoNeeded] == true)
{
// Check if this player is the driver of a vehicle
if (GetPlayerVehicleSeat(OtherPlayer) == 0)
{
// Get the location of the player
GetPlayerPos(OtherPlayer, x, y, z);
// Check if this player is closeby the assistance player
if (IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z))
{
// Clear the other player's need for assistance
APlayerData[OtherPlayer][MedicoNeeded] = false;
// Get the name of the other player
GetPlayerName(OtherPlayer, Name, sizeof(Name));
// Get the vehicle-id of that player's vehicle
vid = GetPlayerVehicleID(OtherPlayer);
// Get the current health of that vehicle
GetVehicleHealth(vid, vhealth);
// Calculate the price to repair the vehicle (calculate as a float, then convert to integer)
FPayment = (1000.0 - vhealth) * 1.0;
Payment = floatround(FPayment, floatround_round);
// Repair the other player's vehicle
RepairVehicle(vid);
// Pay the assistance player and give 1 scorepoint
RewardPlayer(playerid, Payment * 2, 1);
// Let the other player pay for the repairs
RewardPlayer(OtherPlayer, -Payment, 0);
// Let the other player know that his vehicle has been repaired
format(Msg, 128, "{00FF00}Sua vida foi restaurada por {FFFF00}R$%i{00FF00} pelo medico \"{FFFF00}%s{00FF00}\"", Payment, AssistName);
SendClientMessage(OtherPlayer, 0xFFFFFFFF, Msg);
// Let the assistance player know who's vehicle has been repaired
format(Msg, 128, "{00FF00}Vocк salvou a vida do {FFFF00}%s{00FF00}, e ganhou {FFFF00}R$%i", Name, Payment);
SendClientMessage(playerid, 0xFFFFFFFF, Msg);
// Save the player's account
PlayerFile_Save(playerid);
}
}
}
}
}
}
return 1;
}
// This function allows the assistance player to repair and refuel his own vehicle
Medico_FixOwnVehicle(playerid)
{
// Get the vehicle-id of the player's vehicle
new vid = GetPlayerVehicleID(playerid);
// Repair the player's vehicle
RepairVehicle(vid);
// Let the player know that he has repaired and refuelled his own vehicle
SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}Vocк restaurou a sua vida.");
}
// This function gets called when the assistance player dies (or changes class)
Medico_EndJob(playerid)
{
// Kill the PlayerCheckTimer
KillTimer(APlayerData[playerid][PlayerCheckTimer]);
// Scan through all players (to reset them to their default colors for the assistance-player)
for (new PlayerToCheck; PlayerToCheck < MAX_PLAYERS; PlayerToCheck++)
{
// Check if this player is connected
if (IsPlayerConnected(PlayerToCheck))
{
// Reset the playercolor based on the player's class
switch (APlayerData[PlayerToCheck][PlayerClass])
{
case ClassTruckDriver: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassTruckDriver);
case ClassBusDriver: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassBusDriver);
case ClassPilot: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassPilot);
case ClassPolice: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassPolice);
case ClassMafia: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassMafia);
case ClassCourier: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassCourier);
case ClassAssistance: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassAssistance);
case ClassMedico: SetPlayerMarkerForPlayer(playerid, PlayerToCheck, ColorClassMedico);
}
}
}
return 1;
}
eu quero o seguinte quando o player digita /medico funciona normal , manda aviso e tals , mais quando o medico vai atй o player , ele reparar o carro , nгo a vida e tambem queria q o o botгo esquerdo sirva para restaurar sua propia vida
O Segundo problema : quando eu digito /medico quando tem medico online funciona normal , mais quando nao tem ele age como tivesse
Comando /medico :
pawn Код:
COMMAND:medico(playerid, params[])
{
// Setup local variables
new bool:AssistOnline = false, Msg[128], Name[24];
if(Tempos[playerid] > gettime())
return SendClientMessage(playerid, -1, "{FFFF00}[ERRO] {009D4F}Aguarde 2 min para chama-lo novamente!");
Tempos[playerid] = gettime() + 60*2;
// Send the command to all admins so they can see it
SendAdminText(playerid, "/medico", params);
// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// Get the player's name
GetPlayerName(playerid, Name, sizeof(Name));
// Preset the message that needs to be sent to assistance players
format(Msg, 128, "{00FF00}O jogador {FFFF00}%s{00FF00} precisa de assistкncia medica.", Name);
// Check if there is at least one assistance player online
for (new i; i < MAX_PLAYERS; i++)
{
// Check if this player is connected
if (IsPlayerConnected(i))
{
// Check if this player is assistance class
if (APlayerData[i][PlayerClass] == ClassMedico)
{
// Set the flag to indicate that at least one assistance player is online
AssistOnline = true;
// Send the assistance player a message to inform him who needs assistance
SendClientMessage(i, 0xFFFFFFFF, Msg);
}
}
}
// Check if there is at least one assistance player online
if (AssistOnline == true)
{
// Set yourself as "MedicoNeeded"
APlayerData[playerid][MedicoNeeded] = true;
// Let the player know he called for assistance
SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}Vocк ja pediu ajuda.");
}
else // No assistance is online
{
// Check if the player is the driver of a vehicle
if (GetPlayerVehicleSeat(playerid) == 0)
{
// Fully repair the vehicle (damage value and bodywork)
SetPlayerHealth(playerid, 100);
// Let the player pay for the repairs and refuel (default $700)
RewardPlayer(playerid, -700, 0);
// Let the player know he spent $2000 for auto-repair because there were no assistance players online
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Sua Vida Foi restaurada por R$700.");
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Nгo hа Medicos online.");
}
}
}
else
return 0;
// Let the server know that this was a valid command
return 1;
}
OBS: Eu nгo traduzir os comentarios , nem troquei Assistence por Medico