16.12.2010, 21:37
I'm trying to make a /putnitro command to be able to put nitro on vehicles but it no working can someone help me out!
pawn Код:
if(strcmp(cmd, "/putnitro", true) == 0)
{
new tempid = GetPlayerVehicleID(playerid);
if(IsSpawned[playerid] == 0) {
SendClientMessage(playerid, COLOR_ERROR, "You are dead. You cannot use this command");
return 1;
}
if(InDerby[playerid] == 1) {
SendClientMessage(playerid,COLOR_ERROR,"You cannot use this command while you are in the stadium");
return 1;
}
if(gTeam[playerid] != TEAM_MECHANIC) {
SendClientMessage(playerid,COLOR_ERROR,"You are not a Car Mechanic");
return 1;
}
if(fixedcarrecent[playerid] >=1) {
SendClientMessage(playerid,COLOR_ERROR,"Command used recently. Please wait");
return 1;
}
if(!IsValidNosVehicle(tempid)) {
SendClientMessage(playerid,COLOR_ERROR,"You cannot add nitro to this vehicle!");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /putnitro (id)");
return 1;
}
giveplayerid = strval(tmp);
if(!IsNumeric(tmp)) {
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /putnitro (id) ID Must be a number");
return 1;
}
if(!IsPlayerConnected(giveplayerid)) {
format(szstring, sizeof(szstring), "ID (%d) is not an active player", giveplayerid);
SendClientMessage(playerid, COLOR_ERROR, szstring);
return 1;
}
if(GetDistanceBetweenPlayers(playerid,giveplayerid) > 5) {
format(szstring, sizeof(szstring), "(%d) Is not close enough. You cannot add nitro to that players vehicle",giveplayerid);
SendClientMessage(playerid, COLOR_ERROR, szstring);
return 1;
}
GetPlayerName(playerid,mname, 24);
GetPlayerName(giveplayerid, pname, 24);
if(!IsPlayerInAnyVehicle(giveplayerid)) {
format(szstring, sizeof(szstring), "%s(%d) is not in any vehicle",pname,giveplayerid);
SendClientMessage(playerid, COLOR_ERROR, szstring);
return 1;
}
if(IsValidNosVehicle(tempid)) {
AddVehicleComponent(tempid, 1009);
new mrand = random(10000);
oscore = GetPlayerScore(playerid);
GivePlayerMoney(giveplayerid,-mrand);
GivePlayerMoney(playerid,mrand);
SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_NITRO ADDED_|");
format(szstring, sizeof(szstring), "Mechanic %s(%d) has added nitro to your vehicle for $%d",mname,playerid,mrand);
SendClientMessage(giveplayerid,COLOR_DODGERBLUE, szstring);
SendClientMessage(playerid, 0xA9A9A9AA, "|_NITRO ADDED_|");
format(szstring, sizeof(szstring), "You have added nitro to %s(%d)s vehicle. You earned $%d", pname,giveplayerid,mrand);
SendClientMessage(playerid,COLOR_DODGERBLUE, szstring);
SetPlayerScore(playerid, oscore +1);
return 1;
}
else {
format(szstring, sizeof(szstring), "%s(%d) is not the driver of the vehicle",pname,giveplayerid);
SendClientMessage(giveplayerid,COLOR_DODGERBLUE, szstring);
}
return 1;
}