I fucked things up.
#1

Well i just got back into scripting and i was trying to make a command. Iґve tested it out ingame and it doesenґt seem to work, we weґre standing right next to each other almost genitals to genitals and it still said i was out of range.

pawn Код:
if (strcmp(cmd, "/show", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new choice[32];
            choice = strtok(cmdtext, idx);
            tmp = strtok(cmdtext, idx);
            giveplayerid = ReturnUser(tmp);
            if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /show [playerid] [mata/matb/matc/crack/pot/money]");
            if(IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_GREY, "This player isn't logged in.");
            if(giveplayerid == playerid) return SendClientMessage(playerid, COLOR_GREY, "You can't show this to yourself!");
            if(giveplayerid != INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREY, "This is not an valid ID.");
            if (!ProxDetectorS(2.0, playerid, giveplayerid))
            {
                SendClientMessage(playerid, COLOR_GREY, "That player isn't near you.");
                return 1;
            }
            if (strcmp(choice, "mata", true) == 0)
            {
                new amount = PlayerInfo[playerid][pMats];
                if(amount < 1)
                {
                    SendClientMessage(playerid, COLOR_GREY, "You do not have any A materials!");
                    return 1;
                }
                format(string, sizeof(string), "%s has shown you %d A Materials.",  GetName(playerid), amount);
                SendClientMessage(giveplayerid, COLOR_GRAD2, string);

                format(string, sizeof(string), "You have shown %s your %d A Materials.", GetName(giveplayerid), amount);
                SendClientMessage(playerid, COLOR_GRAD2, string);

                format(string, sizeof(string), "* %s has shown %s some A Materials.", GetName(playerid), GetName(giveplayerid));
                ProxDetector(20.0, playerid, string, COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED);
                ApplyAnimation(playerid,"DEALER", "DEALER_DEAL",4.0,0,0,0,0,0);
                ApplyAnimation(giveplayerid,"DEALER", "DEALER_DEAL",4.0,0,0,0,0,0);
                return 1;
            }
            if (strcmp(choice, "matb", true) == 0)
            {
                new amount = PlayerInfo[playerid][pMatsb];
                if(amount < 1)
                {
                    SendClientMessage(playerid, COLOR_GREY, "You do not have any B materials!");
                    return 1;
                }
                format(string, sizeof(string), "%s has shown you %d B Materials.",  GetName(playerid), amount);
                SendClientMessage(giveplayerid, COLOR_GRAD2, string);

                format(string, sizeof(string), "You have shown %s your %d B Materials.", GetName(giveplayerid), amount);
                SendClientMessage(playerid, COLOR_GRAD2, string);

                format(string, sizeof(string), "* %s has shown %s some B Materials.", GetName(playerid), GetName(giveplayerid));
                ProxDetector(20.0, playerid, string, COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED);
                ApplyAnimation(playerid,"DEALER", "DEALER_DEAL",4.0,0,0,0,0,0);
                ApplyAnimation(giveplayerid,"DEALER", "DEALER_DEAL",4.0,0,0,0,0,0);
                return 1;
            }
            if (strcmp(choice, "matc", true) == 0)
            {
                new amount = PlayerInfo[playerid][pMatsc];
                if(amount < 1)
                {
                    SendClientMessage(playerid, COLOR_GREY, "You do not have any C materials!");
                    return 1;
                }
                format(string, sizeof(string), "%s has shown you %d C Materials.",  GetName(playerid), amount);
                SendClientMessage(giveplayerid, COLOR_GRAD2, string);

                format(string, sizeof(string), "You have shown %s your %d C Materials.", GetName(giveplayerid), amount);
                SendClientMessage(playerid, COLOR_GRAD2, string);

                format(string, sizeof(string), "* %s has shown %s some C Materials.", GetName(playerid), GetName(giveplayerid));
                ProxDetector(20.0, playerid, string, COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED);
                ApplyAnimation(playerid,"DEALER", "DEALER_DEAL",4.0,0,0,0,0,0);
                ApplyAnimation(giveplayerid,"DEALER", "DEALER_DEAL",4.0,0,0,0,0,0);
                return 1;
            }
            if (strcmp(choice, "crack", true) == 0)
            {
                new amount = PlayerInfo[playerid][pCrack];
                if(amount < 1)
                {
                    SendClientMessage(playerid, COLOR_GREY, "You do not have any crack!");
                    return 1;
                }
                format(string, sizeof(string), "%s has shown you %d grams of crack.",  GetName(playerid), amount);
                SendClientMessage(giveplayerid, COLOR_GRAD2, string);

                format(string, sizeof(string), "You have shown %s your %d grams of crack.", GetName(giveplayerid), amount);
                SendClientMessage(playerid, COLOR_GRAD2, string);

                format(string, sizeof(string), "* %s has shown %s some crack.", GetName(playerid), GetName(giveplayerid));
                ProxDetector(20.0, playerid, string, COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED);
                ApplyAnimation(playerid,"DEALER", "DEALER_DEAL",4.0,0,0,0,0,0);
                ApplyAnimation(giveplayerid,"DEALER", "DEALER_DEAL",4.0,0,0,0,0,0);
                return 1;
            }
            if (strcmp(choice, "pot", true) == 0)
            {
                new amount = PlayerInfo[playerid][pPot];
                if(amount < 1)
                {
                    SendClientMessage(playerid, COLOR_GREY, "You do not have any pot!");
                    return 1;
                }
                format(string, sizeof(string), "%s has shown you %d grams of pot.",  GetName(playerid), amount);
                SendClientMessage(giveplayerid, COLOR_GRAD2, string);

                format(string, sizeof(string), "You have shown %s your %d grams of pot.", GetName(giveplayerid), amount);
                SendClientMessage(playerid, COLOR_GRAD2, string);

                format(string, sizeof(string), "* %s has shown %s some pot.", GetName(playerid), GetName(giveplayerid));
                ProxDetector(20.0, playerid, string, COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED);
                ApplyAnimation(playerid,"DEALER", "DEALER_DEAL",4.0,0,0,0,0,0);
                ApplyAnimation(giveplayerid,"DEALER", "DEALER_DEAL",4.0,0,0,0,0,0);
                return 1;
            }
            if (strcmp(choice, "money", true) == 0)
            {
                new amount = PlayerInfo[playerid][pMatsc];
                if(amount < 1)
                {
                    SendClientMessage(playerid, COLOR_GREY, "You do not have any money!");
                    return 1;
                }
                format(string, sizeof(string), "%s has shown you %d dollars",  GetName(playerid), amount);
                SendClientMessage(giveplayerid, COLOR_GRAD2, string);

                format(string, sizeof(string), "You have shown %s your %d dollars.", GetName(giveplayerid), amount);
                SendClientMessage(playerid, COLOR_GRAD2, string);

                format(string, sizeof(string), "* %s has shown %s some money.", GetName(playerid), GetName(giveplayerid));
                ProxDetector(20.0, playerid, string, COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED);
                ApplyAnimation(playerid,"DEALER", "DEALER_DEAL",4.0,0,0,0,0,0);
                ApplyAnimation(giveplayerid,"DEALER", "DEALER_DEAL",4.0,0,0,0,0,0);
                return 1;
            }
        }
        return 1;
    }
Reply
#2

You could just use IsPlayerInRangeOfPoint for the range check (look it up on the wiki), obviously I don't know how your ProxDectorS function looks like but still.
Reply
#3

This could be useful:

pawn Код:
stock IsPlayerNearPlayer(playerid, n_playerid, Float:radius){ //CoaPsyFactor
    new Float:npx, Float:npy, Float:npz;
    GetPlayerPos(n_playerid, npx, npy, npz);
    if(IsPlayerInRangeOfPoint(playerid, radius, npx, npy, npz)){
        return true;
    }else{
        return false;
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)