Spawning objects in a circle - Gap appears
#1

Problem: I've built a command to spawn objects in a circle around the player (for testing). However above 50 objects (player count/spawn) a gap appears in the circle. Is my math wrong, or is there an underlying limitation in SAMP?

RESOLUTION: I changed this line and now the circle works perfectly:
PHP код:
new Float:float(360)/float(count); 


PHP код:
CMD:mtest(playeridparams[])
{
    if(
pInfo[playerid][pAdmin] < 5) return SCM(playeridCOLOR_GREY"ERROR: You don't have access to this command, sorry.");
    new 
Float:xFloat:yFloat:zcountspawn;
    if(
sscanf(params"ii"countspawn))
    {
        
SCM(playeridCOLOR_WHITE"USE: /mtest [player count] [spawn distance]");
        
SCM(playeridCOLOR_YELLOW"WARNING: This command uses open parameters, so be careful.");
        return 
1;
    }
    new 
Float:360/count;
    for(new 
i=0i<counti++)
    {
        
GetPlayerPos(playeridxyz);
        new 
Float:a2 a*(i+1);
        
+= (spawn floatsin(-a2degrees));
        
+= (spawn floatcos(-a2degrees));
        
CreateDynamicObject(13646xyz-100, (-(a*i)+180));
    }
    new 
str[128];
    
format(strsizeof(str), "[%s] %s (%i) has created a map test."GetAdminLevelName(pInfo[playerid][pAdmin]), GetName(playerid), playerid);
    
CallLocalFunction("AdminMessage""si"strCOLOR_RED);
    return 
1;

Reply
#2

Quote:
Код:
new Float:a = 360/count
Doesn't that give a tag mismatch, though? Both values are integers so the output should also be an integer. If you want the output to be a float then at least one of the operands should be a float. 360 divided by 50 as integers gives 7; and 7 * 50 = 350 which explains the gap.
Reply
#3

You don't need to get the player's position in every iterator, and declare "a" outside the loop as well.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)