OnPlayerText Problem..
#1

Hello everyone there a problem i dont know how to fix it can you help me??

Im create something but When i add it on OnPlayerText And HideTextdraws then add it again there a bug when i press 3 - 2 - 1

How to fix this??

PHP код:
public OnPlayerText(playeridtext[])
{
    if(
Police[1])
    {
      if(
strval(text) == 2)
      {
        
SetPlayerArmour(playerid100);
        
SendClientMessage(playeridCOLOR_GREEN"Your armour is now 100%");
      }
      if(
strval(text) == 4)
      {
        
SetPlayerHealth(playerid100);
        
SendClientMessage(playeridCOLOR_GREEN"Your health is now 100%");
      }
      if(
strval(text) == 3)
      {
        
TextDrawHideForPlayer(playeridTextdraw11);
        
TextDrawHideForPlayer(playeridTextdraw12);
        
TextDrawHideForPlayer(playeridTextdraw13);
        
TextDrawHideForPlayer(playeridTextdraw14);
        
TextDrawHideForPlayer(playeridTextdraw15);
        
TextDrawHideForPlayer(playeridTextdraw16);
        
TextDrawHideForPlayer(playeridTextdraw17);
        
TextDrawHideForPlayer(playeridTextdraw18);
        
TextDrawHideForPlayer(playeridTextdraw19);
        
TextDrawHideForPlayer(playeridTextdraw20);
        
TextDrawHideForPlayer(playeridTextdraw21);
        
        
TextDrawShowForPlayer(playeridTextdraw22);
        
TextDrawShowForPlayer(playeridTextdraw23);
        
TextDrawShowForPlayer(playeridTextdraw24);
        
TextDrawShowForPlayer(playeridTextdraw25);
        
TextDrawShowForPlayer(playeridTextdraw26);
        
TextDrawShowForPlayer(playeridTextdraw27);
        
TextDrawShowForPlayer(playeridTextdraw28);
        
TextDrawShowForPlayer(playeridTextdraw29);
        
        if(
strval(text) == 1) return GivePlayerWeapon(playerid24100); 
        if(
strval(text) == 2) return GivePlayerWeapon(playerid31100); 
        if(
strval(text) == 3) return GivePlayerWeapon(playerid3450); 
      }
      if(
strval(text) == 4)
      {
        
SendClientMessage(playeridCOLOR_GOLD"Coming Soon");
      }
 }
    return 
1;

Reply
#2

Код:
if(Police[1])
This more than likely won't work. This will check anyone against the array, but it's not player specific, so because of that if one person is a cop, then everyone will be a cop.

There's also a better way to use arrays for this, which rather than having an array named the faction they are part of, use an array of factions, and use their team ID to pick them up.

Then you can have...

Код:
if(faction[playerid]==1)
This also doesn't cover your 3 2 1 issue.
Reply
#3

Why are you using this in public OnPlayerText It is used to make tags in the chat or 3 d label texts and the variable is wrong to use
PHP код:
new Employment[MAX_PLAYERS]=0// Not a cop 
Exemple Usage:

PHP код:
if(Employment[playerid] != 1) return SendClientMessage(playerid, -1" You Not Police"); 
You use the example above to prevent other professions from using the police commands and the lower one to only use the police
\/
PHP код:
if(Employment[playerid] == 1
// Code 
Resume: "1" Is Cop "0" not a cop

Use the function TextdrawHideForPlayer
https://sampwiki.blast.hk/wiki/TextDrawHideForPlayer

Or

TextdrawDestroy
https://sampwiki.blast.hk/wiki/TextDrawDestroy
Reply
#4

Quote:
Originally Posted by C4rtm4n
Посмотреть сообщение
Why are you using this in public OnPlayerText It is used to make tags in the chat or 3 d label texts and the variable is wrong to use
PHP код:
new police[MAX_PLAYERS]=0// Not a cop 
Exemple Usage:

PHP код:
if(police == 0) return SendClientMessage(playerid, -1" You Not Police");
else if(
police == 1) return SendClientMessage(playerid, -1" You Is cop"); 
Resume: "1" Is Cop "0" not a cop
Do you even know how to even use arrays


FFS don't post up BROKEN NON-WORKING code....

This is as good as a tutorial from someone who doesn't have a clue on how to even do what they're trying to teach...
Reply
#5

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Do you even know how to even use arrays


FFS don't post up BROKEN NON-WORKING code....

This is as good as a tutorial from someone who doesn't have a clue on how to even do what they're trying to teach...
Sorry I was not thinking straight I've already corrected the code.
Reply
#6

Quote:
Originally Posted by C4rtm4n
Посмотреть сообщение
Sorry I was not thinking straight I've already corrected the code.
Still not correct. You've even made the exact same mistake as you did with the prior code.
Reply
#7

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Still not correct. You've even made the exact same mistake as you did with the prior code.
/\
Reply
#8

Now it's 'fixed', but it is such a basic thing that how did you mess that up in the first place...
Reply
#9

@Sew I suggest you PM him next time..

@Man43
PHP код:
      if(strval(text) == 3
      { 
        
TextDrawHideForPlayer(playeridTextdraw11); 
        
TextDrawHideForPlayer(playeridTextdraw12); 
        
TextDrawHideForPlayer(playeridTextdraw13); 
        
TextDrawHideForPlayer(playeridTextdraw14); 
        
TextDrawHideForPlayer(playeridTextdraw15); 
        
TextDrawHideForPlayer(playeridTextdraw16); 
        
TextDrawHideForPlayer(playeridTextdraw17); 
        
TextDrawHideForPlayer(playeridTextdraw18); 
        
TextDrawHideForPlayer(playeridTextdraw19); 
        
TextDrawHideForPlayer(playeridTextdraw20); 
        
TextDrawHideForPlayer(playeridTextdraw21); 
         
        
TextDrawShowForPlayer(playeridTextdraw22); 
        
TextDrawShowForPlayer(playeridTextdraw23); 
        
TextDrawShowForPlayer(playeridTextdraw24); 
        
TextDrawShowForPlayer(playeridTextdraw25); 
        
TextDrawShowForPlayer(playeridTextdraw26); 
        
TextDrawShowForPlayer(playeridTextdraw27); 
        
TextDrawShowForPlayer(playeridTextdraw28); 
        
TextDrawShowForPlayer(playeridTextdraw29); 
         
        if(
strval(text) == 1) return GivePlayerWeapon(playerid24100);  
        if(
strval(text) == 2) return GivePlayerWeapon(playerid31100);  
        if(
strval(text) == 3) return GivePlayerWeapon(playerid3450); 
the function strval(string[]) can't differ between numbers in a text, it simply checks if the entire text is a given value.

If you type: "2abcde", strval will return 0

And if you type: "1234", strval will return 1234.

Read here: https://sampwiki.blast.hk/wiki/Strval
Reply
#10

just use switch(strval(text)) then case's under it, like;

PHP код:
switch(strval(text))
{
    case 
1:
    {
          
//shit
    
}
    case 
etc...

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)