SA-MP Forums Archive
Cars - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Cars (/showthread.php?tid=372102)



Cars - NeverKnow - 25.08.2012

I need some help with Giving Players Cars on a timer.
what i did is:

Код:
SetTimer("GiveAllCar",12000,0);

forward GiveAllCar();
public GiveAllCar()
{
     for(new i; i<MAX_PLAYERS; i++)
    {
	    new Car, Float:X,Float:Y,Float:Z,Float:Angle;
	    GetPlayerPos(i,X,Y,Z);
	    GetPlayerFacingAngle(i,Angle);
                 Car= CreateVehicle(411,X,Y,Z,Angle,1,-1,-1);
                 PutPlayerInVehicle(i,Car,0);
    }
}
But when i do this 1 player Gets like 500 Cars and the Server Crash.
I tried also:
Код:
//OnPlayerSpawn
SetTimerEx("GiveAllCar",12000,0,"d",playerid);

forward GiveAllCar(playerid);
public GiveAllCar(playerid)
{
    new Car, Float:X,Float:Y,Float:Z,Float:Angle;
    GetPlayerPos(playerid,X,Y,Z);
    GetPlayerFacingAngle(playerid,Angle);
    Car= CreateVehicle(411,X,Y,Z,Angle,1,-1,-1);
    PutPlayerInVehicle(playerid,Car,0);
}
now on this script sometimes a player dont get a car.

So can someone please help me out?
Thanks!


Re: Cars - clarencecuzz - 25.08.2012

Try Using
Код:
SetTimerEx("GiveAllCar",12000,false,"i",playerid);



Re: Cars - Jeffry - 25.08.2012

pawn Код:
forward GiveAllCar();
public GiveAllCar()
{
    for(new i; i<MAX_PLAYERS; i++)
    {
        new Car, Float:X,Float:Y,Float:Z,Float:Angle;
        GetPlayerPos(i,X,Y,Z);
        GetPlayerFacingAngle(i,Angle);
        Car = CreateVehicle(411,X,Y,Z,Angle,1,-1,-1);
        PutPlayerInVehicle(i,Car,0);
    }
    return 1;
}
OnFilterScriptInit (Or OnGameModeInit):
pawn Код:
SetTimer("GiveAllCar",12000,1);
Cheers!


Re: Cars - NeverKnow - 25.08.2012

Quote:
Originally Posted by clarencecuzz
Посмотреть сообщение
Try Using
Код:
SetTimerEx("GiveAllCar",12000,false,"i",playerid);
I tried this And still sometimes Players dont get Cars.

Quote:
Originally Posted by Jeffry
Посмотреть сообщение
SetTimer("GiveAllCar",12000,1);
I dont want it to repeated.


Re: Cars - Jeffry - 26.08.2012

You only want to give the player one car, 2 minutes after he/she connects?


Re: Cars - NeverKnow - 27.08.2012

Quote:
Originally Posted by Jeffry
Посмотреть сообщение
You only want to give the player one car, 2 minutes after he/she connects?
No, i have Race GM and when they spawn they get car and when they die they spectate.


Re: Cars - Jeffry - 28.08.2012

Quote:
Originally Posted by NeverKnow
Посмотреть сообщение
No, i have Race GM and when they spawn they get car and when they die they spectate.
So two minutes after the spawn they get a car, and when they lose it, no more car?


Re: Cars - NeverKnow - 28.08.2012

Quote:
Originally Posted by Jeffry
Посмотреть сообщение
So two minutes after the spawn they get a car, and when they lose it, no more car?
Yes after they spawn the player will get his car and they lose their car when they Burn or get out of car but my problem is only that sometimes some players dont get their car =/


Re: Cars - NeverKnow - 08.09.2012

Bump


Re: Cars - Jeffry - 09.09.2012

Then what you first posted should actually work.

pawn Код:
//OnPlayerSpawn
SetTimerEx("GiveAllCar",12000,0,"d",playerid);

forward GiveAllCar(playerid);
public GiveAllCar(playerid)
{
    new Car, Float:X,Float:Y,Float:Z,Float:Angle;
    GetPlayerPos(playerid,X,Y,Z);
    GetPlayerFacingAngle(playerid,Angle);
    Car= CreateVehicle(411,X,Y,Z,Angle,1,-1,-1);
    PutPlayerInVehicle(playerid,Car,0);
    return 1;
}
What do you mean by ''sometimes'', does this appear after the server was online for a long time?