Help with /repair and give weapons and spawn vehicle -
lramos15 - 03.06.2013
I want my /repair to be /repair [Id] instead of just you I need a /give weapon [id] [weaponid] also could I get a /spawncar [carid]
Here is my repair command
pawn Код:
CMD:repair(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_RED, "ERROR: You are not atleast Admin Level 3!");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "You are not in a vehicle!");
if(GetPlayerState(playerid) != 2) return SendClientMessage(playerid, -1, "You are not in the driver seat!");
RepairVehicle(GetPlayerVehicleID(playerid));
SendClientMessage(playerid, -1, "Your vehicle has been sucessfully repaired!");
PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
return 1;
}
Re: Help with /repair and give weapons and spawn vehicle -
Konewka - 03.06.2013
In order to do /repair [ID] you need to use sscanf. Like so:
pawn Код:
CMD:repair(playerid, params[])
{
new id;
if(sscanf(params, "u", id) return SendClientMessage(playerid, -1, "TIP: /repair [ID]");
{
if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_RED, "ERROR: You are not atleast Admin Level 3!");
if(!IsPlayerInAnyVehicle(id)) return SendClientMessage(playerid, -1, "This player is not in the vehicle!");
if(GetPlayerState(id) != 2) return SendClientMessage(playerid, -1, "This player is not a driver!");
RepairVehicle(GetPlayerVehicleID(id));
SendClientMessage(playerid, -1, "This player's vehicle has been repaired successfully");
PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
}
return 1;
}
Re: Help with /repair and give weapons and spawn vehicle -
lramos15 - 03.06.2013
Thanks now how do I make a /give weapon [id] [weaponid] also a /spawncar
Re: Help with /repair and give weapons and spawn vehicle -
Akira297 - 03.06.2013
Instead of asking us how to do it, you should post it inside the scripting request thread.
Re: Help with /repair and give weapons and spawn vehicle -
lramos15 - 04.06.2013
So I rewrote a script I cant believe I did it but there is one problem when you type the command with nothing in it, it says my string still. Here is the code
pawn Код:
CMD:giveweapon(playerid,params[])
{
if(PlayerInfo[playerid][pAdmin] > 3)
{
new targetid,weaponid,ammo,string[128],name[MAX_PLAYER_NAME];
if(sscanf(params,"uii",targetid,weaponid,ammo)) SendClientMessage(playerid, COLOR_RED, "Usage: /giveweapon [Player ID/Name] [weapon id] [ammo]");
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Error: This player is not connected.");
if (weaponid > 46) return SendClientMessage(playerid,COLOR_RED, "ERROR: Invalid weapon id!");
GivePlayerWeapon(targetid, weaponid, ammo); //Gives the player the weapon
format(string, 128, "Admin %s(%d): has given you a weapon!", name, playerid);
SendClientMessage(playerid, COLOR_RED, string);
}
else return SendClientMessage(playerid, COLOR_RED, "You are not at least a level 3 admin!");
return 1;
}
Re: Help with /repair and give weapons and spawn vehicle -
Akira297 - 04.06.2013
So whenever you type the command with nothing inside of it, it returns the string of 'Admin....etc'?
Re: Help with /repair and give weapons and spawn vehicle -
lramos15 - 04.06.2013
Yes and the error command I also made the vehicle one and it returns the error command and the invalid vehicle id with nothing in it. Here is that code
pawn Код:
CMD:spawncar(playerid,params[])
{
if(PlayerInfo[playerid][pAdmin] > 4321)
{
new vehicleid,color1,color2,Float:x, Float:y, Float:z,Float:angle;
if(sscanf(params,"iii",vehicleid,color1,color2)) SendClientMessage(playerid, COLOR_RED, "Usage: /spawncar [vehicle id] [primary color] [secondary color]");
if (vehicleid < 400 || vehicleid > 611) return SendClientMessage(playerid,COLOR_RED, "ERROR: This vehicle does not exist!");
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, angle);
CreateVehicle(vehicleid, x+3, y, z,angle, color1, color2, -1);
}
else return SendClientMessage(playerid, COLOR_RED, "You are not Co-Owner or Owner!");
return 1;
}
Re: Help with /repair and give weapons and spawn vehicle -
lramos15 - 04.06.2013
I forgot to add about the spawn car the car respawns I dont want it to I want it to be gone on destroy