14.08.2013, 19:57
Well, I am using the SendLongMessage stock that was posted in the useful functions thread. And I am trying to make a /do command for a roleplay server.
The problem is, I need to make it in two lines like this:
"* STUFF HERE (( PLAYER_NAME )) ..."
"* ... MORE STUFF HERE (( PLAYER_NAME ))"
The command is working, tought the strings come out wrong.
Example:
"* STUFF HERE (( PLAYER_NAME ..."
"* ... )) MORE STUFF HERE ((PLAYER_NAME))"
I have tired many different ways, but haven't really understood how to make this work proparly.
Can anyone help me make a functioning command?
That is the sendLongMessage stock, that should be used inside here:
(( /do command << ))
Tought trying different possiblities, I am unable to make this command fully functioning..
The problem is, I need to make it in two lines like this:
"* STUFF HERE (( PLAYER_NAME )) ..."
"* ... MORE STUFF HERE (( PLAYER_NAME ))"
The command is working, tought the strings come out wrong.
Example:
"* STUFF HERE (( PLAYER_NAME ..."
"* ... )) MORE STUFF HERE ((PLAYER_NAME))"
I have tired many different ways, but haven't really understood how to make this work proparly.
Can anyone help me make a functioning command?
pawn Код:
stock sendLongMessage( playerid , color , message[] )
{
new len = strlen(message),
_iL = len / MAX_CHARS_PER_LINE;
if( ( len % MAX_CHARS_PER_LINE ) ) _iL++;
new _Line[MAX_CHARS_PER_LINE + 5];
new _:_i@Index;
while( _i@Index < _iL )
{
if( _i@Index == 0 )
strmid( _Line, message, ( _i@Index * MAX_CHARS_PER_LINE ), ( _i@Index * MAX_CHARS_PER_LINE ) + MAX_CHARS_PER_LINE );
else
strmid( _Line, message, ( _i@Index * MAX_CHARS_PER_LINE ), ( _i@Index * MAX_CHARS_PER_LINE ) + MAX_CHARS_PER_LINE );
#if defined FINAL_DOTS
if( _iL > 1 )
{
if( _i@Index == 0 )
{
format( _Line, sizeof _Line, "%s ...", _Line );
}
else if( _i@Index > 0 && ( _i@Index + 1 ) < _iL )
{
format( _Line, sizeof _Line, "... %s ...", _Line );
}
else
{
format( _Line, sizeof _Line, "... %s", _Line );
}
}
#endif
////////////
SendClientMessage( playerid, color, _Line );
///////////
_i@Index++;
}
return 1;
}
(( /do command << ))
pawn Код:
if(strcmp(cmd, "/do", true) == 0)
{
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[128];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SyntaxMessage(playerid, COLOR_SYNTAX, "/do [action]");
return 1;
}
new fxString[128]; format(fxString, sizeof(fxString), "* %s ((%s))", result, PlayerRPNameEx(playerid));
if(IsPlayerLoggedIn(playerid))
{
new Float:posx, Float:posy, Float:posz;
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
new invehicle[MAX_PLAYERS];
new virtualworld = GetPlayerVirtualWorld(playerid);
new interior = GetPlayerInterior(playerid);
new vehicleid = GetPlayerVehicleID(playerid);
new ivehicleid;
new col1 = COLOR_PURPLE, col2 = COLOR_PURPLE, col3 = COLOR_PURPLE, col4 = COLOR_PURPLE, col5 = COLOR_PURPLE, Float:radi=30.0;
if(vehicleid)
{
GetVehiclePos(vehicleid,oldposx,oldposy,oldposz);
}
else
{
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
vehicleid = GetPlayerVehicleID(playerid);
}
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerLoggedIn(i))
{
if(!BigEar[i])
{
if(GetPlayerVirtualWorld(i) == virtualworld)
{
if((GetPlayerInterior(i) == interior))
{
if(vehicleid)
{
if(IsPlayerInVehicle(i,vehicleid)) invehicle[i] = 1;
}
if(!invehicle[i])
{
if(IsPlayerInAnyVehicle(i))
{
ivehicleid = GetPlayerVehicleID(i);
GetVehiclePos(ivehicleid,posx,posy,posz);
}
else
{
GetPlayerPos(i,posx,posy,posz);
}
tempposx = (oldposx -posx);
tempposy = (oldposy -posy);
tempposz = (oldposz -posz);
if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
{
new len = strlen(fxString),
_iL = len / MAX_CHARS_PER_LINE;
if( ( len % MAX_CHARS_PER_LINE ) ) _iL++;
new _Line[MAX_CHARS_PER_LINE + 7];
new _:_i@Index;
while( _i@Index < _iL )
{
if( _i@Index == 0 )
strmid( _Line, fxString, ( _i@Index * MAX_CHARS_PER_LINE ), ( _i@Index * MAX_CHARS_PER_LINE ) + MAX_CHARS_PER_LINE );
else
strmid( _Line, fxString, ( _i@Index * MAX_CHARS_PER_LINE ), ( _i@Index * MAX_CHARS_PER_LINE ) + MAX_CHARS_PER_LINE );
#if defined FINAL_DOTS
if( _iL > 1 )
{
if( _i@Index == 0 )
{
format( _Line, sizeof _Line, "%s ...", _Line );
}
else if( _i@Index > 0 && ( _i@Index + 1 ) < _iL )
{
format( _Line, sizeof _Line, "* ... %s ...", _Line );
}
else
{
format( _Line, sizeof _Line, "* ... %s ((%s))", _Line, PlayerRPNameEx(playerid) );
}
}
#endif
////////////
SendClientMessage( i, col1, _Line );
format(_pLog, sizeof(_pLog), "[Recieve/Output] %s", _Line);
LogPlayer(i, _pLog);
///////////
_i@Index++;
}
}
else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
{
new len = strlen(fxString),
_iL = len / MAX_CHARS_PER_LINE;
if( ( len % MAX_CHARS_PER_LINE ) ) _iL++;
new _Line[MAX_CHARS_PER_LINE + 7];
new _:_i@Index;
while( _i@Index < _iL )
{
if( _i@Index == 0 )
strmid( _Line, fxString, ( _i@Index * MAX_CHARS_PER_LINE ), ( _i@Index * MAX_CHARS_PER_LINE ) + MAX_CHARS_PER_LINE );
else
strmid( _Line, fxString, ( _i@Index * MAX_CHARS_PER_LINE ), ( _i@Index * MAX_CHARS_PER_LINE ) + MAX_CHARS_PER_LINE );
#if defined FINAL_DOTS
if( _iL > 1 )
{
if( _i@Index == 0 )
{
format( _Line, sizeof _Line, "%s ...", _Line );
}
else if( _i@Index > 0 && ( _i@Index + 1 ) < _iL )
{
format( _Line, sizeof _Line, "* ... %s ...", _Line );
}
else
{
format( _Line, sizeof _Line, "* ... %s ((%s))", _Line, PlayerNameEx(playerid) );
}
}
#endif
////////////
SendClientMessage( i, col2, _Line );
format(_pLog, sizeof(_pLog), "[Recieve/Output] %s", _Line);
LogPlayer(i, _pLog);
///////////
_i@Index++;
}
}
else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
{
new len = strlen(fxString),
_iL = len / MAX_CHARS_PER_LINE;
if( ( len % MAX_CHARS_PER_LINE ) ) _iL++;
new _Line[MAX_CHARS_PER_LINE + 7];
new _:_i@Index;
while( _i@Index < _iL )
{
if( _i@Index == 0 )
strmid( _Line, fxString, ( _i@Index * MAX_CHARS_PER_LINE ), ( _i@Index * MAX_CHARS_PER_LINE ) + MAX_CHARS_PER_LINE );
else
strmid( _Line, fxString, ( _i@Index * MAX_CHARS_PER_LINE ), ( _i@Index * MAX_CHARS_PER_LINE ) + MAX_CHARS_PER_LINE );
#if defined FINAL_DOTS
if( _iL > 1 )
{
if( _i@Index == 0 )
{
format( _Line, sizeof _Line, "%s ...", _Line );
}
else if( _i@Index > 0 && ( _i@Index + 1 ) < _iL )
{
format( _Line, sizeof _Line, "* ... %s ...", _Line );
}
else
{
format( _Line, sizeof _Line, "* ... %s ((%s))", _Line, PlayerNameEx(playerid) );
}
}
#endif
////////////
SendClientMessage( i, col3, _Line );
format(_pLog, sizeof(_pLog), "[Recieve/Output] %s", _Line);
LogPlayer(i, _pLog);
///////////
_i@Index++;
}
}
else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
{
new len = strlen(fxString),
_iL = len / MAX_CHARS_PER_LINE;
if( ( len % MAX_CHARS_PER_LINE ) ) _iL++;
new _Line[MAX_CHARS_PER_LINE + 7];
new _:_i@Index;
while( _i@Index < _iL )
{
if( _i@Index == 0 )
strmid( _Line, fxString, ( _i@Index * MAX_CHARS_PER_LINE ), ( _i@Index * MAX_CHARS_PER_LINE ) + MAX_CHARS_PER_LINE );
else
strmid( _Line, fxString, ( _i@Index * MAX_CHARS_PER_LINE ), ( _i@Index * MAX_CHARS_PER_LINE ) + MAX_CHARS_PER_LINE );
#if defined FINAL_DOTS
if( _iL > 1 )
{
if( _i@Index == 0 )
{
format( _Line, sizeof _Line, "%s ...", _Line );
}
else if( _i@Index > 0 && ( _i@Index + 1 ) < _iL )
{
format( _Line, sizeof _Line, "* ... %s ...", _Line );
}
else
{
format( _Line, sizeof _Line, "* ... %s ((%s))", _Line, PlayerNameEx(playerid) );
}
}
#endif
////////////
SendClientMessage( i, col4, _Line );
format(_pLog, sizeof(_pLog), "[Recieve/Output] %s", _Line);
LogPlayer(i, _pLog);
///////////
_i@Index++;
}
}
else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
new len = strlen(fxString),
_iL = len / MAX_CHARS_PER_LINE;
if( ( len % MAX_CHARS_PER_LINE ) ) _iL++;
new _Line[MAX_CHARS_PER_LINE + 7];
new _:_i@Index;
while( _i@Index < _iL )
{
if( _i@Index == 0 )
strmid( _Line, fxString, ( _i@Index * MAX_CHARS_PER_LINE ), ( _i@Index * MAX_CHARS_PER_LINE ) + MAX_CHARS_PER_LINE );
else
strmid( _Line, fxString, ( _i@Index * MAX_CHARS_PER_LINE ), ( _i@Index * MAX_CHARS_PER_LINE ) + MAX_CHARS_PER_LINE );
#if defined FINAL_DOTS
if( _iL > 1 )
{
if( _i@Index == 0 )
{
format( _Line, sizeof _Line, "%s ...", _Line );
}
else if( _i@Index > 0 && ( _i@Index + 1 ) < _iL )
{
format( _Line, sizeof _Line, "* ... %s ...", _Line );
}
else
{
format( _Line, sizeof _Line, "* ... %s ((%s))", _Line, PlayerNameEx(playerid) );
}
}
#endif
////////////
SendClientMessage( i, col5, _Line );
format(_pLog, sizeof(_pLog), "[Recieve/Output] %s", _Line);
LogPlayer(i, _pLog);
///////////
_i@Index++;
}
}
}
else
{
new len = strlen(fxString),
_iL = len / MAX_CHARS_PER_LINE;
if( ( len % MAX_CHARS_PER_LINE ) ) _iL++;
new _Line[MAX_CHARS_PER_LINE + 7];
new _:_i@Index;
while( _i@Index < _iL )
{
if( _i@Index == 0 )
strmid( _Line, fxString, ( _i@Index * MAX_CHARS_PER_LINE ), ( _i@Index * MAX_CHARS_PER_LINE ) + MAX_CHARS_PER_LINE );
else
strmid( _Line, fxString, ( _i@Index * MAX_CHARS_PER_LINE ), ( _i@Index * MAX_CHARS_PER_LINE ) + MAX_CHARS_PER_LINE );
#if defined FINAL_DOTS
if( _iL > 1 )
{
if( _i@Index == 0 )
{
format( _Line, sizeof _Line, "%s ...", _Line );
}
else if( _i@Index > 0 && ( _i@Index + 1 ) < _iL )
{
format( _Line, sizeof _Line, "* ... %s ...", _Line );
}
else
{
format( _Line, sizeof _Line, "* ... %s ((%s))", _Line, PlayerRPNameEx(playerid) );
}
}
#endif
////////////
SendClientMessage( i, col1, _Line );
format(_pLog, sizeof(_pLog), "[Recieve/Output] %s", _Line);
LogPlayer(i, _pLog);
///////////
_i@Index++;
}
}
}
}
}
else
{
new len = strlen(fxString),
_iL = len / MAX_CHARS_PER_LINE;
if( ( len % MAX_CHARS_PER_LINE ) ) _iL++;
new _Line[MAX_CHARS_PER_LINE + 7];
new _:_i@Index;
while( _i@Index < _iL )
{
if( _i@Index == 0 )
strmid( _Line, fxString, ( _i@Index * MAX_CHARS_PER_LINE ), ( _i@Index * MAX_CHARS_PER_LINE ) + MAX_CHARS_PER_LINE );
else
strmid( _Line, fxString, ( _i@Index * MAX_CHARS_PER_LINE ), ( _i@Index * MAX_CHARS_PER_LINE ) + MAX_CHARS_PER_LINE );
#if defined FINAL_DOTS
if( _iL > 1 )
{
if( _i@Index == 0 )
{
format( _Line, sizeof _Line, "%s ...", _Line );
}
else if( _i@Index > 0 && ( _i@Index + 1 ) < _iL )
{
format( _Line, sizeof _Line, "* ... %s ...", _Line );
}
else
{
format( _Line, sizeof _Line, "* ... %s ((%s))", _Line, PlayerNameEx(playerid) );
}
}
#endif
////////////
SendClientMessage( i, col1, _Line );
format(_pLog, sizeof(_pLog), "[Recieve/Output] %s", _Line);
LogPlayer(i, _pLog);
////////////
_i@Index++;
}
}
}
}
}
return 1;
}