Why it sends the message 4 times not just 1 ?
#1

Command:
PHP код:
else if(!strcmp(option, "cocaine", true, 4))
            {
                if(
sscanf(params, "s[32]i", option, amount)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /twithdraw cocaine [amount]");
                if(
PlayerInfo[playerid][pvTcocaine] < amount) return SendClientMessage(playerid, COLOR_GREY, "You don't have that much cocaine in your trunk.");
                
PlayerInfo[playerid][pvTcocaine] -= amount;
                
PlayerInfo[playerid][pcocaine] += amount;
                    
format(string, sizeof(string), "* %s opens their trunk and takes %d grams of cocaine from it.", RPN(playerid), amount);
                
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
            } 
It sends *Steve opens their trunk and takes 15 grams of cocaine from it. 4 times, but why it sends the message 4 times ?
Reply
#2

Show entire command.
Reply
#3

Try this maybe

PHP код:
else if(!strcmp(option, "cocaine", true, 1)) 
            { 
                if(
sscanf(params, "s[32]i", option, amount)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /twithdraw cocaine [amount]"); 
                if(
PlayerInfo[playerid][pvTcocaine] < amount) return SendClientMessage(playerid, COLOR_GREY, "You don't have that much cocaine in your trunk."); 
                
PlayerInfo[playerid][pvTcocaine] -= amount; 
                
PlayerInfo[playerid][pcocaine] += amount; 
                    
format(string, sizeof(string), "* %s opens their trunk and takes %d grams of cocaine from it.", RPN(playerid), amount); 
                
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE); 
            } 
Reply
#4

We need to see the whole command.
Also this function could be causing problems so it could be usefull to see it as well:

pawn Код:
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
regards, wolf.
Reply
#5

Its not cause of this function, i am using it for all my commands and they work fine, dunno what is going on with this one this is the logic of pawno
Reply
#6

Why are you repeating COLOR_PURPLE so many times?
Reply
#7

Because its my function, and this question is not related to the problem
Reply
#8

Perhaps you can show us your SendNearbyMessage?

Or maybe what are you doing before executing this at first place?

Quote:
Originally Posted by SandKing94
Посмотреть сообщение
Because its my function, and this question is not related to the problem
I can't solve you a problem without knowing what's the code is.
Reply
#9

PHP код:
stock SendNearbyMessage(playerid, Float:radius, string[], col1, col2, col3, col4, col5)
{
    new 
Float:x, Float:y, Float:z;
    
GetPlayerPos(playerid, x, y, z);
    new 
Float:ix, Float:iy, Float:iz;
    new 
Float:cx, Float:cy, Float:cz;
    foreach(
Player, i)
    {
        if(
IsPlayerLoggedIn(i))
        {
            if(
GetPlayerInterior(playerid) == GetPlayerInterior(i) && GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))
            {
                
GetPlayerPos(i, ix, iy, iz);
                
cx = (x - ix);
                
cy = (y - iy);
                
cz = (z - iz);
                if(((
cx < radius/16) && (cx > -radius/16)) && ((cy < radius/16) && (cy > -radius/16)) && ((cz < radius/16) && (cz > -radius/16)))
                {
                    
SendClientMessage(i, col1, string);
                }
                else if(((
cx < radius/8) && (cx > -radius/8)) && ((cy < radius/8) && (cy > -radius/8)) && ((cz < radius/8) && (cz > -radius/8)))
                {
                    
SendClientMessage(i, col2, string);
                }
                else if(((
cx < radius/4) && (cx > -radius/4)) && ((cy < radius/4) && (cy > -radius/4)) && ((cz < radius/4) && (cz > -radius/4)))
                {
                    
SendClientMessage(i, col3, string);
                }
                else if(((
cx < radius/2) && (cx > -radius/2)) && ((cy < radius/2) && (cy > -radius/2)) && ((cz < radius/2) && (cz > -radius/2)))
                {
                    
SendClientMessage(i, col4, string);
                }
                else if(((
cx < radius) && (cx > -radius)) && ((cy < radius) && (cy > -radius)) && ((cz < radius) && (cz > -radius)))
                {
                    
SendClientMessage(i, col5, string);
                }
            }
        }
    }
    return 
1;
} 
my stock
Reply
#10

Edit:I fixed it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)