Scripting Help please! -
adios1 - 08.12.2011
Guys I really need a script but i don't know how to
(
can someone help me? I need a script.. like a reserved car.. like my name is adios1. and if others try to enter the car it will say that this car is reserved for adios1 and a script to call my private car.. like if i type /callmycar my car will spawn in front of me.. is that possible? if it is. please help me.. i really need that badly.. Cheers Guys! Advance happy holidays!
Re: Scripting Help please! -
[ABK]Antonio - 08.12.2011
pawn Code:
new isReserved[MAX_PLAYERS]; //Add this at the top of your script.
pawn Code:
new adios1car = CreateVehicle() //fill it in yourself
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
if(GetPlayerVehicleID(playerid) == adios1car && strfind(name(playerid), "adios1", true) == -1)
{
new Float:X,Float:Y,Float:Z;
SendClientMessage(playerid, COLOR_RED, "You can't drive this car!!");
SetPlayerPos(playerid, X,Y,Z+5);
}
}
}
pawn Code:
CMD:callmycar(playerid, params[])
{
if(isReserved[playerid] == 1)
{
new Float:X,Float:Y,Float:Z, name[MAX_PLAYER_NAME];
if(strfind(name(playerid), "adios1", true) != -1)
{
GetPlayerPos(playerid, X,Y,Z);
SetVehiclePos(adios1car, X+3, Y+3, Z);
}
}
else return SendClientMessage(playerid, COLOR_RED, "Your name isn't on the reserved list.");
return 1;
}
pawn Code:
public OnPlayerConnect(playerid)
{
if(strfind(name(playerid), "adios1", true) != -1)
{
isReserved[playerid] = 1;
}
else isReserved[playerid] = 0;
}
Re: Scripting Help please! -
adios1 - 08.12.2011
Quote:
Originally Posted by [ABK]Antonio
pawn Code:
new isReserved[MAX_PLAYERS]; //Add this at the top of your script.
pawn Code:
new adios1car = CreateVehicle() //fill it in yourself public OnPlayerStateChange(playerid, newstate, oldstate) { if(newstate == PLAYER_STATE_DRIVER) { new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); if(GetPlayerVehicleID(playerid) == adios1car && strfind(name(playerid), "adios1", true) == -1) { new Float:X,Float:Y,Float:Z; SendClientMessage(playerid, COLOR_RED, "You can't drive this car!!"); SetPlayerPos(playerid, X,Y,Z+5); } } }
pawn Code:
CMD:callmycar(playerid, params[]) { if(isReserved[playerid] == 1) { new Float:X,Float:Y,Float:Z, name[MAX_PLAYER_NAME]; if(strfind(name(playerid), "adios1", true) != -1) { GetPlayerPos(playerid, X,Y,Z); SetVehiclePos(adios1car, X+3, Y+3, Z); } } else return SendClientMessage(playerid, COLOR_RED, "Your name isn't on the reserved list."); return 1; }
pawn Code:
public OnPlayerConnect(playerid) { if(strfind(name(playerid), "adios1", true) != -1) { isReserved[playerid] = 1; } else isReserved[playerid] = 0; }
|
thanks for this bud! ill try this one
Re: Scripting Help please! -
adios1 - 08.12.2011
should I change the "adios1" to my name IN-Game?
Re: Scripting Help please! -
[ABK]Antonio - 08.12.2011
Quote:
Originally Posted by adios1
should I change the "adios1" to my name IN-Game?
|
yeah
Re: Scripting Help please! -
adios1 - 08.12.2011
Last question.. Can I use this as a filterscript? if its. Is it the same code? or should i add something?
Re: Scripting Help please! -
[ABK]Antonio - 08.12.2011
ye you can
pawn Code:
new adios1car;
public OnFilterScriptInit()
{
adios1car = CreateVehicle() // fill it in
}
then remove that from above onplayerstatechange
Re: Scripting Help please! -
adios1 - 08.12.2011
Checking this out NOW!
Re: Scripting Help please! -
adios1 - 08.12.2011
is there something wrong with this one? in code there is no error. but when i try to /callmycar its not working
#include <a_samp>
#if defined FILTERSCRIPT
new ad10zcar
public OnFilterScriptInit()
{
ad10zcar = AddStaticVehicle(562,1491.7544,-693.4974,94.4110,229.1021,31,97);
AddVehicleComponent(ad10zcar, 1037);
AddVehicleComponent(ad10zcar, 1079);
AddVehicleCompoennt(ad10zcar, 114
;
AddVehicleComponent(ad10zcar, 1172);
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
if(GetPlayerVehicleID(playerid) == ad10zcar && strfind(name(playerid), "[USD]Ad10z[Du]", true) == -1)
{
new Float:X,Float:Y,Float:Z;
SendClientMessage(playerid, COLOR_RED, "You can't drive this car!!");
SetPlayerPos(playerid, X,Y,Z+5);
}
}
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/callmycar", true))
if(isReserved[playerid] == 1)
{
new Float:X,Float:Y,Float:Z, name[MAX_PLAYER_NAME];
if(strfind(name(playerid), "[USD]Ad10z[Du]", true) != -1)
{
GetPlayerPos(playerid, X,Y,Z);
SetVehiclePos(ad10zcar, X+3, Y+3, Z);
}
}
else return SendClientMessage(playerid, COLOR_RED, "Your name isn't on the reserved list.");
return 1;
}
public OnPlayerConnect(playerid)
{
if(strfind(name(playerid), "[USD]Ad10z[Du]", true) != -1)
{
isReserved[playerid] = 1;
}
else isReserved[playerid] = 0;
}
#endif
Re: Scripting Help please! -
Rob_Maate - 08.12.2011
eh the format is horrible. your missing a ';' after your variable declaration btw