/repair cmd help - 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: /repair cmd help (
/showthread.php?tid=525956)
/repair cmd help -
saffierr - 14.07.2014
It's kinda messed up,
Quote:
CMD:repair(playerid, params[])
{
if (!IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, -1, "SERVER:Unknown Command.");
}
else if (IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, -1, "Vehicle repaired");
}
if (!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "ERROR: You're not in a vehicle.");
{
RepairVehicle(GetPlayerVehicleID(playerid));
}
return 1;
}
|
If a random players connect, and types /repair while he is not in a car the following appears: SERVER:Unknown Command , and "You're Not in a Vehicle". BUT I want that "You're not in a vehicle" doesn't appear. please help. AND if a random player is in a car and types /repair then appears SERVER:Unknown Command, but the car repairs?? weird.
SO MY QUESTION IS THIS: Can you make it that ONLY admins can use /repair and if a random players types /repair the server says SERVER:Unknown Command. and If a admin types /repair while not in car this appears: "ERROR: You're not in a vehicle" and if a admin is in a car and types /repair this appears: "Vehicle Repaired"
Re : /repair cmd help -
ManuelNeuer - 14.07.2014
If you find any error, Any thing special you didn't have and now you have it, Please let me know.
pawn Код:
CMD:repair(playerid, params[])
{
if(IsPlayerConnected(playerid)) // First check if he is online.
{
if (!IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, -1, "SERVER:Unknown Command.");
return 1;
}
if (!IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, -1, "ERROR: You're not in a vehicle.");
return 1;
}
RepairVehicle(GetPlayerVehicleID(playerid));
SendClientMessage(playerid, -1, "Vehicle repaired");
}
return 1;
}
Re: /repair cmd help -
azzerking - 14.07.2014
// First you should probably change it to return the message instead of continue, as even if one statement turns false it will continue to execute the next if statement.
pawn Код:
CMD:repair(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "SERVER:Unknown Command.");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "ERROR: You're not in a vehicle.");
RepairVehicle(GetPlayerVehicleID(playerid));
return 1;
}
Hope this helps.
Re: /repair cmd help -
saffierr - 14.07.2014
Thank you its working perfectly.
Re: /repair cmd help -
saffierr - 14.07.2014
But Do I have to type , return 1; after every SendClientMessage?
Re: /repair cmd help -
HolisticDev - 14.07.2014
Quote:
Originally Posted by saffierr
But Do I have to type , return 1; after every SendClientMessage?
|
No, you put return 1; after a command to ensure that it does not send to the player that the command is invalid.