PDA

View Full Version : [HELP] Teleport System


[SsC11]MAVERIK
05/06/2010, 02:00 PM
I did this:

#include <a_samp>
new Float:xg, Float:yg, Float:zg;
new goid;
new nega[MAX_PLAYERS];
new fname[MAX_PLAYER_NAME];
new gname[MAX_PLAYER_NAME];
new fromid;
#define GREEN 0x33AA33AA
#define RED 0xAA3333AA

public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Teleport System by MavericK");
print("--------------------------------------\n");
return 1;
}

public OnFilterScriptExit()
{
return 1;
}



public OnPlayerConnect(playerid)
{
nega[playerid] = 0;
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
nega[playerid] = 0;
return 1;
}



public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
new string[256];

if (strcmp("/deney", cmdtext, true, 10) == 0)
{
if(nega[playerid] == 0) {
nega[playerid] = 1;
SendClientMessage(playerid, GREEN, "All requests will be automatically rejected");
SendClientMessage(playerid, RED, "Rerun the command to disable this option");
} else {
nega[playerid] = 0;
SendClientMessage(playerid, GREEN, "Possibility of teleportation activated");
}
return 1;
}

if (strcmp(cmd, "/go", true, 10) == 0)
{
new tmp[256];
new stringdomanda[256];
tmp = strtok(cmdtext, idx);
goid = strval(tmp);
playerid = fromid;
GetPlayerName(goid, gname, sizeof(gname));
GetPlayerName(fromid, fname, sizeof(fname));


if(strlen(tmp) == 0) SendClientMessage(playerid, RED, "USE: /go [PLAYERID]");

else if (!IsNumeric2(tmp)) SendClientMessage(playerid, RED, "ID INVALID");

else if(goid == INVALID_PLAYER_ID) SendClientMessage(playerid, RED, "ID INVALID");

else
{

if(nega[goid] != 1) {

format(string, sizeof(string), "Sent teleport request to %s", gname);
SendClientMessage(fromid, GREEN, string);

format(stringdomanda, sizeof(stringdomanda), "Do you want allow at %s of teleport to you?", fname);
ShowPlayerDialog(goid,48,0,"Tele",stringdomanda,"Yes","No");

} else {
format(string, sizeof(string), "%s He refused the request", gname);
SendClientMessage(fromid, GREEN, string);
}
}

return 1;
}
return 0;
}



public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{

if(dialogid == 48)
{
if(response == 1){
GetPlayerPos(goid, xg, yg, zg);
SetPlayerPos(fromid, xg, yg, zg);
} else {
new string[256];
format(string, sizeof(string), "%s He refused the request", gname);
SendClientMessage(fromid, RED, string);
}
}

return 1;
}

strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}

new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}

IsNumeric2(const string[])
{

new length=strlen(string);
if (length==0) return false;
for (new i = 0; i < length; i++)
{
if((string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+' && string[i]!='.')
|| (string[i]=='-' && i!=0)
|| (string[i]=='+' && i!=0)
) return false;
}
if (length==1 && (string[0]=='-' || string[0]=='+' || string[0]=='.')) return false;
return true;
}

The player can see the dialog but nothing happens if he responds..
And these don't work:

format(string, sizeof(string), "Sent teleport request to %s", gname);
SendClientMessage(fromid, GREEN, string);


if(dialogid == 48)
{
if(response == 1){
GetPlayerPos(goid, xg, yg, zg);
SetPlayerPos(fromid, xg, yg, zg);
} else {
new string[256];
format(string, sizeof(string), "%s He refused the request", gname);
SendClientMessage(fromid, RED, string);
}
}

[SsC11]MAVERIK
05/06/2010, 07:23 PM
Little up

DarK_FeneR
25/05/2012, 01:46 PM
i've a warnings and one bug ingame


C:\Users\Vincenzo\Desktop\M3 Server SAMP 0.3e\filterscripts\teleport.pwn(35) : warning 217: loose indentation
C:\Users\Vincenzo\Desktop\M3 Server SAMP 0.3e\filterscripts\teleport.pwn(54) : warning 217: loose indentation
C:\Users\Vincenzo\Desktop\M3 Server SAMP 0.3e\filterscripts\teleport.pwn(56) : warning 217: loose indentation
C:\Users\Vincenzo\Desktop\M3 Server SAMP 0.3e\filterscripts\teleport.pwn(62) : warning 217: loose indentation
C:\Users\Vincenzo\Desktop\M3 Server SAMP 0.3e\filterscripts\teleport.pwn(76) : warning 217: loose indentation
C:\Users\Vincenzo\Desktop\M3 Server SAMP 0.3e\filterscripts\teleport.pwn(82) : warning 217: loose indentation
C:\Users\Vincenzo\Desktop\M3 Server SAMP 0.3e\filterscripts\teleport.pwn(85) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


7 Warnings.