Need a little help here
#1

Hey
Just made a little noobie thing that if you press the action key you spawn an infernus,
and i have couple of questions
1.How can i make something that if i pressed ctrl once and spawned a car i won't be able to spawn another one
for an amount of time?cuz ppl just tapping ctrl and it lags the server and spawns tons of cars O.o
2.And i have another problem,everytime if i face north the car spawns fine infront of me,and if i face south its
spawning behind me. anyone knows how to solve it?
Reply
#2

Sorry,bump.
Reply
#3

Quote:
Originally Posted by O_x
1.How can i make something that if i pressed ctrl once and spawned a car i won't be able to spawn another one
for an amount of time?cuz ppl just tapping ctrl and it lags the server and spawns tons of cars O.o
pawn Код:
new tick;
pawn Код:
YOURFUNCTIONTOSPAWNVEHICLES() // e.g OnPlayerKeyStateChange
{
  if(GetTickCount() < tick) return SendClientMessage(playerid, COLOR, "You'll need to wait to spawn another vehicle!");
  // your stuff to spawn vehicle...
  tick = GetTickCount() + 10000; // change 10000 for the amount of time in ms.
  return 1;
}
Reply
#4

Thanks guys
If anyone knows the answer to the second one i'll be glad if you'll post it here ^^
thanks
Edit:
Here is the code(if it helps..)
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
  if ((newkeys & KEY_FIRE) && !(oldkeys & KEY_FIRE))
  {
    new Float:x, Float:y, Float:z;
    new Abc;
    new Float:Angle;
    Abc = GetPlayerFacingAngle(playerid, Angle);
    GetPlayerPos(playerid,x,y,z);
    if(GetTickCount() < tick) return SendClientMessage(playerid, COLOR_RED, "You're gonna need to wait 30 seconds to spawn another vehicle.");
    CreateVehicle(411,x,y+6.13,z,Abc+90,0,1,300);
    tick = GetTickCount() + 30000;
    }
    return 1;
}
btw it works thanks alot
Reply
#5

2. GetXYInfrontOfPlayer

Search it, Its on here somewhere
Reply
#6

Quote:
Originally Posted by Joe Torran C
2. GetXYInfrontOfPlayer

Search it, Its on here somewhere
Ok,i found it https://sampwiki.blast.hk/wiki/Stocks#Re...ultiple_values
Thanks i'll try it out
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)