/putnitro help
#1

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;
}
Reply
#2

What doesn't work?
Reply
#3

?
pawn Код:
if(strcmp(cmd, "/putnitro", true) == 0)
{
    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;
    }
    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;
    }
    new tempid = GetPlayerVehicleID(giveplayerid);
    if(!IsValidNosVehicle(tempid)) {
        SendClientMessage(playerid,COLOR_ERROR,"You cannot add nitro to this vehicle!");
        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;
}
Reply
#4

Lol it doesn't actually put the nitro on the players vehicle :/
Reply
#5

Quote:
Originally Posted by MWF2
Посмотреть сообщение
Lol it doesn't actually put the nitro on the players vehicle :/
EDIT: I'll try the code gangsta posted.
Reply
#6

i moved the new tempid to after getting the other player's id and changed it to get the other players vehicleid. you were giving yourself nitro.
Reply
#7

lol btw m8 that dosent add the nos to the car
Reply
#8

Quote:
Originally Posted by [XA]PuNi$HeR_
Посмотреть сообщение
lol btw m8 that dosent add the nos to the car

I tested it, it worked fine
Reply
#9

Quote:
Originally Posted by [FU]Victious
Посмотреть сообщение
What doesn't work?
you always say that, read the topic for once the posts.
Reply
#10

Quote:
Originally Posted by Porsche911
Посмотреть сообщение
read the topic for once the posts.
lrn2speakenglish

kthx
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)