Can i do it like this?
#1

pawn Код:
if(PlayerInfo[playerid][pMuted] == 1)
            {
                SendClientMessage(playerid, TEAM_CYAN_COLOR, "You cannot speak, you have been silenced");
                return 1;
            }
            if(PlayerInfo[playerid][pMaskuse] == 1)
            format(string, sizeof(string), "* %s takes out a cellphone.",sendername);
            SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USECELLPHONE);
            ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
            new phonenumb = strval(tmp);
            if(phonenumb == 115)
           
            if(PlayerInfo[playerid][pMaskuse] == 0)
            format(string, sizeof(string), "* Stranger takes out a cellphone.");
            SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USECELLPHONE);
            ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
            if(phonenumb == 115)
            {
Reply
#2

Can you be a little more specific about what you want us to answer? Also, if you're not sure it works, why waiting for an answer here if you can simply test it yourself?
Reply
#3

You lack at least 3 curly braces https://sampwiki.blast.hk/wiki/Control_Structures#Brackets
Reply
#4

I mean can i just leave a space between
pawn Код:
if(phonenumb == 115) and if(PlayerInfo[playerid][pMaskuse] == 0)
will it still work ingame? i get no errors when i complie but i thougt i was needed to have { between them but maybe i dont? reason im asking is cuz i dont have a test server and dont want to bother my players with something im not sure it will work
Reply
#5

Parser doesn't give a damn about whitespace (except preprocessor stuff). Although I'm little shocked that it works, please, please use brackets, indentation and logic operators for stuff like that. If pMaskuse is 1 then user has mask on?
pawn Код:
if(PlayerInfo[playerid][pMuted] == 1) return SendClientMessage(playerid, TEAM_CYAN_COLOR, "You cannot speak, you have been silenced");
strcat((string[0] = EOS, string), "* Stranger takes out a cellphone.");
if(PlayerInfo[playerid][pMaskuse] == 1) format(string, sizeof(string), "* %s takes out a cellphone.",sendername);
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USECELLPHONE);
ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
new phonenumb = strval(tmp);
if(phonenumb == 115)
{
Reply
#6

Yes then he have the mask on
Reply
#7

I did like this now
pawn Код:
if(PlayerInfo[playerid][pMaskuse] == 1)
            {
                format(string, sizeof(string), "* %s takes out a cellphone.",sendername);
                SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USECELLPHONE);
                ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
                new phonenumb = strval(tmp);
                if(phonenumb == 115)
            }
            else if(PlayerInfo[playerid][pMaskuse] == 0)
            {
                if(PlayerInfo[playerid][pMaskuse] == 0)
                format(string, sizeof(string), "* Stranger takes out a cellphone.");
                SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USECELLPHONE);
                ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
                if(phonenumb == 115)
            {
                SendClientMessage(playerid, COLOR_GREEN, "____________Services number list____________");
                SendClientMessage(playerid, COLOR_WHITE, "111 - pizza stack co., 222 - bus services");
                SendClientMessage(playerid, COLOR_WHITE, "103 - medics, 444 - taxi, 555 - mechanic");
                SendClientMessage(playerid, COLOR_WHITE, "151 - Advertisement Agency, 150 - ABC Studios");
                SendClientMessage(playerid, COLOR_GREEN, "____________________________________________");
                return 1;
            }
and i got 26 errors that dosnt even make sense, soooo where did i miss a bracket or something?
Reply
#8

Yup, 26 errors are typical for missing bracket. Also I already gave you piece of fixed code. Now with 20% more comments!

pawn Код:
if(PlayerInfo[playerid][pMuted] == 1) return SendClientMessage(playerid, TEAM_CYAN_COLOR, "You cannot speak, you have been silenced");

//If user has a mask, then change contents of string to "Stranger blahblahb"
format(string, sizeof(string), PlayerInfo[playerid][pMaskuse] == 0 ? ("* %s takes out a cellphone.") : ("* Stranger takes out a cellphone."), sendername);

SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USECELLPHONE);
ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
if(strval(tmp) == 115)
{
    SendClientMessage(playerid, COLOR_GREEN, "____________Services number list____________");
    SendClientMessage(playerid, COLOR_WHITE, "111 - pizza stack co., 222 - bus services");
    SendClientMessage(playerid, COLOR_WHITE, "103 - medics, 444 - taxi, 555 - mechanic");
    SendClientMessage(playerid, COLOR_WHITE, "151 - Advertisement Agency, 150 - ABC Studios");
    SendClientMessage(playerid, COLOR_GREEN, "____________________________________________");
    return 1;
}
Reply
#9

But this
pawn Код:
format(string, sizeof(string), PlayerInfo[playerid][pMaskuse] == 0 ("* %s takes out a cellphone."), sendername);
only checks if the user dont use the mask, its nothing that checks if the user use a mask or what to say when he does?
Reply
#10

Take a closer look

pawn Код:
PlayerInfo[playerid][pMaskuse] == 0 ? ("* %s takes out a cellphone.") : ("* Stranger takes out a cellphone.")
If mask is equal 0, then string formatted will be "* %s takes out a cellphone.", but if the player has a mask on, then it will be "* Stranger takes out a cellphone.". This is called ternary operator
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)