AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Making a new function [SOLVED] (https://forums.alliedmods.net/showthread.php?t=74945)

minimiller 07-27-2008 17:20

Making a new function [SOLVED]
 
Ok this is gonna sound really nubbish, but its the best i can explain what i want to do

Basiaclly i need to make a new function like client_print but make some of it green
I have made it, and it almost works, but i need to know how you make it so you can use 2 arguments, but in some cases you can use the 3rd aswell
Code:

stock green_print(index, const message[], const message2[])
{
    new finalmsg[192];
    formatex(finalmsg, 191, "^x04%s ^x01%s", g_tag, message);
    message_begin(MSG_ONE, SayText, _, index);
    write_byte(index);
    write_string(finalmsg);
    message_end();
}

index would be a players index
const message[] is a constant message which is shown to all players
const message2[] is an optional bit

E.g. using 3 arguments
green_print(id, "Hello %s", g_tag)

E.g. using 2 arguments
green_print(id, Hello everyone!")

Again apologies for the nubbishness ;)

This has been solved by X-olent
Thanks a bunch man! :up:

Exolent[jNr] 07-27-2008 18:43

Re: [help] Making a new function
 
Code:

stock green_print(index, const fmt[], any:...)
{
    new message[192];
    vformat(message, 191, fmt, 3);
   
    new finalmsg[192];
    formatex(finalmsg, 191, "^x04%s ^x01%s", g_tag, message);
    message_begin(MSG_ONE, SayText, _, index);
    write_byte(index);
    write_string(finalmsg);
    message_end();
}



All times are GMT -4. The time now is 05:40.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.