/fixveh command messed up -
jurtes - 16.10.2010
Hello I made this command.. It isn't working.. Can anyone fix it for me (im not getting errors it just doesn't do anything ingame)
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/fixveh", cmdtext, true, 10) == 0)
{
new vehicleid = GetPlayerVehicleID(playerid);
new name[MAX_PLAYER_NAME], string[44];
GetPlayerName(playerid, name, sizeof(name));
if(strcmp(name, "[BM]Jimmy", true) == 0)
RepairVehicle(GetClosestCar(playerid));
SetVehicleHealth(vehicleid, 1000.0);
return 1;
}
return 0;
}
Re: /fixveh command messed up -
Cameltoe - 16.10.2010
ZCMD:
pawn Код:
command(fixveh, playerid, params[])
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, somecolor, " You are not in any vehicle! ");
new
vehicleid = GetPlayerVehicleID(playerid);
RepairVehicle(vehicleid);
SetVehicleHealth(vehicleid, 1000);
return 1;
}
Re: /fixveh command messed up -
boelie - 16.10.2010
add this line
RepairVehicle(GetPlayerVehicleID(playerid));
delete the rest
Re: /fixveh command messed up -
jurtes - 16.10.2010
I want to fix a vehicle if I'm like next to it (something like IfIsPlayerInRangeOfVehicle) and I want to be the only one who is able to do it as I'm rping a mechanic. any help please?
Re: /fixveh command messed up -
Rachael - 16.10.2010
learn to use strcmp
pawn Код:
if (strcmp("/fixveh", cmdtext, true, 10) == 0)
you are asking the script to check if the first 10 characters in cmdtext[] are "/fixveh" which is only 7
This may or may not stop the command from working, but its still not correct.
pawn Код:
if(!strcmp("/fixveh",cmdtext,true))
Also, I am not sure about this, but RepairVehicle(); might not work if the vehicle has no driver.
Re: /fixveh command messed up -
Scenario - 16.10.2010
ZCMD and SSCANF:
pawn Код:
command(vrepair, playerid, params[])
{
#pragma unused params
new string[128];
if(PlayerStatistics[playerid][pAdminLevel] < 3)
return false;
if(!IsPlayerConnected(playerid))
return SendClientMessage(playerid, COLOR_WHITE, "You are not logged in!");
if(!IsPlayerInAnyVehicle(playerid))
return SendClientMessage(playerid, COLOR_WHITE, "You are not in a vehicle!");
RepairVehicle(GetPlayerVehicleID(playerid));
SendClientMessage(playerid, COLOR_WHITE, "You have fixed your vehicle.");
return 1;
}
It checks if the person who executed the command is in a vehicle, if they are, it continues if not, it won't. You'll have to edit the admin check to your liking. Hope this helps.
Re: /fixveh command messed up -
[NoV]LaZ - 16.10.2010
Quote:
Originally Posted by RealCop228
pawn Код:
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_WHITE, "You are not logged in!"); }
|
Maybe:
pawn Код:
if ( !IsPlayerConnected( playerid ) )
return SendClientMessage( playerid, -1, "You are not connected" );
That part does not make any sense.
You can't check if a player is logged in with
IsPlayerConnected.
________
Gay Blowjob
Re: /fixveh command messed up -
Scenario - 16.10.2010
Quote:
Originally Posted by [NoV]LaZ
Maybe:
pawn Код:
if ( !IsPlayerConnected( playerid ) ) return SendClientMessage( playerid, -1, "You are not connected" );
That part does not make any sense.
You can't check if a player is logged in with IsPlayerConnected.
|
I just knew somebody was going to comment on that... I have a custom command, IsPlayerConnectedEx, in which I just removed the "Ex" for this situation. I didn't bother with the message.
Re: /fixveh command messed up -
Rachael - 16.10.2010
It turns out you can RepairVehicle() without a driver, here is a thing that works. Its a little clumsy and unoptimized, but you can probably compare it with your script to get a solution to your problem.
pawn Код:
#include <a_samp>
#include <zcmd>
CMD:fixtest(playerid,params[])
{
new veh = GetPlayerVehicleID(playerid);
if(veh)
{
RepairVehicle(veh);
printf("inveh %d",veh);
return 1;
}
veh = GetClosestVehicleID(playerid);
if(veh)
{
RepairVehicle(veh);
printf("nearveh %d",veh);
return 1;
}
return 1;
}
GetClosestVehicleID(playerid)
{
new Float:min_dist = 100.0;
new Float:dist;
new Float:vehx,Float:vehy,Float:vehz;
new Float:px,Float:py,Float:pz;
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,px,py,pz);
new close_vehid;
for(new i = 1; i < MAX_VEHICLES;i++)
{
if(GetVehicleModel(i) > 0)
{
GetVehiclePos(i,vehx,vehy,vehz);
x = px - vehx;
y = py - vehy;
z = pz - vehz;
dist = floatsqroot((x * x) + (y * y) + (z * z));
if(dist < min_dist)
{
min_dist = dist;
close_vehid = i;
}
}
}
return close_vehid;
}
I left the printf commands that I used for testing in there, you can remove them if you like.
feel free to add your own messages for success / failure and whatnot.
Re: /fixveh command messed up -
jurtes - 17.10.2010
Is there anyway I can make it like only someone using my name can use it?
EDIT: it still only works when ur in the car.. Help?