Spawning any object in game -
Jhony_Blaze - 29.11.2014
First of all I should let you know that I am not good at scripting, this is kinda what I've done and I'd need some help, I want a command that spawns any object in game.
Код:
COMMAND:object(playerid, params[])
{
// Setup local variables
new ObjectModel, ObjID, Msg[128], Float:plocx,Float:plocy,Float:plocz,Float:ploca
// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// Check if the player's admin-level is at least 5
if (APlayerData[playerid][PlayerLevel] >= 5)
{
if (sscanf(params, "iffff", ObjectModel, Float:plocx,Float:plocy,Float:plocz,Float:ploca)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/object <ObjectModel>\"");
else
{
GetPlayerPos(playerid, plocx, plocy, plocz);
GetPlayerFacingAngle(playerid,ploca);
ObjID = CreateObject(ObjectModel, Float:plocx,Float:plocy,Float:plocz,Float:ploca);
// Inform the player about it
format(Msg, 128, "You spawned object-id %i (model-id = %i) at coords: x=%4.2f, y=%4.2f, z=%4.2f", ObjID, ObjectModel, x, y, z);
SendClientMessage(playerid, 0x00FF00FF, Msg);
}
}
else
return 0;
}
else
return 0;
return 1;
}
Errors:
Код:
(14181) : error 001: expected token: ";", but found "if"
(14192) : warning 202: number of arguments does not match definition
(14192) : warning 202: number of arguments does not match definition
(14194) : error 017: undefined symbol "x"
Please, give me some help, I'd appreciate it.
Re: Spawning any object in game -
Pottus - 29.11.2014
pawn Код:
new ObjectModel, ObjID, Msg[128], Float:plocx,Float:plocy,Float:plocz,Float:ploca
new ObjectModel, ObjID, Msg[128], Float:plocx,Float:plocy,Float:plocz,Float:ploca;
Also why bother doing this.
pawn Код:
if (sscanf(params, "iffff", ObjectModel, Float:plocx,Float:plocy,Float:plocz,Float:ploca)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/object <ObjectModel>\"");
When you do this anyways.
pawn Код:
GetPlayerPos(playerid, plocx, plocy, plocz);
GetPlayerFacingAngle(playerid,ploca);
Re: Spawning any object in game -
JeaSon - 29.11.2014
try this
pawn Код:
COMMAND:object(playerid, params[])
{
// Setup local variables
new ObjectModel, ObjID, Msg[128], Float:plocx,Float:plocy,Float:plocz,Float:ploca;
// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// Check if the player's admin-level is at least 5
if (APlayerData[playerid][PlayerLevel] >= 5)
{
if (sscanf(params, "i", ObjectModel)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /object <ObjectModel>");
GetPlayerPos(playerid, plocx, plocy, plocz);
GetPlayerFacingAngle(playerid,ploca);
ObjID = CreateObject(ObjectModel, plocx, plocy, plocz, ploca);
// Inform the player about it
format(Msg, 128, "You spawned object-id %i (model-id = %i) at coords: x=%4.2f, y=%4.2f, z=%4.2f", ObjID, ObjectModel, plocx, plocy, plocz);
SendClientMessage(playerid, 0x00FF00FF, Msg);
}
else
return SendClientMessage(playerid, -1, "You are not logged in please login to continu");
}
else
return SendClientMessage(playerid, -1, "sorry you need to be admin to use this command");
return 1;
}
Re: Spawning any object in game -
Jhony_Blaze - 29.11.2014
With the one Namer suggested I get 2 errors
Errors:
Код:
(14189) : warning 202: number of arguments does not match definition
(14189) : warning 202: number of arguments does not match definition
This is the 14189th line
Код:
ObjID = CreateObject(ObjectModel, plocx, plocy, plocz, ploca);
Re: Spawning any object in game -
JeaSon - 29.11.2014
pawn Код:
ObjID = CreateObject(ObjectModel, plocx, plocy, plocz, 0.0, 0.0,0.0 );
Re: Spawning any object in game -
Jhony_Blaze - 29.11.2014
Now it compiles perfectly but nothing happens in game when I want to use the command.
Re: Spawning any object in game -
JeaSon - 29.11.2014
can you explain a bit ?
try changing this
ObjID = CreateObject(ObjectModel, plocx, plocy, plocz, 0.0, 0.0,0.0,5.0 );
Re: Spawning any object in game -
Jhony_Blaze - 29.11.2014
This is how the script looks right now but still doesn't work, it compiles, but when I am in game and type /object nothing will appear. Not even the client message.
Код:
COMMAND:object(playerid, params[])
{
// Setup local variables
new ObjectModel, ObjID, Msg[128], Float:plocx,Float:plocy,Float:plocz,Float:ploca;
// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// Check if the player's admin-level is at least 5
if (APlayerData[playerid][PlayerLevel] >= 5)
{
if (sscanf(params, "i", ObjectModel)) SendClientMessage(playerid, 0xFF0000AA, "Usage: /object <ObjectModel>");
GetPlayerPos(playerid, plocx, plocy, plocz);
GetPlayerFacingAngle(playerid,ploca);
ObjID = CreateObject(ObjectModel, plocx, plocy, plocz, 0.0, 0.0, 0.0, 5.0);
// Inform the player about it
format(Msg, 128, "You spawned object-id %i (model-id = %i) at coords: x=%4.2f, y=%4.2f, z=%4.2f", ObjID, ObjectModel, plocx, plocy, plocz);
SendClientMessage(playerid, 0x00FF00FF, Msg);
}
else
return 0;
}
else
return 0;
return 1;
}
Re: Spawning any object in game -
JeaSon - 29.11.2014
you need to be admin level 5 and also you must be logged in
pawn Код:
// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
// Check if the player's admin-level is at least 5 or above
if (APlayerData[playerid][PlayerLevel] >= 5)
Re: Spawning any object in game -
Threshold - 29.11.2014
pawn Код:
COMMAND:object(playerid, params[])
{
if(!APlayerData[playerid][LoggedIn]) return SendClientMessage(playerid, -1, "You must be logged in to use this command.");
if(APlayerData[playerid][PlayerLevel] < 5) return SendClientMessage(playerid, -1, "Only Level 5+ Administrators can use this command.");
new ObjectModel;
if(sscanf(params, "i", ObjectModel)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/object <ObjectModel>\"");
new Float:ploc[4];
GetPlayerPos(playerid, ploc[0], ploc[1], ploc[2]);
GetPlayerFacingAngle(playerid, ploc[3]);
new fstr[95];
format(fstr, sizeof(fstr), "You spawned object-id %i (model-id = %i) at coords: x=%.2f, y=%.2f, z=%.2f",
CreateObject(ObjectModel, ploc[0], ploc[1], ploc[2], 0.0, 0.0, ploc[3]), ObjectModel, ploc[0], ploc[1], ploc[2]);
SendClientMessage(playerid, 0x00FF00FF, fstr);
return 1;
}
You need to send the client a message using SendClientMessage rather than returning 0. This way, you can let the player know what they need to change in order to use the command.