start plugin
Started by waplet
20/03/2012 22:08
Page 1 of 1
waplet20/03/2012 22:08
What's wrong with it?
It teleports me somewhere in the sky.. Btw is this causing the tag mismatch error on the line 42? Please help, got to make it work. New at Pawn
#include
#include
#include // For some Adminstuf
#include // My most used module ;o
#include
#pragma semicolon 1
new g_Mapname[64], g_Filename[128];
public plugin_init()
{
register_plugin("Start position", "1.0", "PrEn1umz");
register_clcmd("say /start", "goStart");
register_clcmd("say /setstart", "setStart", ADMIN_MAP, "");
register_clcmd("say /delstart", "delStart", ADMIN_MAP, "");
get_mapname(g_Mapname, 63);
format(g_Filename, 127, "addons/amxmodx/configs/start/%s.txt", g_Mapname);
}
public goStart(id)
{
if (file_exists(g_Filename))
{
new temp[64], pos[3], str1[13], str2[13], str3[13];
new file = fopen(g_Filename, "rt");
while(!feof(file))
{
fgets(file, temp, 63);
parse(temp, str1, 12, str2, 12, str3, 12);
pos[0] = str_to_num(str1);
pos[1] = str_to_num(str2);
pos[2] = str_to_num(str3);
client_print(id, print_chat, "%d - 1", pos[0]);
client_print(id, print_chat, "%d - 2", pos[1]);
client_print(id, print_chat, "%d - 3", pos[2]);
new Float:origin[3];
//engfunc(EngFunc_SetOrigin, id, pos);
entity_get_vector(id,EV_VEC_origin,origin);
entity_set_origin(id,pos);
entity_set_vector(id,EV_VEC_velocity,Float:{0.0,0.0,0.0});
}
client_print(id, print_chat, "* Tu tiki teleporteets uz startu");
fclose(file);
}
else
{
client_print(id, print_chat, "* Nav uzlikta starta poziicija");
}
}
public setStart(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
{
client_print(id, print_chat, "* Rokas nost");
return PLUGIN_HANDLED;
}
if (file_exists(g_Filename))
{
client_print(id, print_chat, "* Starta poziicija jau ir uzlikta. Raksti /delstart");
}
else
{
new i[3], temp[128];
get_user_origin(id, i);
format(temp, 127, "%d %d %d", i[0], i[1], i[2]);
write_file(g_Filename, temp, 0);
client_print(id, print_chat, "* Starta poziicija uzlikta");
}
return PLUGIN_HANDLED;
}
public delStart(id, level, cid)
{
if (!cmd_access(id, level, cid, 1))
{
client_print(id, print_chat, "* Rokas nost");
return PLUGIN_HANDLED;
}
if (file_exists(g_Filename))
{
delete_file(g_Filename);
client_print(id, print_chat, "* Starta pozicija izdzeesta");
}
else
{
client_print(id, print_chat, "* Nav starta pozicijas");
}
return PLUGIN_HANDLED;
} irQuaker21/03/2012 03:45
Got it to work, but it can be done a lot more efficiently.
http://pastebin.com/tECTxzqv
Page 1 of 1
Please log in to post replies.