SA-MP Forums Archive
YOU CAN FORE SURE.. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: YOU CAN FORE SURE.. (/showthread.php?tid=197643)



YOU CAN FORE SURE.. - ukraine1594 - 09.12.2010

Hey, I got an error. If I join my own server, it asks me which Age. After answering the Age it gets to the next question, Whats your Sex. If I enter male / female there comes nothing, it pops up only in global chat but doesnt come as answer. I mean, I cant answer to registrationstep 2. So I keep freezed because I cant answer. Normally I should answer male/female and function answers back to me: ok your male/female. blabla.. and then I get unfreezed. :< How can I fix that?
Guess mistake is somewhere at the 3rd code, by RegistrationStep 2

PHP код:
enum PInfo
{
    
pAge,
    
pSex
}
new 
PlayerInfo[MAX_PLAYERS][PInfo]; //How many there should be 
PHP код:
public OnPlayerSpawn(playerid)
{
    if(
RegistrationStep[playerid] == 0)
    {
        
SendClientMessage(playerid,LIGHTBLUE,"What's your Age?");
        
SendClientMessage(playerid,WHITE,"Hint: Enter your 2 digit age");
        
TogglePlayerControllable(playerid,0); //Freezing the player
        
RegistrationStep[playerid] = 1//Sets our registrationstep to 1
        
return 1;
    }
    return 
1;

PHP код:
public OnPlayerText(playeridtext[])
{
    if(
RegistrationStep[playerid] == 1)
    {
        if(!
strlen(text)) //Checks to make sure there is atleast 1 character input
        
{
            
SendClientMessage(playerid,LIGHTBLUE,"What's your Age?");
            
SendClientMessage(playerid,WHITE,"Hint: Enter your 2 digit age");
            return 
0//Ends the commands and doesnt display in text
        
}
        if(
strlen(text)< 2||strlen(text) > 2)//Checks that the input is only 2 characters long
        
{
            
SendClientMessage(playerid,0xD70000FF,"Only a 2 digit number will work!");
            return 
0;
        }
        new 
string[128]; //Creates a new string 128 characters long
        
format(string,sizeof(string),"Ok so you are %d years old",strval(text)); //Formats the string
        
SendClientMessage(playerid,LIGHTBLUE,string); //Sends new message with the string
        
PlayerInfo[playerid][pAge] = strval(text);
        
SendClientMessage(playerid,LIGHTBLUE,"What is your Sex?");
        
SendClientMessage(playerid,WHITE,"Hint: Enter male or female");
        
RegistrationStep[playerid] = 2;
        return 
0;
    }
    if(
RegistrationStep[playerid] == 2)
    {
        new 
tmp[4];
        if(!
strlen(text)) //Check to make sure there is at least 1 character input
        
{
            
SendClientMessage(playerid,LIGHTBLUE,"What is your Sex?");
            
SendClientMessage(playerid,WHITE,"Hint: Enter male or female");
            return 
0;
        }
        if((
strcmp("male"tmptruestrlen(tmp)) == 0) && (strlen(tmp) == strlen("male")))
        {
//Checks to see if the input matches "male" and if it does continues
            
PlayerInfo[playerid][pSex] = 1;
            
SendClientMessage(playerid,LIGHTBLUE,"Ok, so you are a Male.");
            
SendClientMessage(playerid,WHITE,"Thank you for filling in the information");
            
TogglePlayerControllable(playerid,1);//Unfreezes the player and play resumes
            
return 0;
        }
        else if((
strcmp("female"tmptruestrlen(tmp)) == 0) && (strlen(tmp) == strlen("female")))
        {
//Checks to see if the input matches "female" and if it does continues
            
PlayerInfo[playerid][pSex] = 2;
            
SendClientMessage(playerid,LIGHTBLUE,"Ok, so you are a Female.");
            
SendClientMessage(playerid,WHITE,"Thank you for filling in the information");
            
TogglePlayerControllable(playerid,1);//Unfreezes the player and play resumes
            
return 0;
        }
    } 



Re: please help!!! :( - admantis - 09.12.2010

Try this..

Код:
public OnPlayerSpawn(playerid)
{
    if(RegistrationStep[playerid] == 0)
    {
        SendClientMessage(playerid,LIGHTBLUE,"What's your Age?");
        SendClientMessage(playerid,WHITE,"Hint: Enter your 2 digit age");
        TogglePlayerControllable(playerid,1); //Freezing the player
        RegistrationStep[playerid] = 1; //Sets our registrationstep to 1
        return 1;
    }
    return 1;
}

Код:
public OnPlayerText(playerid, text[])
{
    if(RegistrationStep[playerid] == 1)
    {
        if(!strlen(text)) //Checks to make sure there is atleast 1 character input
        {
            SendClientMessage(playerid,LIGHTBLUE,"What's your Age?");
            SendClientMessage(playerid,WHITE,"Hint: Enter your 2 digit age");
            return 0; //Ends the commands and doesnt display in text
        }
        if(strlen(text)< 2||strlen(text) > 2)//Checks that the input is only 2 characters long
        {
            SendClientMessage(playerid,0xD70000FF,"Only a 2 digit number will work!");
            return 0;
        }
        new string[128]; //Creates a new string 128 characters long
        format(string,sizeof(string),"Ok so you are %d years old",strval(text)); //Formats the string
        SendClientMessage(playerid,LIGHTBLUE,string); //Sends new message with the string
        PlayerInfo[playerid][pAge] = strval(text);
        SendClientMessage(playerid,LIGHTBLUE,"What is your Sex?");
        SendClientMessage(playerid,WHITE,"Hint: Enter male or female");
        RegistrationStep[playerid] = 2;
        return 0;

    }
    if(RegistrationStep[playerid] == 2)
    {
        new tmp[4];
        if(!strlen(text)) //Check to make sure there is at least 1 character input
        {
            SendClientMessage(playerid,LIGHTBLUE,"What is your Sex?");
            SendClientMessage(playerid,WHITE,"Hint: Enter male or female");
            return 0;
        }
        if((strcmp("male", tmp, true, strlen(tmp)) == 0) && (strlen(tmp) == strlen("male")))
        {//Checks to see if the input matches "male" and if it does continues
            PlayerInfo[playerid][pSex] = 1;
            SendClientMessage(playerid,LIGHTBLUE,"Ok, so you are a Male.");
            SendClientMessage(playerid,WHITE,"Thank you for filling in the information");
            TogglePlayerControllable(playerid,0);//Unfreezes the player and play resumes
            return 0;
        }
        else if((strcmp("female", tmp, true, strlen(tmp)) == 0) && (strlen(tmp) == strlen("female")))
        {//Checks to see if the input matches "female" and if it does continues
            PlayerInfo[playerid][pSex] = 2;
            SendClientMessage(playerid,LIGHTBLUE,"Ok, so you are a Female.");
            SendClientMessage(playerid,WHITE,"Thank you for filling in the information");
            TogglePlayerControllable(playerid,0);//Unfreezes the player and play resumes
            return 0;
        }
    }



AW: YOU CAN FORE SURE.. - ukraine1594 - 09.12.2010

so what did you change there? Still the same


Re: YOU CAN FORE SURE.. - admantis - 09.12.2010

I changed ''TogglePlayerControllable'', 0 is for unfreezing and 1 is for freezing. Anyways, what's your problem? I tried doing it that way, you even tested it?


AW: Re: YOU CAN FORE SURE.. - ukraine1594 - 09.12.2010

Quote:
Originally Posted by admantis
Посмотреть сообщение
I changed ''TogglePlayerControllable'', 0 is for unfreezing and 1 is for freezing. Anyways, what's your problem? I tried doing it that way, you even tested it?
not yet, but thanks. So I should copy only the second part? I did a quick read because I have not much time


Re: YOU CAN FORE SURE.. - admantis - 09.12.2010

both parts but i'll keep reading the code till i find error


AW: Re: YOU CAN FORE SURE.. - ukraine1594 - 09.12.2010

Quote:
Originally Posted by admantis
Посмотреть сообщение
both parts but i'll keep reading the code till i find error
You're great mate, thanks in advance btw.
I need to go off soon, school :S! Going to take now a fast shower and I read then later your answer.


Re: YOU CAN FORE SURE.. - wups - 09.12.2010

What the fuck?
pawn Код:
if((strcmp("male", tmp, true, strlen(tmp)) == 0) && (strlen(tmp) == strlen("male")))
        {//Checks to see if the input matches "male" and if it does continues
            PlayerInfo[playerid][pSex] = 1;
            SendClientMessage(playerid,LIGHTBLUE,"Ok, so you are a Male.");
            SendClientMessage(playerid,WHITE,"Thank you for filling in the information");
            TogglePlayerControllable(playerid,0);//Unfreezes the player and play resumes
            return 0;
        }
        else if((strcmp("female", tmp, true, strlen(tmp)) == 0) && (strlen(tmp) == strlen("female")))
        {//Checks to see if the input matches "female" and if it does continues
            PlayerInfo[playerid][pSex] = 2;
            SendClientMessage(playerid,LIGHTBLUE,"Ok, so you are a Female.");
            SendClientMessage(playerid,WHITE,"Thank you for filling in the information");
            TogglePlayerControllable(playerid,0);//Unfreezes the player and play resumes
            return 0;
        }
Do this
pawn Код:
if(!strcmp("male", tmp, true, 4))
        {//Checks to see if the input matches "male" and if it does continues
            PlayerInfo[playerid][pSex] = 1;
            SendClientMessage(playerid,LIGHTBLUE,"Ok, so you are a Male.");
            SendClientMessage(playerid,WHITE,"Thank you for filling in the information");
            TogglePlayerControllable(playerid,0);//Unfreezes the player and play resumes
            return 0;
        }
        else if(!strcmp("female", tmp, true, 6))
        {//Checks to see if the input matches "female" and if it does continues
            PlayerInfo[playerid][pSex] = 2;
            SendClientMessage(playerid,LIGHTBLUE,"Ok, so you are a Female.");
            SendClientMessage(playerid,WHITE,"Thank you for filling in the information");
            TogglePlayerControllable(playerid,0);//Unfreezes the player and play resumes
            return 0;
        }
        else
        { SendClientMessage(playerid,WHITE,"Wrong answer!"); return 0; }
This will work for sure.


AW: YOU CAN FORE SURE.. - ukraine1594 - 09.12.2010

dont know what now to replace, can you write whole code what to replace and say where? Thanks


Re: YOU CAN FORE SURE.. - wups - 10.12.2010

I copied the wrong part in the top, and the good part in the bottom.