PDA

View Full Version : strfind


colonel-top
10/05/2013, 06:17 AM
Hello guys little help i want help on this text so im try to create but i cant :(

if(strfind("hey heal me", "hey heal me", true) != -1) //returns 4 (!= -1 because -1 would be 'not found')
{
if(IsPlayerAdmin(playerid))
{


SetPlayerHealth(playerid, 100.0);
}
}
if(strfind("hey armour me", "hey armour me", true) != -1) //returns 4 (!= -1 because -1 would be 'not found')
{
if(IsPlayerAdmin(playerid))
{


SetPlayerArmour(playerid, 100.0);
}
}

im add it Onplayertext but its work both so when im type hey heal me its give armour too T_T can someone fix this ? thx a lot >< /// COlonel

RajatPawar
10/05/2013, 06:20 AM
public OnPlayerText(playerid, text[])
{
if(strcmp(text,"hey heal me", true) != -1)
{
if(IsPlayerAdmin(playerid))
{


SetPlayerHealth(playerid, 100.0);
}
}
return 1;
}

colonel-top
10/05/2013, 06:23 AM
ahh its not work lol its do same both T_T

Logic
10/05/2013, 06:36 AM
delete

mineralo
10/05/2013, 06:49 AM
public OnPlayerText(playerid, text[])
{
if(IsPlayerAdmin(playerid))
{
if(strfind("heal", text, true) != -1)
SetPlayerHealth(playerid,100.0);
}
return 1;
}

[HiC]TheKiller
10/05/2013, 07:02 AM
public OnPlayerText(playerid, text[])
{
if(IsPlayerAdmin(playerid))
{
if(!strcmp(text,"hey heal me", true))
{
SetPlayerHealth(playerid, 100.0);
return 0; //The text will not show up in chat but the player will be healed.
}
}
return 1;
}


That should work. strcmp returns 0 if the string matches by the way.

colonel-top
10/05/2013, 07:20 AM
Yeah Is work thx mineralo :D