Warp command -
patfay - 16.03.2011
Okay, I made a warp command so that if I type /warp [Playerid] [location] it will warp that player to that location
So far I made two different locations, SFPD, and SFES.
I was wondering how I can fix this, as I get some errors
pawn Код:
command(warp, playerid, params[])
{
new id, Names[2][MAX_PLAYER_NAME];
if(sscanf(params, "u", id)) {
if(Player[playerid][AdminLevel] >= 1) {
SendClientMessage(playerid, WHITE, "SYNTAX: /warp [playerid] [Location]");
}
}
else {
if(Player[playerid][AdminLevel] >= 1) {
if(IsPlayerConnected(id)) {
GetPlayerName(id, Names[0], MAX_PLAYER_NAME);
GetPlayerName(playerid, Names[1], MAX_PLAYER_NAME);
new string[128];
if(!strcmp(text, "PD", true)) {
format(string, sizeof(string), "You have warped %s to the Police Department.", GetName(id));
SendClientMessage(playerid, WHITE, string);
SetPlayerPos(playerid, Groups[1][HQExteriorX], Groups[1][HQExteriorY], Groups[1][HQExteriorZ]);
SetPlayerVirtualWorld(playerid, SpawnWorld);
SetPlayerInterior(playerid, Groups[1][HQExteriorID]);
format(string, sizeof(string), "%s has admin-warped you to the Police Department.", GetName(playerid));
SendClientMessage(id, WHITE, string);
TextDrawHideForPlayer(id, ExitTextdraw);
format(string, sizeof(string), "%s has been warped to the Police Department by %s.", Names[0], Names[1]);
AdminActionsLog(string);
}
else if(!strcmp(text, "Hospital", true)) {
format(string, sizeof(string), "You have warped %s to the Hospital.", GetName(id));
SendClientMessage(playerid, WHITE, string);
SetPlayerPos(playerid, Groups[4][HQExteriorX], Groups[4][HQExteriorY], Groups[4][HQExteriorZ]);
SetPlayerVirtualWorld(playerid, SpawnWorld);
SetPlayerInterior(playerid, Groups[4][HQExteriorID]);
format(string, sizeof(string), "%s has admin-warped you to the Hospital.", GetName(playerid));
SendClientMessage(id, WHITE, string);
TextDrawHideForPlayer(id, ExitTextdraw);
format(string, sizeof(string), "%s has been warped to the Hospital by %s.", Names[0], Names[1]);
AdminActionsLog(string);
}
}
else {
SendClientMessage(playerid, WHITE, "That player is not connected.");
}
}
}
return 1;
}
Код:
C:\Users\Brandona_2\Desktop\Carnage Roleplay\gamemodes\VortexRoleplay.pwn(11481) : error 017: undefined symbol "text"
C:\Users\Brandona_2\Desktop\Carnage Roleplay\gamemodes\VortexRoleplay.pwn(11495) : error 017: undefined symbol "text"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Errors.
Код:
Line 11481: if(!strcmp(text, "PD", true)) {
Line 11495: else if(!strcmp(text, "Hospital", true)) {
Yes I have added new text;
And Im pretty sure I didn't do this right anyways
Re: Warp command -
tanush - 17.03.2011
umm im not sure if it wil work, try #define text xD
Re: Warp command -
patfay - 17.03.2011
No, that wouldn't work..
Re: Warp command -
Marricio - 17.03.2011
You forgot to define text in sscanf
pawn Код:
command(warp, playerid, params[])
{
new id, text[128],Names[2][MAX_PLAYER_NAME];
if(sscanf(params, "us[128]", id,text)) {
if(Player[playerid][AdminLevel] >= 1) {
SendClientMessage(playerid, WHITE, "SYNTAX: /warp [playerid] [Location]");
}
}
else {
if(Player[playerid][AdminLevel] >= 1) {
if(IsPlayerConnected(id)) {
GetPlayerName(id, Names[0], MAX_PLAYER_NAME);
GetPlayerName(playerid, Names[1], MAX_PLAYER_NAME);
new string[128];
if(!strcmp(text, "PD", true)) {
format(string, sizeof(string), "You have warped %s to the Police Department.", GetName(id));
SendClientMessage(playerid, WHITE, string);
SetPlayerPos(playerid, Groups[1][HQExteriorX], Groups[1][HQExteriorY], Groups[1][HQExteriorZ]);
SetPlayerVirtualWorld(playerid, SpawnWorld);
SetPlayerInterior(playerid, Groups[1][HQExteriorID]);
format(string, sizeof(string), "%s has admin-warped you to the Police Department.", GetName(playerid));
SendClientMessage(id, WHITE, string);
TextDrawHideForPlayer(id, ExitTextdraw);
format(string, sizeof(string), "%s has been warped to the Police Department by %s.", Names[0], Names[1]);
AdminActionsLog(string);
}
else if(!strcmp(text, "Hospital", true)) {
format(string, sizeof(string), "You have warped %s to the Hospital.", GetName(id));
SendClientMessage(playerid, WHITE, string);
SetPlayerPos(playerid, Groups[4][HQExteriorX], Groups[4][HQExteriorY], Groups[4][HQExteriorZ]);
SetPlayerVirtualWorld(playerid, SpawnWorld);
SetPlayerInterior(playerid, Groups[4][HQExteriorID]);
format(string, sizeof(string), "%s has admin-warped you to the Hospital.", GetName(playerid));
SendClientMessage(id, WHITE, string);
TextDrawHideForPlayer(id, ExitTextdraw);
format(string, sizeof(string), "%s has been warped to the Hospital by %s.", Names[0], Names[1]);
AdminActionsLog(string);
}
}
else {
SendClientMessage(playerid, WHITE, "That player is not connected.");
}
}
}
return 1;
}
Should work
Re: Warp command -
patfay - 17.03.2011
Compiled correctly, but ingame it doesn't work.
If I type /warp 0 PD, it will just show the syntax.
How would I make it so that if you type /warp [PLAYERID] [Warp Name] - Warp name would be like PD SFES, Government, ETC... (Whatever is inside the if(!strcmp(text, "PD", true)) {