Custom Spawn location based on UID?

Manatee Hunter

Valued Member!
Wondering if its possible to give custom spawn locations for specific UIDs. Seeing as how these individuals can be given a specific skin on log in. The main reason I'd like to do this is so that clans can EARN this as something for collecting a ton of materials.. This way they can respawn back at base.

On a side note: I've been toying with the the loadout lottery Torndeco had posted a while back and was wondering if it was possible to equip specific loadouts in the lottery with specific skins (w/o it being an item in their inventory but rather on their character)
 
Sure, you can use MySQL Triggers (depending on what build you use) Lets say a person of a specific group dies, you want to set his next spawnpoint to a custom place

Code:
BEGIN
DECLARE x INT;
SET x = (SELECT unique_id FROM cust_loadout_profile WHERE unique_id=NEW.unique_id);
IF NEW.unique_id = x THEN
    SET worldspace='[152,[-18697.6,25815.301,0.001]]';
END IF;
END

This is the "body" of a SQL trigger, here I've used the cust_loadout_profile table to keep my specific group ids in. You can create a new groupspawntable instead :) I'm checking that the person who died has a ID match in the table, if he does, I set a custom worldspace coordinate on his new spawn.
 
I'm with Dayz.ST, I have experience with how my DB is set up and what it does and i'm capable of screwing around with my pbos just fine, I assume this is going to require some sort of DB toying around + server.pbo alterations?

BUT I am not capable of writing anything on my own :S
 
I'm with Dayz.ST, I have experience with how my DB is set up and what it does and i'm capable of screwing around with my pbos just fine, I assume this is going to require some sort of DB toying around + server.pbo alterations?

BUT I am not capable of writing anything on my own :S
Alright, you're probably using reality (former bliss), it's purely SQL. I'll write the sql when i get home and test it before i post it
 
Awesome!

Pretty much wanted to give clans or players the opportunity to gain a priv like this by doing X list of tasks.

I figure if something like this can be achieved, rewards for survival time / zombie kills / humanity level can be done as well
 
yeah, you can always use the data for a IF-sentence :) Haven't tried it, but this should work


Code:
delimiter $$
CREATE TRIGGER `custom_spawn` BEFORE INSERT
    ON `databasename`.`survivor`
    FOR EACH ROW
BEGIN
DECLARE x INT;
DECLARE y STRING;
SET x = (SELECT unique_id FROM cust_spawn WHERE unique_id=NEW.unique_id);
SET y = (SELECT worldspace FROM cust_spawn WHERE unique_id=NEW.unique_id);
IF NEW.unique_id = x THEN
SET NEW.worldspace=y;
END IF;
END
delimiter ;
 
 
CREATE TABLE `cust_spawn` (
`unique_id` INT(10) NULL DEFAULT NULL,
`worldspace` VARCHAR(50) NULL DEFAULT NULL
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;

First, create the trigger (first block of code), then create the second block of code (execute as query) insert a unique_id and worldspace like the one in survivor table - remember to change databasename to the name of your database. Everything a new character is created, it checks if he exists in the cust_spawn table, if he does, it sets his new spawn-location to the one specified in cust_spawn.worldspace :) Let me know how it works out
 
My apologies, I don't fully grasp what you've stated here, I've created the tables, but not sure how the rest is done... If you don't mind clarifying it would be greatly appreciated, if not, thanks for the push in the right direction :)
 
yeah, you can always use the data for a IF-sentence :) Haven't tried it, but this should work


Code:
delimiter $$
CREATE TRIGGER `custom_spawn` BEFORE INSERT
    ON `databasename`.`survivor`
    FOR EACH ROW
BEGIN
DECLARE x INT;
DECLARE y STRING;
SET x = (SELECT unique_id FROM cust_spawn WHERE unique_id=NEW.unique_id);
SET y = (SELECT worldspace FROM cust_spawn WHERE unique_id=NEW.unique_id);
IF NEW.unique_id = x THEN
SET NEW.worldspace=y;
END IF;
END
delimiter ;
 
 
CREATE TABLE `cust_spawn` (
`unique_id` INT(10) NULL DEFAULT NULL,
`worldspace` VARCHAR(50) NULL DEFAULT NULL
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;

First, create the trigger (first block of code), then create the second block of code (execute as query) insert a unique_id and worldspace like the one in survivor table - remember to change databasename to the name of your database. Everything a new character is created, it checks if he exists in the cust_spawn table, if he does, it sets his new spawn-location to the one specified in cust_spawn.worldspace :) Let me know how it works out

how do i create the trigger iam using navicat and having problems with that part
 
My apologies, I don't fully grasp what you've stated here, I've created the tables, but not sure how the rest is done... If you don't mind clarifying it would be greatly appreciated, if not, thanks for the push in the right direction :)

You simply put each block of code and execute it as a query on your database :) Table i've tested, teh trigger I haven't yet, so there MIGHT be some syntax errors, but try it out :) remember if the trigger stops people from respawning/new people joining, remove it :)

EDIT: Should I make a video showing it quickly?
 
You simply put each block of code and execute it as a query on your database :) Table i've tested, teh trigger I haven't yet, so there MIGHT be some syntax errors, but try it out :) remember if the trigger stops people from respawning/new people joining, remove it :)

EDIT: Should I make a video showing it quickly?

A video would be nice if that's quicker for you to do than an explanation with each step explained clearly in text.
 
Alright, I'll write it in text before I go on vacation.

First step, create the table - you do that by going into your MySQL Client like Navicat, HeidiSQL or phpmyadmin and then execute a query with this code:

Code:
CREATE TABLE `cust_spawn` (
`unique_id` INT(10) NULL DEFAULT NULL,
`worldspace` VARCHAR(50) NULL DEFAULT NULL
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;

Now that the table has been created, refresh your database so you can see it on the tablelist. Next step is creating the trigger, execute a new query with following code (haven't tested it, but use a client like HeidiSQL and use "Create Trigger" which is easier, remember to change
Code:
ON databasename
to the name of your database. Execute the query.

Code:
delimiter $$
CREATE TRIGGER "custom_spawn_trigger" BEFORE INSERT
    ON databasename.survivor
    FOR EACH ROW
BEGIN
DECLARE x INT;
DECLARE y STRING;
SET x = (SELECT unique_id FROM cust_spawn WHERE unique_id=NEW.unique_id);
SET y = (SELECT worldspace FROM cust_spawn WHERE unique_id=NEW.unique_id);
IF NEW.unique_id = x THEN
SET NEW.worldspace = y;
END IF;
END
delimiter ;


Now go to cust_spawn table and add a new row with the unique ID of a person who needs a custom spawnpoint and add the custom spawnpoint in the worldspace column.


I can't help the next week, since I'm on vacation untill sunday. But play around with it if it doesn't work :)
 
Alright, I created the table and I tried the second part, but it doesn't actually do anything? - A box flashes for like.. 0.01 seconds saying loading, doesn't say anything went wrong though
 
i tried this and i got no errors but when i put my id in and a worldspace kill myself i dont spawn where i selectected
 
I have been having the same issue! I added in the trigger and table exactly how it says here and the custom spawns do not take effect. Any help with this would be greatly appreciated!
 
I will give it a try when I get home from work in 8 hours. And see if i can create a "step by step" guide with where to insert what etc. ;)
 
That would be much appreciated Midnight^.

I created the table without much issue, after entering it in SQL tab and I seemingly got the trigger to go through as a query. I tested it after setting myself as dead via the database. However this was without a server restart, I'll try that next and then post what I did.

EDIT: Post server restart and I'm still spawning on the coast.
 
Alright, I created the table and I tried the second part, but it doesn't actually do anything? - A box flashes for like.. 0.01 seconds saying loading, doesn't say anything went wrong though

I'm with Dayz.st and this doesn't work. Hope the step by step tutorial helps :)

I wouldn't recommend fiddling around with it either until midnight comes back with the correct step by step, as you can screw up your database if you aren't careful.
 
I'm with Dayz.st and this doesn't work. Hope the step by step tutorial helps :)

I wouldn't recommend fiddling around with it either until midnight comes back with the correct step by step, as you can screw up your database if you aren't careful.

... Careful... Database.... Fiddling.... Hope... Screw.... Midnight. - Tenderly.
 
Back
Top