28.06 after some worries with the if and else clauses i finally got the whisper command working. switch/case would have been a real helper here!!

now you can "/w name text" and its displayed only for the player with the right player_name.

iam really happy because teamsay shouldnt be a problem now because it works similar. what i did was to send the chat over the network in the form "/a playerto playerfrom messagetext".

then only display it in the on_server or on_client functions at the "EVENT_STRING" if the playerfrom text was equal to player_name.

heres a little example code of how my probably ugly string manipulation works just to get the idea: (note: its not complete, and uses locoweeds chat example as base)

Code:

// send chat to a special player with "/w playerto text"
if(str_cmpni(str_chatentry,"/w "))
{

txtchatentry.visible = off;

// change text so that it is "you whisper to nameto: messagetext"
str_cpy(str_temp,"you whisper to "); // put players name before entry
str_clip(str_chatentry,3); // clip /a at start
str_cpy(str_whisperto, str_chatentry); // copy first 20 chars to name
temp = str_stri(str_whisperto," "); // find first space after name
str_trunc(str_whisperto, (str_len(str_whisperto)-temp)+1); // trunctate the rest of the name string
str_cat(str_temp,str_whisperto); // copy name to temp
str_cat(str_temp,":"); // copy : to temp
str_clip(str_chatentry,str_len(str_whisperto)); // clip the name from the chatentry
str_cat(str_temp,str_chatentry); // paste chatentry after name
str_cpy(str_sendchat, str_temp); // place the result in sendchat


// if host display already and send to others
if(connection == 3)
{


// move old chat entries one up and display str_sendchat at bottom
update_chat();


// add "/w " and send "/w nameto namefrom messagetext" to clients
str_cpy(str_temp, "/w "); // add /w
str_cat(str_temp, str_whisperto); // add name to whisper to
str_cat(str_temp, " "); // spacer
str_cat(str_temp, player_name); // add sender name
str_cat(str_temp, " "); // spacer
str_cat(str_temp, str_chatentry); // message text left over from top
str_cpy(str_sendchat, str_temp);

send_string(str_sendchat);


}
else // if client send entry to server for processing/manipulation
{
// move old chat entries one up and display str_sendchat at bottom
update_chat();

// add "/w " and send "/w nameto namefrom messagetext" to clients
str_cpy(str_temp, "/w "); // add /w
str_cat(str_temp, str_whisperto); // add name to whisper to
str_cat(str_temp, " "); // spacer
str_cat(str_temp, player_name); // add sender name
str_cat(str_temp, " "); // spacer
str_cat(str_temp, str_chatentry); // message text left over from top
str_cpy(str_sendchat, str_temp);

send_string(str_sendchat);
}

}



and here is a screenshot of it working (notice the chat at the bottom)



Last edited by ulf; 04/28/06 11:28.