Blank line in chatbox
#1

Ok so I get a blank line or like a space in the chatbox with this code, and I don't know why (it could also be what runs above it if this code is fine),

pawn Код:
public StartingTheVehicle(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            new RandomStart;
            new string[128];
            new sendername[MAX_PLAYER_NAME];
            RandomStart = random(4);
            switch(RandomStart)
            {
                case 0,1,2,3:
                {
                    engineOn[GetPlayerVehicleID(playerid)] = true;
                    TogglePlayerControllable(playerid, true);
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    format(string, sizeof(string), "* Vehicle's engine starts (( %s )).", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
                    gEngine[playerid] = 1;
                }
Its like this:
Код:
Stranger enters his vehicle.
Stranger reaches for a key and begins to insert it in the ignition.

"* Vehicle's engine starts (( Stranger)).
Anyone see a problem?
Reply
#2

Can you show us the function for the Stranger Enters Vehicle and reaches for a key etc.
Also what are your color defines?
Reply
#3

That text was just an example, but here is the code that normally would be above that:

pawn Код:
format(string, sizeof(string), "* %s spins a key and tries to start vehicle engine.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
                    SetTimerEx("StartingTheVehicle",3500,0,"i",playerid);//The timer that gives the code I put in the first post
                    GameTextForPlayer(playerid, "~w~Starting vehicle engine...",3500,3);
                    gEngine[idcar] = 1;
                    new engine,lights,alarm,doors,bonnet,boot,objective;
                    GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective);
                    SetVehicleParamsEx(GetPlayerVehicleID(playerid), 1, lights, 0, 0, 0, 0, 0);
                    new y, m, d;
                    new h,mi,s;
                    getdate(y,m,d);
                    gettime(h,mi,s);
                    format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /engine",d,m,y,h,mi,s,sendername);
                    CommandLog(string);
                    return 1;
                }
The color defines are fine, I use them for other things in my script without problems.
Reply
#4

Firstly, I suggest that you switch from ProxDetector to SendNearbyMessage, it's more updated and more efficient. Here is the code:

pawn Код:
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;
}

Second, I don't see any errors in your code. Check your timer function and make sure you aren't sending a blank format or double sending.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)