OnPlayerText -
AnonScripter - 27.09.2013
when you enter one of the dynamic CPs, a textdraw show for player like this:
1- repair
2- refuel
3- add nos
how to use OnPlayerText to make it when a player is in this dynamic cp, if he response or text [1] it will repair his vehicle, and if he respond [2] it will refuel and.....?
Re: OnPlayerText -
Konstantinos - 27.09.2013
What? I'm sure you want to do something else and you chose the wrong callback.
Re: OnPlayerText -
DanishHaq - 27.09.2013
Do you mean you want to use OnPlayerKeyStateChange? You should use IsPlayerInRangeOfPoint with that with regards to your dynamic CP's, obviously use their variables if they're dynamic by looping all the CP's. And then you can use player text draw's too:
https://sampwiki.blast.hk/wiki/Textdraw#Per-Player_Textdraw.
Re: OnPlayerText -
AnonScripter - 27.09.2013
idk what callback i should use but i have a box that contains textdraws which it appears when you enter one of my dynamic cps, the textdraws are:
1- repair
2- refuel
3- add nos
so it just show the textdraws without any point, so how to make it if i'm in this dynamic cp that shows this textdraws, when the player respond or reply with [1] in chat, it will repair his vehicle instead of sending number [1] to chat like that:
Player(id:0): 1
Re: OnPlayerText -
Mattakil - 27.09.2013
You can do this:
pawn Код:
public OnPlayerUpdate(playerid)
{
if(IsPlayerInRangeOfPoint(playerid, checkpointx, checkpointy, checkpointz)
{
TextDrawShowForPlayer(playerid, textdraw);
return 1;
}
else
{
TextDrawHideForPlayer(playerid, textdraw);
return 1;
}
return 1;
}
public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
//do stuff corresponding with the textdraw
}
Better than using OnPlayerText, you just click on the textdraw to do whatever
Re: OnPlayerText -
Pottus - 27.09.2013
I see exactly what your trying to do here, so basically what you need is an cp processor function to check which cp the player is in then execute the specified action lets break down the steps.
First part Checkpoints:
1.) Create Checkpoints (save their IDs in a array)
2.) Player enters checkpoint show textdraws
3.) Record which check point player entered
Second part Actions:
1.) Player gave input is the player in a checkpoint? If true are they still in the checkpoint ? Yes continue no cancel action invalidate checkpoint record
2.) Which action did the player specify? Is this action valid?
3.) Execute specified action
@Matkill: Never use IsPlayerInRangeOfPoint() in OnPlayerUpdate() dynamic checkpoints/areas eliminate the need for that completely on top of that your idea isn't even logical.
Re: OnPlayerText -
AnonScripter - 27.09.2013
Quote:
Originally Posted by [uL]Pottus
I see exactly what your trying to do here, so basically what you need is an cp processor function to check which cp the player is in then execute the specified action lets break down the steps.
First part Checkpoints:
1.) Create Checkpoints (save their IDs in a array)
2.) Player enters checkpoint show textdraws
3.) Record which check point player entered
Second part Actions:
1.) Player gave input is the player in a checkpoint? If true are they still in the checkpoint ? Yes continue no cancel action invalidate checkpoint record
2.) Which action did the player specify? Is this action valid?
3.) Execute specified action
@Matkill: Never use IsPlayerInRangeOfPoint() in OnPlayerUpdate() dynamic checkpoints/areas eliminate the need for that completely on top of that your idea isn't even logical.
|
maybe you know what is my point, but i didn't understand the second part, i mean how to script it, on what call back ?
Re: OnPlayerText -
Pottus - 27.09.2013
Second part is in OnPlayerText() or could be a dialog input it doesn't really matter how you get the value you just need to know you have to process that value and do a few checks, heck you could even skip most of the steps I gave and just use IsPlayerInRangeOfPoint() but that would more CPU overall but very marginal.
Re: OnPlayerText -
AnonScripter - 27.09.2013
so: for example..
pawn Код:
public OnPlayerText(playerid, text[])
{
if IsPlayerInRangeOfPoint(x,y,z)
{
if(text == 1) return RepairVehicle;
if(text == 2) return RefuelVehicle;
if(text == 3) return AddNosToVehicle;
}
return 1;
}
is this a right way, i think text == number is wrong or something.
Re: OnPlayerText -
Pottus - 27.09.2013
You'd want
pawn Код:
public OnPlayerText(playerid, text[])
{
if IsPlayerInRangeOfPoint(x,y,z)
{
if(strval(text) == 1) return RepairVehicle;
else if(strval(text) == 2) return RefuelVehicle;
else if(strval(text) == 3) return AddNosToVehicle;
}
return 1;
}
That is probably the easiest way for you, the first way I mentioned is faster and dynamic but works better when you have lots of points if you have only one point the given solution here is ideal.