string cut -
ancezas - 04.03.2014
hi, i have this code:
pawn Код:
new
msg[ 128 ];
format( msg, 128, "%s", inputtext );
InfoMSG( playerid, msg );
and it's retrieves all string, like
I need to cut : Prisijunges, I would use strmid but the Ance_Zas is player name, and it's featced from mysql, its not static and every time can be difrent leitgh. any ideas?
or mabye i can retrieve the player name from dialog to listitem easyest way?
Re: string cut -
HK - 04.03.2014
Can you try be abit more specific so I could help you more?
Re: string cut -
fordawinzz - 04.03.2014
pawn Код:
strdel(msg, 0, strfind(msg, ":") + 1); //this will return 'Prisijunges'
strdel(msg, strfind(msg, ":") + 1, strlen(msg)); //this will return 'Ance_Zas'
Re: string cut -
Konstantinos - 04.03.2014
pawn Код:
new msg[21], pos = strfind(inputtext, ":"), length = strlen(inputtext);
if (pos != -1)
{
strmid(msg, inputtext, pos, length, 21);
InfoMSG(playerid, msg);
}
Re: string cut -
ancezas - 04.03.2014
if( dialogid == 312 )//Darbuotju valdymas...
{
if( response )
{
new msg[21], pos = strfind(inputtext, "-"), length = strlen(inputtext);
strmid(msg, inputtext, pos, length, 21);
InfoMSG(playerid, msg);
}
return true;
}
it gives "- prisijunges" that it deletes that string that should be left

its all reverse, so how to do it ritgh?
Re: string cut -
Konstantinos - 04.03.2014
Oh, that was a mistake by my side. Change to:
pawn Код:
new msg[21], pos = strfind(inputtext, ":");
if (pos != -1)
{
strmid(msg, inputtext, 0, pos, 21);
InfoMSG(playerid, msg);
}
Re: string cut -
ancezas - 04.03.2014
new
msg[ 21 ],
pos = strfind( inputtext, " -" );
strmid( msg, inputtext, 0, pos, 21 );
InfoMSG( playerid, msg );
new name = strval( msg );
and the verible name is return zero, why?
Re: string cut -
Konstantinos - 04.03.2014
The example you gave is: "Ance_Zas: Prisijunges". The code I wrote will return "Ance_Zas" but you search for " -" and you never check if it was found or not. In case " -" doesn't exist in the inputtext, the length will be 0 and msg will not hold the name.
Re: string cut -
ancezas - 04.03.2014
so how to do that msg hold palyer name?
Re: string cut -
Konstantinos - 04.03.2014
Read what I said above, it all depends on you. The inputtext has after the name ":" or " -" character? Replace strfind with the character your inputtext holds after the name.