2 problems Please help
#1

I have added a weapons dialog, and it is very unorganized. I don't understand why though. Can someone fix that please, I'm not sure why it's doing that....


pawn Код:
ShowPlayerDialog(giveplayerid,WEAPONDEALER_DIALOG,2,"Weapon Dealers List","Silenced 9mm\t\t\t $2500\nTec9\t\t\t $1000\nS/O Shotgun\t\t\t $3500\nSniper Rifle\t\t\t $15000\nAK47\t\t\t $8000\nArmour\t\t\t $500\n3 Blocks Of C4\t\t\t $3500\nParachute\t\t\t $10000\nM4\t\t\t $1000\nRifle\t\t\t $7000\nDesert Eagle\t\t\t $5000","Buy","Cancel");

Here is a screenshot:





My second problem is, My /drag command is working fine except, it's only suppose to work if a player is cuffed. Even if the player is cuffed, it says "Player is not handcuffed"

pawn Код:
if(strcmp(cmd, "/drag", true) == 0)
{
    if(IsSpawned[playerid] == 0) {
        SendClientMessage(playerid, COLOR_ERROR, "You are dead. You cannot use this command");
        return 1;
    }
    if(Jailed[playerid] ==1) {
        SendClientMessage(playerid, COLOR_ERROR, "You cannot use this command in jail");
        return 1;
    }
    if(gTeam[playerid] != TEAM_SWAT) {
        SendClientMessage(playerid,COLOR_ERROR,"You are not part of the SWAT team. Only SWAT can use this command");
        return 1;
    }
    if(cuffed[giveplayerid] == 0) {
        SendClientMessage(playerid,COLOR_ERROR,"That player is not handcuffed! Please cuff the suspect before dragging.");
        return 1;
    }
    if(InDerby[playerid] == 1) {
        SendClientMessage(playerid,COLOR_ERROR,"You cannot use this command while you are in the stadium");
        return 1;
    }
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)) {
        SendClientMessage(playerid, COLOR_ERROR, "USAGE: /drag (id)");
        return 1;
    }
    giveplayerid = strval(tmp);
    if(!IsNumeric(tmp)) {
        SendClientMessage(playerid, COLOR_ERROR, "USAGE: /drag (id) ID Must be a number");
        return 1;
    }
    giveplayerid = strval(tmp);
    if(!IsPlayerConnected(giveplayerid)) {
        format(szstring, sizeof(szstring), "ID (%d) is not an active player", giveplayerid);
        SendClientMessage(playerid, COLOR_ERROR, szstring);
        return 1;
    }
    GetPlayerName(playerid,oname, 24);
    GetPlayerName(giveplayerid, pname, 24);

    if(!IsNumeric(tmp)) {
        SendClientMessage(playerid, COLOR_ERROR, "USAGE: /drag (id) ID Must be a number");
        return 1;
    }
    if(GetDistanceBetweenPlayers(playerid,giveplayerid) > 4) {
        format(szstring, sizeof(szstring), "%s(%d) Is not close enough you cannot drag that player",pname, giveplayerid);
        SendClientMessage(playerid, COLOR_ERROR, szstring);
        return 1;
    }
    if(Jailed[giveplayerid] == 1) {
        format(szstring, sizeof(szstring), "%s(%d) Is in jail. You cannot drag a prisoner",pname, giveplayerid);
        SendClientMessage(playerid, COLOR_ERROR, szstring);
        return 1;
    }
    if(IsPlayerInAnyVehicle(playerid)) {
        SendClientMessage(playerid, COLOR_ERROR, "You are in a vehicle. You must be on foot to drag");
        return 1;
    }
    if(gTeam[playerid] == TEAM_COP && gTeam[playerid] == TEAM_ARMY && gTeam[playerid] == TEAM_SWAT && gTeam[playerid] == TEAM_MARINE && gTeam[playerid] == TEAM_AIRSUPPORT) {
        SendClientMessage(playerid, COLOR_ERROR, "You cannot drag a Law Enforcement agent");
        return 1;
    }
    if(IsPlayerInAnyVehicle(giveplayerid)) {
        SendClientMessage(playerid, COLOR_ERROR, "That player is already in a vehicle");
        return 1;
    }
    if(gLastCar[playerid] == 0) {
        SendClientMessage(playerid, COLOR_ERROR, "You must have a vehicle before using this command!");
        return 1;
    }
    if(GetPlayerWantedLevel(giveplayerid) <= 3) {
        format(szstring, sizeof(szstring), "%s(%d) Does not have a warrant. You cannot drag that player",pname,giveplayerid);
        SendClientMessage(playerid, COLOR_ERROR, szstring);
        return 1;
    }
    SendClientMessage(giveplayerid, 0xA9A9A9AA, "|_DRAGGED_|");
    format(szstring, sizeof(szstring), "%s(%d): has dragged you,use /breakcuffs to attempt an escape!",oname, playerid);
    SendClientMessage(giveplayerid, COLOR_DODGERBLUE, szstring);
    TogglePlayerControllable(giveplayerid, 0);
    oscore = GetPlayerScore(playerid);
    SetPlayerScore(playerid, oscore +1);
    SendClientMessage(playerid, 0xA9A9A9AA, "|_Criminal Dragged|");
    format(szstring, sizeof(szstring), "You have grabbed %s(%d) and thrown him into your car!", pname, giveplayerid);
    SendClientMessage(playerid, COLOR_DODGERBLUE, szstring);
    format(szstring, sizeof(szstring), "%s(%d) has grabbed %s(%d) and thrown him into his car!",oname,playerid,pname,giveplayerid);
    SendClientMessageToAll(0x00C7FFAA, szstring);
    PutPlayerInVehicle(giveplayerid,gLastCar[playerid],1);
    Dragged[giveplayerid] =1;
    format(szstring, sizeof(szstring), "~r~DRAGGED BY SWAT MEMBER~n~~w~%s(%d)",oname,playerid);
    GameTextForPlayer(giveplayerid,szstring,5000,3);
    swatrank[playerid] +=1;
    return 1;
}
Reply
#2

1. Some of the lines need more tabs(\t's) to compensate for the size of certain entries (note how '3 blocks of C4' is obviously larger than 'Tec9'.

2. Try putting 'else' in front of some of the 'if' statements (i.e else if(blah blah...))
Example:
pawn Код:
if(killerid==INVALID_PLAYER_ID)
{
    format(str,sizeof(str),"[%d] %s has killed himself",playerid,PlayerName(playerid));
    SendClientMessageToAll(0xAA0000AA,str);
}
else if(killerid==an_actual_player)
{
    format(str2,sizeof(str2),"[%d] %s was killed by [%d] %s",playerid,PlayerName(playerid),killerid,PlayerName(killerid));
    SendClientMessageToAll(0xAA0000AA,str2);
}
I believe this is not the same as:
pawn Код:
if(killerid==INVALID_PLAYER_ID)
{
    format(str,sizeof(str),"[%d] %s has killed himself",playerid,PlayerName(playerid));
    SendClientMessageToAll(0xAA0000AA,str);
}
if(killerid==an_actual_player)
{
    format(str2,sizeof(str2),"[%d] %s was killed by [%d] %s",playerid,PlayerName(playerid),killerid,PlayerName(killerid));
    SendClientMessageToAll(0xAA0000AA,str2);
}
Correct me if I'm wrong
Reply
#3

1. Ok, I understand thank you, i will fix that



2. I'm not sure how to fix that, can you show me how
Reply
#4

You need to put else in front of all of your if's other than the 1st one.
Reply
#5

Quote:
Originally Posted by John_F
Посмотреть сообщение
You need to put else in front of all of your if's other than the 1st one.
Thank you.


All i had to do was put else if on the "cuffed" part of my code. It worked.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)