SA-MP Forums Archive
Need assistance with this line of code please - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need assistance with this line of code please (/showthread.php?tid=644810)



Need assistance with this line of code please - Relic - 14.11.2017

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.


Re: Need assistance with this line of code please - Twizted - 14.11.2017

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


Re: Need assistance with this line of code please - Relic - 14.11.2017

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.


Re: Need assistance with this line of code please - TomRedlake - 14.11.2017

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


Re: Need assistance with this line of code please - Relic - 14.11.2017

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


Re: Need assistance with this line of code please - Twizted - 14.11.2017

Edited.


Re: Need assistance with this line of code please - Lucases - 14.11.2017

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


Re: Need assistance with this line of code please - Relic - 14.11.2017

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.


Re: Need assistance with this line of code please - TomRedlake - 14.11.2017

You are welcome