What did I do wrong?
#1

Here's what I have
Код:
  	    new
			tmp[3],
   			skinid = strval(tmp);
		if(1 <= strval(tmp) <= 299)
		 {
            SetPlayerSkin(skinid);
   			SendClientMessage(playerid, COLOR_WHITE, "[REGISTER:] You have now set your skin.");
	    	RegistrationStep[playerid] = 0;
			TogglePlayerControllable(playerid,1);
			PlayerInfo[playerid][pRegistered] = 1;
		    return 0;
		}
		else
		{
  			SendClientMessage(playerid, COLOR_RED, "[REGISTER:] Invalid skin, 1-299");
  			SendClientMessage(playerid, COLOR_RED, "[NOTE:] Some skins are restricted.");

	 	}
		return 0;
This is what happens when I go in-game





How can I make it so it sets their skin to whatever they type in the chat?
Reply
#2

pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[128], skinstring[128];
    sscanf(text, "s[128]", skinstring);
    if(strval(skinstring) < 1 || strval(skinstring) > 299)
    {
        SetPlayerSkin(playerid, strval(skinstring));
        format(string, sizeof(string), "** Your skin has been set to the skin with the id %s.", skinstring);
        SendClientMessage(playerid, COLOR_WHITE, string);
        return 0;
    }
    else
    {
        format(string, sizeof(string), "** The skin %s doesn't exist.", skinstring);
        SendClientMessage(playerid, COLOR_WHITE, string);
        return 0;
    }
    return 1;
}
Reply
#3

Instead of if(1 <= strval(tmp) <= 299) use:
pawn Код:
if(skinid > 0 && skinid < 300)
Reply
#4

Quote:
Originally Posted by Madd92
Посмотреть сообщение
Instead of if(1 <= strval(tmp) <= 299) use:
pawn Код:
if(skinid > 0 && skinid < 300)
I get one error. Same thing for both of your guys' attempts.

C:\Users\Zachary.Zach-HP.000\Desktop\Folders\SA-MP\Fort Carson Roleplay\gamemodes\fcrp.pwn(1917) : error 001: expected token: "-identifier-", but found "if"
Reply
#5

By doing this:
pawn Код:
new
    tmp[3],
    skinid = strval(tmp);
skinid will always be 0.

Use sscanf like SickAttack did but without a string.

pawn Код:
new
    skinid;
if (sscanf(text, "i", skinid)) return SendClientMessage(playerid, COLOR_RED, "Use a number for the skin ID.");
if (!(1 <= skinid <= 299))
{
    SendClientMessage(playerid, COLOR_RED, "[REGISTER:] Invalid skin, 1-299");
    SendClientMessage(playerid, COLOR_RED, "[NOTE:] Some skins are restricted.");
    return 1;
}
SetPlayerSkin(skinid);
SendClientMessage(playerid, COLOR_WHITE, "[REGISTER:] You have now set your skin.");
RegistrationStep[playerid] = 0;
TogglePlayerControllable(playerid,1);
PlayerInfo[playerid][pRegistered] = 1;
Reply
#6

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
By doing this:
pawn Код:
new
    tmp[3],
    skinid = strval(tmp);
skinid will always be 0.

Use sscanf like SickAttack did but without a string.

pawn Код:
new
    skinid;
if (sscanf(text, "i", skinid)) return SendClientMessage(playerid, COLOR_RED, "Use a number for the skin ID.");
if (!(1 <= skinid <= 299))
{
    SendClientMessage(playerid, COLOR_RED, "[REGISTER:] Invalid skin, 1-299");
    SendClientMessage(playerid, COLOR_RED, "[NOTE:] Some skins are restricted.");
    return 1;
}
SetPlayerSkin(skinid);
SendClientMessage(playerid, COLOR_WHITE, "[REGISTER:] You have now set your skin.");
RegistrationStep[playerid] = 0;
TogglePlayerControllable(playerid,1);
PlayerInfo[playerid][pRegistered] = 1;
Thanks, but can you define sscanf for me?

I have one error, on sscanf
C:\Users\Zachary.Zach-HP.000\Desktop\Folders\SA-MP\Fort Carson Roleplay\gamemodes\crp.pwn(1916) : error 017: undefined symbol "sscanf"
Reply
#7

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
By doing this:
pawn Код:
new
    tmp[3],
    skinid = strval(tmp);
skinid will always be 0.

Use sscanf like SickAttack did but without a string.

pawn Код:
new
    skinid;
if (sscanf(text, "i", skinid)) return SendClientMessage(playerid, COLOR_RED, "Use a number for the skin ID.");
if (!(1 <= skinid <= 299))
{
    SendClientMessage(playerid, COLOR_RED, "[REGISTER:] Invalid skin, 1-299");
    SendClientMessage(playerid, COLOR_RED, "[NOTE:] Some skins are restricted.");
    return 1;
}
SetPlayerSkin(skinid);
SendClientMessage(playerid, COLOR_WHITE, "[REGISTER:] You have now set your skin.");
RegistrationStep[playerid] = 0;
TogglePlayerControllable(playerid,1);
PlayerInfo[playerid][pRegistered] = 1;
I like to use it as a string so that you can type the name also, but of course you have to make it supported.

Quote:
Originally Posted by ZachKnoxx
Посмотреть сообщение
Yeah, that didn't work. For some reason my script isn't a big fan of plugins and includes.
All scripts act the same way and support the same stuff, why do you blame the script if its the user?

Download sscanf from https://sampforum.blast.hk/showthread.php?tid=120356. Once you've downloaded it move the file to the following directory "/pawno/include/" then on the top of your gamemode add #include <sscanf2> and then complie.
Reply
#8

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
I like to use it as a string so that you can type the name also, but of course you have to make it supported.



All scripts act the same way and support the same stuff, why do you blame the script if its the user?

Download sscanf from https://sampforum.blast.hk/showthread.php?tid=120356. Once you've downloaded it move the file to the following directory "/pawno/include/" then on the top of your gamemode add #include <sscanf2> and then complie.
I did that, but it doesn't work. I just get the same error.

Also, I'm not new to scripting, if you look below, I had hosted a roleplay server with a unique script and a playerbase that reached to 150+ players on peak hours.
Reply
#9

Quote:
Originally Posted by ZachKnoxx
Посмотреть сообщение
I did that, but it doesn't work. I just get the same error.
It suppose to work, how are you opening your gamemode? By clicking on the ".pwn" file or by executing "pawno" then opening your gamemode form there? If your opening your gamemode by clicking on the ".pwn" file then do it the other way.
Reply
#10

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
It suppose to work, how are you opening your gamemode? By clicking on the ".pwn" file or by executing "pawno" then opening your gamemode form there? If your opening your gamemode by clicking on the ".pwn" file then do it the other way.
I do it that way, still nothing. I'm just going to remove that portion of the script, and do it another way.

Still thanks for the help from you all.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)