SA-MP Forums Archive
Car respawn error - 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: Car respawn error (/showthread.php?tid=514007)



Car respawn error - Sachza - 19.05.2014

Hi!

I want that if a player leaves the car and the car did not belong to him, then the car will respawn after 10 seconds, but if the car belongs to him, then you do not respawn.
Sorry for my bad english.

pawn Код:
forward respawn();

public OnPlayerExitVehicle(playerid, vehicleid)
{
    new id = GetVehicleID(vehicleid);
    if(GetPlayerVehicleAccess(playerid, id) < 1)
    {
        SendClientMessage(playerid,0x96FFF3FF,"{96FFF3}Sa lahkusid masinast! See ei ole sinu masin, seega see respawnib 10 sekundi pдrast!");
        SetTimer("respawn", 10000, false);
    }
    else return SendClientMessage(playerid,0x96FFF3FF,"{96FFF3}Sa lahkusid masinast!");
    return 1;
}

public respawn()
{
    new vehicleid = GetPlayerVehicleID(playerid); // (1824)  
    DestroyVehicle(vehicleid);
}
ERROR:
pawn Код:
C:\Users\Monster\Desktop\samp03z_svr_R1_win32\filterscripts\avs.pwn(1824) : error 017: undefined symbol "playerid"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
Please help, btw i use Advanced Vehicle System version 1.0 by MadeMan


Re: Car respawn error - JFF - 19.05.2014

Quote:
Originally Posted by Sachza
Посмотреть сообщение
Hi!

I want that if a player leaves the car and the car did not belong to him, then the car will respawn after 10 seconds, but if the car belongs to him, then you do not respawn.
Sorry for my bad english.

pawn Код:
forward respawn();

public OnPlayerExitVehicle(playerid, vehicleid)
{
    new id = GetVehicleID(vehicleid);
    if(GetPlayerVehicleAccess(playerid, id) < 1)
    {
        SendClientMessage(playerid,0x96FFF3FF,"{96FFF3}Sa lahkusid masinast! See ei ole sinu masin, seega see respawnib 10 sekundi pдrast!");
        SetTimer("respawn", 10000, false);
    }
    else return SendClientMessage(playerid,0x96FFF3FF,"{96FFF3}Sa lahkusid masinast!");
    return 1;
}

public respawn()
{
    new vehicleid = GetPlayerVehicleID(playerid); // (1824)  
    DestroyVehicle(vehicleid);
}
ERROR:
pawn Код:
C:\Users\Monster\Desktop\samp03z_svr_R1_win32\filterscripts\avs.pwn(1824) : error 017: undefined symbol "playerid"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
Please help, btw i use Advanced Vehicle System version 1.0 by MadeMan
Didnt test but it should work

pawn Код:
forward respawn();

new LastCar[MAX_PLAYERS];

public OnPlayerExitVehicle(playerid, vehicleid)
{
    new id = GetVehicleID(vehicleid);
    if(GetPlayerVehicleAccess(playerid, id) < 1)
    {
        SendClientMessage(playerid,0x96FFF3FF,"{96FFF3}Sa lahkusid masinast! See ei ole sinu masin, seega see respawnib 10 sekundi pдrast!");
        SetTimer("respawn", 10000, false);
        LastCar[playerid] = vehicleid;
    }
    else return SendClientMessage(playerid,0x96FFF3FF,"{96FFF3}Sa lahkusid masinast!");
    return 1;
}

public respawn()
{  
    DestroyVehicle(LastCar[playerid]);
}



Re: Car respawn error - Beckett - 19.05.2014

pawn Код:
forward respawn();
new v_id;

public OnPlayerExitVehicle(playerid, vehicleid)
{
    new id = GetVehicleID(vehicleid);
    if(GetPlayerVehicleAccess(playerid, id) < 1)
    {
        SendClientMessage(playerid,0x96FFF3FF,"{96FFF3}Sa lahkusid masinast! See ei ole sinu masin, seega see respawnib 10 sekundi pдrast!");
        SetTimer("respawn", 10000, false);
        v_id = vehicleid;
    }
    else return SendClientMessage(playerid,0x96FFF3FF,"{96FFF3}Sa lahkusid masinast!");
    return 1;
}

public respawn()
{
    DestroyVehicle(v_id);
}



Re: Car respawn error - Sachza - 19.05.2014

Quote:
Originally Posted by JFF
Посмотреть сообщение
Didnt test but it should work

pawn Код:
forward respawn();

new LastCar[MAX_PLAYERS];

public OnPlayerExitVehicle(playerid, vehicleid)
{
    new id = GetVehicleID(vehicleid);
    LastCar[playerid] = vehicleid;
    if(GetPlayerVehicleAccess(playerid, id) < 1)
    {
        SendClientMessage(playerid,0x96FFF3FF,"{96FFF3}Sa lahkusid masinast! See ei ole sinu masin, seega see respawnib 10 sekundi pдrast!");
        SetTimer("respawn", 10000, false);
    }
    else return SendClientMessage(playerid,0x96FFF3FF,"{96FFF3}Sa lahkusid masinast!");
    return 1;
}

public respawn()
{  
    DestroyVehicle(LastCar[playerid]);
}
When i compile it... the same error:
pawn Код:
C:\Users\Monster\Desktop\samp03z_svr_R1_win32\filterscripts\avs.pwn(1827) : error 017: undefined symbol "playerid"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
And error line is:
pawn Код:
DestroyVehicle(LastCar[playerid]);



Re: Car respawn error - JFF - 19.05.2014

pawn Код:
forward respawn();

new LastCar[MAX_PLAYERS];

public OnPlayerExitVehicle(playerid, vehicleid)
{
    new id = GetVehicleID(vehicleid);
    LastCar[playerid] = vehicleid;
    if(GetPlayerVehicleAccess(playerid, id) < 1)
    {
        SendClientMessage(playerid,0x96FFF3FF,"{96FFF3}Sa lahkusid masinast! See ei ole sinu masin, seega see respawnib 10 sekundi pдrast!");
        SetTimer("respawn", 10000, false);
    }
    else return SendClientMessage(playerid,0x96FFF3FF,"{96FFF3}Sa lahkusid masinast!");
    return 1;
}

public respawn()
{  
    for(new i=0; i < MAX_PLAYERS; i++)
    {
       DestroyVehicle(LastCar[i]);
    }
}



Re: Car respawn error - XK - 19.05.2014

Lol not really,you have to replace
pawn Код:
public respawn()
with
pawn Код:
public respawn(playerid)
because you have to define playerid
JFF you made a big mistake,if you use that code it will do it for all of the players
and use SetTimerEx and edit it....
and edit
pawn Код:
forward respawn(playerid);



Re: Car respawn error - JFF - 19.05.2014

Quote:
Originally Posted by XK
Посмотреть сообщение
Lol not really,you have to replace
pawn Код:
public respawn()
with
pawn Код:
public respawn(playerid)
because you have to define playerid
JFF you made a big mistake,if you use that code it will do it for all of the players
and use SetTimerEx and edit it....
and edit
pawn Код:
forward respawn(playerid);
Yeah ur right i should have used a timerex with adding playerid to the public