MySQL pickups question
#1

Hi. I'm scripting a little server for myself, I have not scripted anything for a long time tho.
My Pickups save to MySQL and load from there fine, but I need a script, that if you step on the pickups (PickupTypes are 1), you'll be teleported to somewhere else.
My MySQL struct:
Код:
INSERT INTO `pickups` (`PickupX`, `PickupY`, `PickupZ`, `PickupModel`, `PickupType`)
Code to spawn pickups
PAWN
Код:
stock AddPickupFromFile()
{
    new
		Str[67],
		PType,
		PModel,
		Float:PX,
		Float:PY,
		Float:PZ,
		pTotal;

	mysql_query("SELECT * FROM `pickups`");
	mysql_store_result();
    if(mysql_num_rows() > 0)
    {
        while(mysql_fetch_row(Str))
        {
	        sscanf(Str, "p<|>fffii", PX, PY, PZ, PModel, PType);
	        CreateDynamicPickup(PModel, PType, PX, PY, PZ, -1, -1, -1, PICKUPDISTANCE);
	        pTotal++;
		}
	}
	mysql_free_result();
	printf("** %i\t<->\tPickups Loaded From\t<->\tMySQL\t\t   **", pTotal);
	return 1;
}

stock AddPickupToFile(Float:PX, Float:PY, Float:PZ, PModel, PType)
{
	new
		Query[200];

	format(Query, sizeof(Query), "INSERT INTO `pickups` (PickupX, PickupY, PickupZ, PickupModel, PickupType) VALUES(%f, %f, %f, %d, %d)",
	PX, PY, PZ, PModel, PType);

	mysql_query(Query);
	mysql_free_result();
	return 1;
}
It's from [L3th4l]'s gm

Hope you understood my sh*tty English and can help me

Thanks
Reply
#2

Anyone :S?
Reply
#3

Use this callback

pawn Код:
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
    if(pickupid == /*id you want to teleport from*/)
    {
        SetPlayerPos(playerid, /*coords*/);
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by MadeMan
Посмотреть сообщение
Use this callback

pawn Код:
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
    if(pickupid == /*id you want to teleport from*/)
    {
        SetPlayerPos(playerid, /*coords*/);
    }
    return 1;
}
Thanks for reply.

But I only have x,y,z,pickup type and pickup model. Where could i get pickupid? No entry for this on mysql nor word "pickupid" in my pawno script.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)