CS是很久以前的游戏了。mac上最小支持的就是1.6.....在steam里能下载到的最小版本也只有1.6。
客户端好找,但是创建一个server就比较麻烦了。所幸gameservermanagers.com真是一个良心网站,就提供了一键创建server包。
1、先加入源,并更新: dpkg --add-architecture i386; apt-get update; apt-get install mailutils postfix curl wget file bzip2 gzip unzip bsdmainutils python util-linux tmux lib32gcc1 libstdc++6 libstdc++6:i386
2、创建用户并以该用户登录:adduser csserver / passwd csserver / su csserver
3、下载安装包wget https://gameservermanagers.com/dl/csserver ,设置可执行权限 chmod +x csserver
4、执行它:./csserver install
然后就完事了。。。安装完后
./csserver start就能启动了
还有一些命令,如stop/restart/console/details/update/force-update/debug等
更详细 的还是直接看官网吧:https://gameservermanagers.com/lgsm/csserver/
看看它support server list。。。吓尿你
一个很简单的laravel代码:
PHP代码
- User::where('id',1)->update(['last_login'=>time()]);
这样一个简单的代码,你会发现,它并没有触发:updating,updated事件,然而,你又会发现,updated_at也更新了。这是怎么回事?
跟进代码看一下,你会发现这个update,是Eloquent\Builder的方法,它的update方法代码很简单:
PHP代码
-
-
-
-
-
-
- public function update(array $values)
- {
- return $this->toBase()->update($this->addUpdatedAtColumn($values));
- }
我擦 ,要不要这么直接?再看一下toBase,这回是调用的是Query\Builder了。这里的update,就纯粹是生成sql,然后execute,不再走EloquentORM的事件了,所以就不会触发任何事件。
那么要怎么样才能触发事件呢?方法有两种
1、不要这样简写:先读数据再update,就一定会触发
2、不要用where(),而是直接User::find(1)->update([]),这时候就会从ORM走了。
这事儿官方有解释:
https://laravel.com/docs/5.3/eloquent#updates
- When issuing a mass update via Eloquent, the saved and updated model events will not be fired for the updated models. This is because the models are never actually retrieved when issuing a mass update.
同时,这事儿在stackoverflow上也有很多人在问,有人回复的就是和我上面的一样:
http://stackoverflow.com/questions/41295032/laravel-eloquent-model-update-event-is-not-fired
- You need to retrieve the user from the database and then save that user in order to fire the event. For example:
-
- This will NOT fire the update event:
-
- User::where('id', $id)->update(['username' => $newUsername]);
- This will fire the update event:
-
- User::find($id)->update(['username' => $newUsername]);
官方的解释我是看过了,下面的是我用了很多办法没法解决后才找到的。
我在想,use SoftDeletes可以注入代码,为什么我不行?直到我发现softdeletes是官方自带库,人家都准备了事件:onDelete了。。怎么就没有onUpdate事件可以让我加点字段呢?
然后我又想用其他的Scope,也没有成功(折腾了一个下午)
暂时放弃!就这样吧,不过我还在想想,有没有什么办法可以注入,因为在sql生成完后,它还是有触发的事件的,比如:
PHP代码
-
-
-
-
-
-
-
-
- public function logQuery($query, $bindings, $time = null)
- {
- if (isset($this->events)) {
- $this->events->fire(new Events\QueryExecuted(
- $query, $bindings, $time, $this
- ));
- }
-
- if ($this->loggingQueries) {
- $this->queryLog[] = compact('query', 'bindings', 'time');
- }
- }
-
- /**
- * Register a database query listener with the connection.
- *
- * @param \Closure $callback
- * @return void
- */
- public function listen(Closure $callback)
- {
- if (isset($this->events)) {
- $this->events->listen(Events\QueryExecuted::class, $callback);
- }
- }
-
- /**
- * Fire an event for this connection.
- *
- * @param string $event
- * @return void
- */
- protected function fireConnectionEvent($event)
- {
- if (! isset($this->events)) {
- return;
- }
-
- switch ($event) {
- case 'beganTransaction':
- return $this->events->fire(new Events\TransactionBeginning($this));
- case 'committed':
- return $this->events->fire(new Events\TransactionCommitted($this));
- case 'rollingBack':
- return $this->events->fire(new Events\TransactionRolledBack($this));
- }
- }
实在不行了,还可以在事务上面想想办法,但是总归是只能一次处理,如果是需要两次执行sql。那还不如直接写代码呢。等有空再看了