Need assistance with this line of code please
#1

Hello guys, first of all excuse me for being shit at scripting I have literally ZERO knowledge, but I really need something quick.

So this is a simple SendClientMessage when I write the command /createplayer

Now, everytime I want to change the name of the player, I have to do it in the .pwn manually.

I am looking for a way to do it in game, without having to go in the .pwn to do it, with the same exact SendClientMessage to show with my new name that I pick.

Can you guys help me with that?

Like this:
Код:
CMD:createplayer(playerid, params[])
{
	SendClientMessage(playerid, COLOR_LIGHTBLUE,"* You created John Smith!");
	SendClientMessage(playerid, COLOR_DBLUE,"A new player has been created");
	SendClientMessage(playerid, COLOR_DBLUE,"Welcome John Smith, enjoy your stay!");
	return 1;
}
If I was not clear enough, i'll explain it again in a more simple way

I need something to change the name John Smith for instance, without going to the .pwn and do it manually.

Im literally shit at scripting, and I tried different variatons, none work.
Reply
#2

Do you want to change the names of existing instances of /createplayer or do you want to use /createplayer <some_name_here>?
Reply
#3

Quote:
Originally Posted by Twizted
Посмотреть сообщение
Do you want to change the names of existing instances of /createplayer or do you want to use /createplayer <some_name_here>?
No, just use createplayer for whatever name pops in my head (just like u said /createplayer some_name_here), without anything that exists.

Just being able to do that anytime I want with any name that comes in my head.



--- thanks for your fast response, bro.
Reply
#4

At top of script:
Код:
#include <sscanf2>
#include <zcmd>
Код:
CMD:createplayer(playerid,params[])
{
	new text[24],string[256];
	if(sscanf(params, "s[24]",text)) return SendClientMessage(playerid,-1,"USAGE: /createplayer [name]");
	
	format(string,sizeof(string), "You created %s", text);
	SendClientMessage(playerid, COLOR_DBLUE, string);
	SendClientMessage(playerid, COLOR_DBLUE,"A new player has been created");
	format(string,sizeof(string), "Welcome %s, enjoy your stay"", text);
	SendClientMessage(playerid, COLOR_DBLUE, string);
	switch(SetPlayerName(playerid, text))
    	{
        	case -1: SendClientMessage(playerid,0xFF0000FF, "Unable to change your name, someone else has that name already!");
        	case 0: SendClientMessage(playerid, 0xFF0000FF, "You are already known with that name!");
        	case 1: SendClientMessage(playerid, 0x00FF00FF, "Your name is now changed as you wanted!");
    	}
	return 1;
}
Haven't tested it, but I think it should work
Reply
#5

Quote:
Originally Posted by TomRedlake
Посмотреть сообщение
At top of script:
Код:
#include <sscanf2>
#include <zcmd>
Код:
CMD:createplayer(playerid,params[])
{
	new text[24],string[256];
	if(sscanf(params, "s[24]",text)) return SendClientMessage(playerid,-1,"USAGE: /createplayer [name]");
	
	format(string,sizeof(string), "You created %s", text);
	SendClientMessage(playerid, COLOR_DBLUE, string);
	SendClientMessage(playerid, COLOR_DBLUE,"A new player has been created");
	format(string,sizeof(string), "Welcome %s, enjoy your stay"", text);
	SendClientMessage(playerid, COLOR_DBLUE, string);
	switch(SetPlayerName(playerid, text))
    	{
        	case -1: SendClientMessage(playerid,0xFF0000FF, "Unable to change your name, someone else has that name already!");
        	case 0: SendClientMessage(playerid, 0xFF0000FF, "You are already known with that name!");
        	case 1: SendClientMessage(playerid, 0x00FF00FF, "Your name is now changed as you wanted!");
    	}
	return 1;
}
Haven't tested it, but I think it should work
Holy shit that works perfectly.

Just one more thing, how do I change the color of format(string,sizeof(string), "You created %s", text); to COLOR_LIGHTBLUE cause that's the one I need.

Fucking awesome broski, thank u so much!

EDIT: figured it out. Thanks again
Reply
#6

Edited.
Reply
#7

If you already have defined COLOR_LIGHTBLUE then replace COLOR_DBLUE.

If you haven't defined COLOR_LIGHTBLUE:

PHP код:
#define COLOR_LIGHTBLUE       0x3DA6EDAA 
At the top of your script
Reply
#8

Quote:
Originally Posted by Twizted
Посмотреть сообщение
Edited.
Quote:
Originally Posted by Lucases
Посмотреть сообщение
If you already have defined COLOR_LIGHTBLUE then replace COLOR_DBLUE.

If you haven't defined COLOR_LIGHTBLUE:

PHP код:
#define COLOR_LIGHTBLUE       0x3DA6EDAA 
At the top of your script
You guys are awesome, I figured it out.

Thank you all for your help.

I'm out.
Reply
#9

You are welcome
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)