Help Need Help
#1

i always get this error
even if i try

pawn Код:
Age[playerid] = inputtext;
and this
pawn Код:
pData[playerid][pAge] = inputtext;
Код:
C:\Users\Daniel\SanAndreas Muliplayer\0.3e\gamemodes\ricaniel.pwn(472) : error 006: must be assigned to an array
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#2

inputtext is a string.
You could try converting it to an integer by using strval.
Strval converts an integer into a string.
pawn Код:
pData[playerid][pAge] = strval(inputtext);
If that doesn't work. You need to post more code.
Reply
#3

It Work Thank You +rep
but anyways

i am lttile confuse about strval - strlen and etc.. can i ask for some information to that?
Reply
#4

Quote:
Originally Posted by RicaNiel
Посмотреть сообщение
i am lttile confuse about strval - strlen and etc.. can i ask for some information to that?
strval - Convert string to integer
strlen - Check the length

In https://sampwiki.blast.hk/wiki/Category:Scripting_Functions you can find more functions ...
Reply
#5

Strval has one parameter, in that parameter you put the string you want to convert into an integer instead.
pawn Код:
new string[4] = "255"; // This is just made up of characters.
new variable = 255; // This is a number.
So the code below wont work....The string is 255, but it is just a string, not a number.
pawn Код:
GivePlayerMoney(playerid, string);
Instead you would use strval to convert the string into a number.

pawn Код:
new string[4] = "400";
GivePlayerMoney(playerid, strval(string)); // This converts the string into the number 400 and will give the player the money.
Strlen just counts the characters in a string, and returns an integer.

Example.
pawn Код:
new string[11] = "Hello John";
printf("String has %d characters in it.",strlen(string));
Will print
Код:
String has 10 characters in it. Since there are 10 chars in the string.
Hope I helped.
Reply
#6

Ok for example i want to insert a string using input text
what should i use?\

if i use this "Hello this is my text"
i use that in inputtext

what should i use?
is it strlen?
Reply
#7

What do you mean exactly?
What do you want your code to do?
Reply
#8

this one

pawn Код:
if(!strlen(inputtext)) return ShowPlayerDialog(playerid,D_SEX,INPUT,""CSERVER"RicaNiel Role-Play",""CWHITE"Please Select Your Gender","Proceed","Cancel");
                if(strfind(inputtext,"Male",true))
                {
                    new gender[50];
                    format(gender,sizeof(gender),"%s",inputtext);
                    pData[playerid][pSex] = gender;
                }
            }
        }
    }
still has errors

pawn Код:
C:\Users\Daniel\SanAndreas Muliplayer\0.3e\gamemodes\ricaniel.pwn(486) : error 006: must be assigned to an array
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
Reply
#9

You are using strfind incorrectly. You have to see if strfind returns -1 for it to be true. You should use strcmp instead.

Example

pawn Код:
if(!strcmp(inputtext,"America",true))
{
    SendClientMessage(playerid, -1, "You typed America in the dialog box!");
    return 1;
}
Another flaw in your code is the variable
pawn Код:
pData[playerid][pSex]
You need to make sure that that variable is a string in your Player Data enumerator.
I use this stock to replace a string.
pawn Код:
stock strreplace(string[], find, replace)
{
    for(new i=0; string[i]; i++) {
        if(string[i] == find) {
            string[i] = replace;
        }
    }
}
This is how it is used
pawn Код:
if(!strcmp(inputtext,"Male",true))
{
    SendClientMessage(playerid, -1, "So you are a Male!");
    strreplace(pData[playerid][pSex],pData[playerid][pSex],inputtext);
    // The first parameter gets the string
    // The second parameter basically selects the whole string
    // The last parameter replaces the whole string with the dialog inputtext.
    return 1;
}
Reply
#10

Oh i get it
thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)